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.7k stars 1.06k forks source link

Using the -o build option creates invalid multi-target framework NuGet packages #18614

Open TroyWalshProf opened 3 years ago

TroyWalshProf commented 3 years ago

Steps To Reproduce

  1. Create a simple csproj file.
    Example:
    <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
    <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    </PropertyGroup>
    </Project>
  2. Open a command window and CD to the folder containing the CSProj.
  3. Run the following build command: dotnet build PROJECTNAME.csproj -c Release -o .
  4. Note that the DLL was build twice but in the exact same location image
  5. Change the extension of the resulting nupkg file to .zip and unzip the package
  6. Compare the DLLs in the framework specific subfolders of lib

Result: The package will looks correct. It will have framework specific lib subfolders. But, if you look at the individual DLLs you will find that the the DLLs are in fact all identical. What is happening is that framework specific DLLs are all being built, but each build overwrites the previous. Then once all the builds are done the NuGet package build pulls the one remaining (last built) DLL for all frameworks.

Desired Behavior It would expect the build to fail when creating the NuGet package. *Would at least be nice to get some kind of warning

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.