Reputation: 20057
I'd like to create a folder during my TFS build process, in this case it's a 'TempImages' folder which I don't want as part of the solution, nor source control.
To achieve this locally I set up the following post build action:
IF NOT EXIST "$(ProjectDir)\TempImages\" mkdir "$(ProjectDir)\TempImages\"
This works like a charm, except when using TFS to publish to my test environment the folder is not created.
After some googling, I found I may need to perform this action in a slightly different way, so added the following to my .csproj
file.
<Target Name="AfterBuild">
<Exec Command="IF NOT EXIST "$(ProjectDir)\TempImages\" mkdir "$(ProjectDir)\TempImages\""></Exec>
</Target>
Unfortunately, this doesn't seem to have done the trick.
What's the recommended route to create a folder on post build / post deployment through TFS for this purpose?
Upvotes: 0
Views: 1640
Reputation: 1604
Both should work. The problem is likely to be that the TempImages folder is getting created in the TFS sources folder instead of the output / drop folder.
You could try changing the $(ProjectDir)
property to one of:
$(WebProjectOutputDir)
$(TF_BUILD_BINARIESDIRECTORY)
$(TF_BUILD_DROPLOCATION)
The latter two will only work for TF Build and you will almost certainly need to add a relative path suffix, e.g. $(TF_BUILD_BINARIESDIRECTORY)\MyWebSite\TempImages\
.
You can add conditional logic to your post build event or MSBuild target to detect when building from TF Build based on the $(TF_BUILD)
property.
http://msdn.microsoft.com/en-us/library/hh850448.aspx
Upvotes: 4