Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

[MIGRATION]: NuGet content and tools files not migrated correctly  #11

@livarcocc

Description

@livarcocc

From @Daniel15 on May 8, 2017 5:39

Steps to reproduce

Repro project: nugetbug.zip

project.json:

{
  "version": "0.0.1-*",
  "title": "NuGetBugExample",
  "packOptions": {
    "files": {
      "include": [
        "tools",
        "Content"
      ]
    },
  },
  "frameworks": {
    "net40": {}
  }
}

global.json:

{
  "sdk": {
    "version": "1.0.0-preview2-003121"
  }
}

Content/README.txt and tools/install.ps1 are just placeholders with any content

  1. Run dotnet pack with the 1.0.0-preview2 tooling, and inspect the generated NuGet package. Notice that the README.txt and install.ps1 are in the right place:
  2. Delete global.json
  3. Run dotnet migrate and dotnet restore
  4. Run dotnet pack again.

Expected behavior

Package should be built exactly the same as it was with the old tooling

Actual behavior

  1. Warning is thrown while packing:
warning : Issue found with package 'nugetbug'. [C:\temp\nugetbug\nugetbug.csproj]
warning : Issue: PowerShell file outside tools folder. [C:\temp\nugetbug\nugetbug.csproj]
warning : Description: The script file 'content\tools\install.ps1' is outside the 'tools' folder and hence will not be executed during installation of this package. [C:\temp\nugetbug\nugetbug.csproj]
warning : Solution: Move it into the 'tools' folder. [C:\temp\nugetbug\nugetbug.csproj]
warning : Issue: PowerShell file outside tools folder. [C:\temp\nugetbug\nugetbug.csproj]
warning : Description: The script file 'contentFiles\any\net40\tools\install.ps1' is outside the 'tools' folder and hence will not be executed during installation of this package. [C:\temp\nugetbug\nugetbug.csproj]
warning : Solution: Move it into the 'tools' folder. [C:\temp\nugetbug\nugetbug.csproj]
  1. README.txt and install.ps1 are in the wrong place: content/Content/readme.txt and content/tools/install.ps1

This is due to an issue in the generated csproj file. The following segment is added to the file:

<ItemGroup>
  <None Update="tools\**\*;Content\**\*">
    <Pack>true</Pack>
  </None>
</ItemGroup>

However, it's missing the PackagePath to place the files in the right location. The correct XML looks like this, as per the documentation at https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets#including-content-in-a-package

<ItemGroup>
  <Content Include="tools\**\*">
    <Pack>true</Pack>
    <PackagePath>tools\</PackagePath>
  </Content>
  <Content Include="Content\**\*">
    <Pack>true</Pack>
    <PackagePath>content\</PackagePath>
  </Content>
</ItemGroup>

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0)

Product Information:
 Version:            1.0.0
 Commit SHA-1 hash:  e53429feb4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16188
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0

cc @blackdwarf and @livarcocc

Copied from original issue: dotnet/cli#6544

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions