Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning NU5118 packaging RCL with static contents and multi-target frameworks netcoreapp3.1;net5.0 #10253

Closed
tmm360 opened this issue Nov 11, 2020 · 2 comments
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Pack Priority:2 Issues for the current backlog. Product:dotnet.exe Type:Bug

Comments

@tmm360
Copy link

tmm360 commented Nov 11, 2020

Details about Problem

Trying to package a Razor Class Library that contains static contents, and that multi-targets the frameworks netcoreapp3.1 and net5.0, I receive several NU5118 warnings. I'm using dotnet pack command from stable .NET 5 SDK. Building works without warnings, packaging no.

dotnet.exe --version: 5.0.100
VS version: 16.8.0

Detailed repro steps so we can see the same problem

  1. Create a new RCL project with this minimal project file:
<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
  </PropertyGroup>

</Project>
  1. Add a wwwroot directory with a sample static file inside

  2. Try to pack it with dotnet pack, or VS UI.

Logs

1>------ Build started: Project: RazorClassLibrary1, Configuration: Debug Any CPU ------
1>RazorClassLibrary1 -> C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\bin\Debug\net5.0\RazorClassLibrary1.dll
1>RazorClassLibrary1 -> C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\bin\Debug\netcoreapp3.1\RazorClassLibrary1.dll
1>C:\Program Files\dotnet\sdk\5.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(207,5): warning NU5118: File 'C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\wwwroot\background.png' is not added because the package already contains file 'staticwebassets\background.png'
1>C:\Program Files\dotnet\sdk\5.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(207,5): warning NU5118: File 'C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\obj\Debug\netcoreapp3.1\staticwebassets\msbuild.RazorClassLibrary1.Microsoft.AspNetCore.StaticWebAssets.props' is not added because the package already contains file 'build\Microsoft.AspNetCore.StaticWebAssets.props'
1>C:\Program Files\dotnet\sdk\5.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(207,5): warning NU5118: File 'C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\obj\Debug\netcoreapp3.1\staticwebassets\msbuild.build.RazorClassLibrary1.props' is not added because the package already contains file 'build\RazorClassLibrary1.props'
1>C:\Program Files\dotnet\sdk\5.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(207,5): warning NU5118: File 'C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\obj\Debug\netcoreapp3.1\staticwebassets\msbuild.buildMultiTargeting.RazorClassLibrary1.props' is not added because the package already contains file 'buildMultiTargeting\RazorClassLibrary1.props'
1>C:\Program Files\dotnet\sdk\5.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(207,5): warning NU5118: File 'C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\obj\Debug\netcoreapp3.1\staticwebassets\msbuild.buildTransitive.RazorClassLibrary1.props' is not added because the package already contains file 'buildTransitive\RazorClassLibrary1.props'
1>Successfully created package 'C:\Users\mirko\Desktop\wow\WebApplication1\RazorClassLibrary1\bin\Debug\RazorClassLibrary1.1.0.0.nupkg'.
1>Done building project "RazorClassLibrary1.csproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Sample Project

RazorClassLibrary1.zip

@zkat zkat added the Category:Quality Week Issues that should be considered for quality week label Nov 23, 2020
@zkat zkat self-assigned this Nov 23, 2020
@zkat zkat added the Priority:2 Issues for the current backlog. label Nov 3, 2021
@tmm360
Copy link
Author

tmm360 commented Apr 1, 2022

This looks to be fixed

@tmm360 tmm360 closed this as completed Apr 1, 2022
@bigabdoul
Copy link

bigabdoul commented Aug 31, 2022

This issue is old, but it still does not unambiguously resolve the root cause. After investigating, I noticed that the issue arose from the lack of the Razor Language Version specification when targeting multiple frameworks. In other words, there should be an explicit and appropriate Razor Language Version property group for each target framework. The above project file should look like:

<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
    <RazorLangVersion>5.0</RazorLangVersion>
  </PropertyGroup>
</Project>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Pack Priority:2 Issues for the current backlog. Product:dotnet.exe Type:Bug
Projects
None yet
Development

No branches or pull requests

6 participants