views:

175

answers:

2

I am using an InvokeProcess activity in TFS 2010 to try and run the corflags application on a built exe.

C:\Builds\4\testing\Sources\BuildAssets\corflags.exe C:\Builds\4\testing\Binaries\Executable.exe /32bit+

However I am getting the following message:

corflags : error CF001 : Could not open file for writing

I am running the TFS Build Agent on my local machine because I am currently in a testing phase, and when I run the exact same command from the command line, the corflags application completes without error.

Any ideas would be greatly appreciated.

A: 

I'm not familiar with the specific situation but some general ideas:

Who is the build running as? Does that user have permissions to the output path?

Another consideration is: Has the build completed before it attempts to execute your command?

Try changing the command to be something really simple eg Type "OutputFile" - Does this hit the same issue? If so, it's a permission/timing issue. If not, it's the specific command - but at least we'll have narrowed the problem down.

Basiclife
The build is running under my account which has full access to the directories.I do all my post build steps after the compilation is complete and has been set to BuildPhaseStatus.Complete.I am able to achieve other commands such as creating directories. Ewald Hofman has answered above and mentions the read only state of the two files.Corflags is readonly being part of the source (only for simplicity of scaling the build agents in the future), but the exe I am trying to change the headers on is not read only. Thanks.
Swaff
Does this error occur for any [write] operation against the .exe or only for corflags?
Basiclife
Other than the creation of the exe by the build process, corflags.exe is the only other application that attemtps to modify my output.
Swaff
I'm aware that that's true in the normal process but what I'm trying to identify is whether it's a problem with corflags or the exe itself - so can you try changing the command to delete it instead of corlfags'ing it? Does that also fail? If so, it's permissions/similar. If not, it's something to do with corflags. At present we don't know if it's a problem with the file or the operation you're attempting on it.
Basiclife
It turned out to be that the share for the output directory was not set up to allow the correct user to perform the operation. Permissions after all. Many thanks.
Swaff
+1  A: 

I don't know the corflags either, but it is using a file in the workspace (a file that is downloaded from Version Control). There is a readonly flag on this file by default.

So if you need this file to be writable:
1) either checkout the file if you need this file in your version control and afterwards check it in again (tf checkout / tf checkin)
2) remove the file from version control if the file is created by the app
3) remove the readonly flag with the attrib command.

Ewald Hofman