Arcade: [Content_Types].xml contained in generated Nuget package is invalid

Created on 23 Aug 2019  路  4Comments  路  Source: dotnet/arcade

We are using Arcade to build and publish a nuget package for https://github.com/dotnet/spark . [Content_Types].xml contained in the generated nupkg contains a line for the LICENSE file with leading double slashes // .

[Content_Types].xml contents:

<?xml version="1.0" encoding="utf-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
  <Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
  <Default Extension="dll" ContentType="application/octet" />
  <Default Extension="xml" ContentType="application/octet" />
  <Default Extension="TXT" ContentType="application/octet" />
  <Default Extension="jar" ContentType="application/octet" />
  <Default Extension="targets" ContentType="application/octet" />
  <Default Extension="nuspec" ContentType="application/octet" />
  <Override PartName="//LICENSE" ContentType="application/octet" />
</Types>

This is causing some issues with a pipeline that is consuming our nuget package. The expected behavior should produce a line with a single forwardslash, ie <Override PartName="/LICENSE" ContentType="application/octet" />

The Directory.Build.props containing the LICENSE settings is located at https://github.com/dotnet/spark/blob/master/src/csharp/Directory.Build.props

Do you have any recommendations on how we can get a single / for the xml attribute value ?

Most helpful comment

Note - this behavior is due to NuGet, and not caused by arcade. I can repro this behavior in a vanilla .NET library.

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <PackageLicenseFile>LICENSE</PackageLicenseFile>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="$(MSBuildThisFileDirectory)LICENSE"
             Pack="true"
             PackagePath="\"
             Visible="false" />
  </ItemGroup>

</Project>

Calling dotnet pack on that library will produce a [Content_Types].xml file with a double slash.

I think there are 2 ways to fix this.

  1. Don't use PackageLicenseFile at all, but instead use PackageLicenseExpression.

    • The reason I didn't use PackageLicenseExpression in the first place is because that license expression doesn't match the LICENSE we have in the repo. The LICENSE file in the spark repo contains Copyright (c) 2019 .NET Foundation, which isn't shown when using the PackageLicenseExpression.

  2. Change PackagePath="\" to PackagePath="".

All 4 comments

Cc: @imback82

cc: @eerhardt

Note - this behavior is due to NuGet, and not caused by arcade. I can repro this behavior in a vanilla .NET library.

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <PackageLicenseFile>LICENSE</PackageLicenseFile>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="$(MSBuildThisFileDirectory)LICENSE"
             Pack="true"
             PackagePath="\"
             Visible="false" />
  </ItemGroup>

</Project>

Calling dotnet pack on that library will produce a [Content_Types].xml file with a double slash.

I think there are 2 ways to fix this.

  1. Don't use PackageLicenseFile at all, but instead use PackageLicenseExpression.

    • The reason I didn't use PackageLicenseExpression in the first place is because that license expression doesn't match the LICENSE we have in the repo. The LICENSE file in the spark repo contains Copyright (c) 2019 .NET Foundation, which isn't shown when using the PackageLicenseExpression.

  2. Change PackagePath="\" to PackagePath="".

Thanks @eerhardt for the suggestion. We will try 2). Closing this since this is not related to Arcade.

Was this page helpful?
0 / 5 - 0 ratings