dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.06k forks source link

Dotnet publish doesn't pass along specific configuration to dependent csprojects not specified in solution file #15761

Open zlepper opened 3 years ago

zlepper commented 3 years ago

We have a project structure where we are running with 2 solution files. One solution file lists all projects, and are where we normally develop things. The other solution file only lists the main microservices that needs to be published. We do this to make it possible to use the dotnet publish command, and leverage proper parallel builds for all the microservices.

Right now this works because dotnet also compiles all references csprojects, even if they aren't included in the solution file. There is a minor problem however that configuration, like -c Release is not passed along, resulting in the referenced projects not being compiled in release mode.

I have attached a very small sample project that does this. Build it using the build.cmd file. Then go inspect the dotnet-sdk-bug\MyApp\bin\Release\net5.0\win-x64\publish\MyLibrary.dll file with something like DotPeek. Notice how the Console.WriteLine("I'm in debug mode"); is still included, even though the entire solution was compiled in release mode.

dotnet-sdk-bug.zip

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

marcpopMSFT commented 1 year ago

This is not currently supported as cli properties are passed to the members of the solution but not to projects outside of the solution.