Passing AssemblyName as argument of MSBuild propagates it to referenced projects.
Version Used: .NET SDK 9.0.203
Steps to Reproduce:
- Create a .NET Class Library. Name it P1.
- Create a second .NET Class Library. Name it P2.
- Add project reference in P2 to P1.
- Build P2 from command-line using msbuild.exe with the following command:
msbuild.exe P2.csproj /p:AssemblyName="P3"
A minimal repro, with source-code provided, is ideal. Most compiler/language issues can be distilled into a snippet that can be pasted into sharplab.
Diagnostic Id: n/a
Expected Behavior:
- Have P3.dll in P2's /bin folder.
- Have P1.dll in P1's /bin folder, because the argument 'AssemblyName' is not supposed to be propagated.
Actual Behavior:
- Have P3.dll in P2's /bin folder.
- Have P3.dll in P1's /bin folder.
- Both dlls contain their respective codebase.
When inspecting the P3.dll in P2 project folder, a circular reference is observed:
The issue is reproducible with .NET and .NET Framework SDK-style project files. I've attached 2 .zips, demonstrating the issue in .NET 8 and .NET Framework 4.6.2. ProjRef_net462.zip ProjRef_net8.zip
You can set the AssemblyName property in P2's csproj file, then it's not propagated. Command line arguments are propagated, that's by design.
MSBuild triage: This is by design. Please take a look at this document for more information https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-properties?view=visualstudio#global-properties.