My .csproj defines the following post build event in the .csproj file that regenerates a symbolic link. This works fine inside with a manual Visual Studio build and the symlink gets regenerated without issue:
<PostBuildEvent>
del C:\foo\foo\bin\debug\my.config
mklink C:\bar\bar\bar\bar\bar\bar\bin\debug\my.config c:\baz\baz\my.config
</PostBuildEvent>
However, I am trying to set up continuous integration using TFS2015 with automated builds using MSBuild, however in this case, the build fails with 'the command mklink C:\bar\bar\bar\bar\bar\bar\bin\debug\my.config c:\baz\baz\my.config exited with code 1'.
How do I go about regenerating a symbolic link via an automated build?
I resolved this by setting the variable $(BuildingInsideVisualStudio) to true inside my csproj file in the following way:
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<PostBuildEvent>
del C:\foo\foo\bin\debug\my.config
mklink C:\bar\bar\bar\bar\bar\bar\bin\debug\my.config c:\baz\baz\my.config
</PostBuildEvent>
</PropertyGroup>
I had seen this as a possible answer elsewhere, however the posts I saw showed incorrect syntax and did not clearly illustrate how to use the variable within the context of the csproj build script. Hopefully this will clarify for someone.
This MSDN article was useful: https://msdn.microsoft.com/en-us/library/ms171468(v=vs.140).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With