In one of our web applications, it is required that some HTML pages be editable in a GUI interface we created for the user. Unfortunately, the interface directly reads/writes f
I bumped on this & assume it's connected with this question as well.
What @Duat suggests has worked for me, within the scope of the Build-Agent server. Yet, in your other question, you mention a net-drive - so I suppose you 're talking about file(s) residing either in the drop location of your build, or on the target computer where MSBuild/MSDeploy deploys your solution.
I will advance with the first assumption (so, we 'll focus on Drop Location), but it should be similar to handle the matter in either case.
The idea bases on a strategically placed 'xcopy'. ('xcopy' per default resets all file attributes into read-write during execution)
The first step is to construct a custom activity that sets the files you need into read-write. A quick first draft of the activity can be this (it's meant to change the attributes of a file, not a dir):
namespace BuildTasks.Activities
{
using System;
using System.Activities;
using System.IO;
using Microsoft.TeamFoundation.Build.Client;
[BuildActivity(HostEnvironmentOption.Agent)]
public sealed class MakeFileWriteable : CodeActivity
{
[RequiredArgument]
public InArgument FilePath
{
get;
set;
}
protected override void Execute(CodeActivityContext context)
{
String filePath = FilePath.Get(context);
//add exception handling
FileAttributes fileAttributes = File.GetAttributes(filePath);
File.SetAttributes(filePath, fileAttributes & ~FileAttributes.ReadOnly);
}
}
}
The second step, now once you have MakeFileWritable
in your build solution, is to change your build definition from this
into something like this
The file in MakeFileWriteable
should be from within the BuildAgent and is the FROMFILE in the InvokeProcess that follows:
TOFILE is where the file should land.
Remember to set the "/Y" in the arguments, since you 'll be overwriting the file.