Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Do not include "contentFiles/" prefix in <contentFiles/> (issue #6556) #164

Merged
merged 3 commits into from
Oct 15, 2018

Conversation

azeno
Copy link
Contributor

@azeno azeno commented Aug 25, 2018

Nuget expects the include paths relative to the package contentFiles folder (see official examples https://docs.microsoft.com/en-us/nuget/reference/nuspec#including-content-files). Otherwise the BuildAction, CopyToOutput and Flatten attributes have no effect. This PR fixes that by adjusting the included path accordingly.

@dnfclas
Copy link

dnfclas commented Aug 25, 2018

CLA assistant check
All CLA requirements met.

@azeno
Copy link
Contributor Author

azeno commented Aug 25, 2018

Was also already reported here: NuGet/Home#6556

@kzu
Copy link
Contributor

kzu commented Sep 4, 2018

See NuGet/Home#6556 (comment). I don't think this PR is correct.

@jpsalada
Copy link

Can someone approve these changes? We really need this.

@kzu
Copy link
Contributor

kzu commented Oct 15, 2018

Read my comment above and on the linked issue plz.

Thanks

@jpsalada
Copy link

Read the answers to your comment please.

@jpsalada
Copy link

@kzu

I have created a TestProject example. If I put my content dependency this way:

  <ItemGroup>
    <Content Include="mybinarydependency.bin" copyToOutput="true"buildAction="content"flatten="true" packagePath="contentFiles\any\any\mybinarydependency.bin">
    </Content>
  </ItemGroup>

Everything in the package goes ok, but nuspec file get contentFiles in the directory specification:

 <contentFiles>
      <files include="contentFiles\any\any\mybinarydependency.bin" buildAction="content" copyToOutput="true" flatten="true" />
    </contentFiles>

The problem is the nuget restore will not be able to detect the file and will assume default configuration for the dependency (compile, not copy to output), making it impossible to have this type of content in the nuget. Content from project.assets.json:


        "contentFiles": {
          "contentFiles/any/any/mybinarydependency.bin": {
            "buildAction": "**Compile**",
            "codeLanguage": "any",
            "copyToOutput": **false**
          }

Now if I directly change nuget package, namely the nuspec setting include to "any\any\mybinarydependency.bin", while maintaining the directory structure "contentFiles\any\any\mybinarydependency.bin" within the package, nuget restore will detect the file and it will assume the correct properties that have been configurated in the .csproj. buildAction to content and copyToOutput to true.:

        "contentFiles": {
          "contentFiles/any/any/mybinarydependency.bin": {
            "buildAction": "**Content**",
            "codeLanguage": "any",
            "copyToOutput": **true**,
            "outputPath": "mybinarydependency.bin"
          }

@kzu kzu merged commit 30e9954 into NuGet:dev Oct 15, 2018
@jpsalada
Copy link

Thank you so much!

@azeno azeno deleted the issue-6556 branch November 10, 2018 15:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants