I have a .sln solution file that references a .csproj project file that has an after build task of something like:
<PropertyGroup>
<PostBuildEvent>
xcopy $(SolutionDir)\dir1\Somefle.xml $(ProjectDir) /Y /I
</PostBuildEvent>
</PropertyGroup>
The solution is built using msbuild with a task like the following:
<Target Name="CompileSolution">
<MSBuild Projects="@(SolutionToBuild)" Targets="Rebuild" Properties="Platform=Any CPU" />
</Target>
Now here’s the strange part:
If I:
- run the build script (say c:\MyWorkingCopy)
- rename the working copy folder (say to c:\YourWorkingCopy)
- run the build script again
On step 3, the xcopy will fail, because it will because it will be trying to copy the file from “c:\MyWorkingCopy” – which of course is not where the solution file now resides.
Why does msbuild use the old Solution directory? And is there some way to reset it?
(I am using .NET Framework 3.5)
It may be related to the sln.cache file that is created by msbuild when you build a sln file (it’s a temporary proj file built from the sln one), if it is present or if the sln is not modified the sln.cache file may be used… I don’t really know but it I think it could help.