When I have a C# console application foo
, and I compile it with
msbuild /p:Configuration=Debug /p:Platform="Any CPU"
Sometimes the resulting executable is
bin\Any CPU\Debug\net7.0\foo.exe"
and sometimes
bin\Debug\net7.0\foo.exe
Why?
Note:
There is no OutputPath
element in any of the project files.
I am not asking how to change the behavior, but why it is currently as it is.
Thanks to Sir Rufo for https://github.com/dotnet/sdk/issues/10188 which turned out to be the clue to the answer: it depends on whether MSBuild is working from a .sln
or .csproj
file. It defaults to the former if present, which means it produces different results for a single-project solution with both files in the same directory, versus a multi-project solution.