0

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

Joe
  • 5,394
  • 3
  • 23
  • 54
  • You can without .nuspec, just edit the .csproj file, see here: https://stackoverflow.com/a/64209711/7409220 – Shayki Abramczyk May 04 '21 at 07:53
  • Hi Leo, I have been working on this today to try to determine if any of these kind answers will help me. Unfortunately my boss keeps pulling me off on to different tasks (All Zoom meetings today) so I have not had time to explore these answers. I will post back here as soon as I have something – Joe May 06 '21 at 03:21
  • @Joe, How about the issue? Does the answer below resolved your question, If not, would you please let me know the latest information about this issue? – Leo Liu May 14 '21 at 07:47

1 Answers1

0

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>
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I've gone back over this a few times. I've been able to make this work without the .NUSPEC or the added MSBuild `ItemGroup` listed here. Instread I set the MSBuild setting `GeneratePackageOnBuild` to `true` and `GenerateAssemblyInfo` to `false` (with necessary attributes in an AssemblyInfo.cs file) Now the resources.dll is included. I will freely admit I do not know why this works. – Joe May 17 '21 at 20:38