Strange behavior with $ (SolutionDir) with msbuild in .csproj file erroneously

I have a .sln solution file that references a .csproj project file that has a task after build:

<PropertyGroup> <PostBuildEvent> xcopy $(SolutionDir)\dir1\Somefle.xml $(ProjectDir) /Y /I </PostBuildEvent> </PropertyGroup> 

The solution is built using msbuild with a task similar to the following:

 <Target Name="CompileSolution"> <MSBuild Projects="@(SolutionToBuild)" Targets="Rebuild" Properties="Platform=Any CPU" /> </Target> 

Now here is the weird part:

If I:

  • run the build script (say c: \ MyWorkingCopy)
  • rename the working copy folder (say c: \ YourWorkingCopy)
  • run the build script again

In step 3, xcopy will fail because it will try to copy the file from "c: \ MyWorkingCopy" - which, of course, is not where the solution file is.

Why is msbuild using the old solution catalog? And is there a way to reset it?

(I am using the .NET Framework 3.5)

+4
source share
1 answer

It can be associated with the sln.cache file that msbuild creates when creating the sln file (this is a temporary proj file built from sln-one) if it is present or if sln is not changed sln.cache can be used ... I really don't know but I think this could help.

+2
source

All Articles