This repository was archived by the owner on Mar 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Copy link
Copy link
Open
Labels
Description
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
- Run
dotnet pack
with the1.0.0-preview2
tooling, and inspect the generated NuGet package. Notice that theREADME.txt
andinstall.ps1
are in the right place:
- Delete
global.json
- Run
dotnet migrate
anddotnet restore
- Run
dotnet pack
again.
Expected behavior
Package should be built exactly the same as it was with the old tooling
Actual behavior
- 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]
README.txt
andinstall.ps1
are in the wrong place:content/Content/readme.txt
andcontent/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