Pipeline NuGet task won't publish resource DLL. Do I need a NUSPEC file?

I have a tiny .NET 5.0 C# project ("MyComponent") that builds in Azure DevOps YAML pipelines and publishes a NuGet package to an internal feed. It has English strings and French strings so it generates two outputs: MyComponent.dll and MyComponent.resources.dll

\net5.0-windows
    |
    |-- MyComponent.dll
    |
    \fr
        |
        |-- MyComponent.resources.dll

My other projects do pull it from the internal feed and use it. Unfortunately when they pull it, the resources DLL does NOT get pulled to the client's build tree. Only MyComponent.dll is pulled. So I guess it's not getting published properly.

This is the entire publish task

- task: NuGetCommand@2
  displayName: 'Pack NuGet Package'
  inputs:
    command: 'pack'
    verbosityPack: Detailed
    packagesToPack: '**/MyComponent.csproj'
    configuration: 'x64\Release'
    versioningScheme: byBuildNumber
    includeSymbols: true

How do I make this thing also publish the resources dll in the "fr" subdirectory?

Is there some syntax option on this command task that I am missing? The docs list so many options, I'm lost. Do I need to write a .NUSPEC file?

-Joe

1 answer

  • answered 2021-05-04 08:19 Leo Liu-MSFT

    Pipeline NuGet task won't publish resource DLL. Do I need a NUSPEC file?

    This is a matter of taste selection.

    You could edit the .csproj file to include the resource file(s) directly, like Shayki comment:

      <ItemGroup>
        <Content Include="resource\**\ClassLibrary2.resources.dll">
            <Pack>true</Pack>
            <PackagePath>lib\net5.0\</PackagePath>
        </Content>
      </ItemGroup>
    

    The ** contains all localized folders.

    And we could also to create a NUSPEC file to explicitly add the resource file.

    <files>
        <file src="bin\Debug\en\MyAssembly.resource.dll" target="lib\net40\en\MyAssembly.resource.dll" />
        <file src="bin\Debug\es\MyAssembly.resource.dll" target="lib\net40\es\MyAssembly.resource.dll" />
    </files>