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

Change NuGet package to use None ItemGroup to copy files to output directory #703

Merged

Conversation

inthemedium
Copy link
Member

Without this change, files from this nuget package will be included
automatically when the consuming project is packing.

Example error when packing a project:

C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5):
warning NU5100: The assembly 'content\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' is
not inside the 'lib' folder and hence it won't be added as a reference
when the package is installed into a project. Move it into the 'lib'
folder if it needs to be referenced.

Additionally, add the contents to an ItemGroup so they can be seperated later if needed.

…directory

Without this change, files from this nuget package will be included
automatically when the consuming project is packing.

Example error when packing a project:
> C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5):
warning NU5100: The assembly 'content\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' is
not inside the 'lib' folder and hence it won't be added as a reference
when the package is installed into a project. Move it into the 'lib'
folder if it needs to be referenced.

Additionally, add the contents to an ItemGroup so they can be seperated later if needed.
@nohwnd nohwnd self-assigned this Mar 25, 2020
@nohwnd nohwnd added this to the 16.7.0 milestone Mar 25, 2020
@nohwnd
Copy link
Member

nohwnd commented Mar 25, 2020

Thanks for the PR, added it to 16.7.0. If you shared a bit more about why this is an issue, and how to replicate it, that would be great 🙂

@inthemedium
Copy link
Member Author

inthemedium commented Mar 25, 2020

Thanks for the PR, added it to 16.7.0. If you shared a bit more about why this is an issue, and how to replicate it, that would be great 🙂

Why it's an issue: any projects package referencing the MSTest.TestAdapter cannot be packed without non-trivial modifications to get rid of the pack warnings.

Here's a sample .csproj file that illustrates the issue:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
  </ItemGroup>
</Project>

Output:

1>------ Build started: Project: ConsoleApp22, Configuration: Debug Any CPU ------
1>ConsoleApp22 -> C:\Users\...\source\repos\ConsoleApp22\ConsoleApp22\bin\Debug\netcoreapp3.1\ConsoleApp22.dll
1>Successfully created package 'C:\Users\...\source\repos\ConsoleApp22\ConsoleApp22\bin\Debug\ConsoleApp22.1.0.0.nupkg'.
1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5100: The assembly 'content\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5100: The assembly 'contentFiles\any\netcoreapp3.1\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5100: The assembly 'content\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5100: The assembly 'contentFiles\any\netcoreapp3.1\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5100: The assembly 'content\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5100: The assembly 'contentFiles\any\netcoreapp3.1\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
1>Done building project "ConsoleApp22.csproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Expected output:

1>------ Build started: Project: ConsoleApp22, Configuration: Debug Any CPU ------
1>ConsoleApp22 -> C:\Users\...\source\repos\ConsoleApp22\ConsoleApp22\bin\Debug\netcoreapp3.1\ConsoleApp22.dll
1>Successfully created package 'C:\Users\...\source\repos\ConsoleApp22\ConsoleApp22\bin\Debug\ConsoleApp22.1.0.0.nupkg'.

@nohwnd
Copy link
Member

nohwnd commented Mar 25, 2020

Thanks, helps a lot :)

@nohwnd nohwnd merged commit ccc0dd8 into microsoft:master Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants