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

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

Open
livarcocc opened this issue May 8, 2017 · 0 comments
Open

Comments

@livarcocc
Copy link
Contributor

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

Daniel15 added a commit to reactjs/React.NET that referenced this issue May 9, 2017
Daniel15 added a commit to reactjs/React.NET that referenced this issue May 11, 2017
* Upgrade to Visual Studio 2017 + csproj tooling

* Include workaround for NuGet/Home#4337 (explicitly specify version when restoring NuGet packages)

* Work around dotnet/cli-migrate#11

* Upgrade to .NET Core 1.1.x

* Remove VersionPrefix from all csproj files

* Legacy NuGet restore is no longer needed

* Disable CS1701 warning for sample projects

* Turns out we actually do need the legacy NuGet restore

* Use VS2017 AppVeyor image

* Remove project dependencies to work around NuGet/Home#5193 and NuGet/Home#4578

* Use MSBuild 15 on AppVeyor

* Enforce .NET Core tools 1.0.0 in global.json

* Use newer npm on AppVeyor (as a workaround for https://github.com/dotnet/cli/issues/6561 and dotnet/msbuild#406), and run correct test command
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant