Create localized Nuget Package from project with "pack" in Visual studio 2022

Norman 21 Reputation points
2022-09-23T07:52:01.45+00:00

Hello,
I have a "resources" dll with german texts.

My goal is to create a nuget package, via visual studio, containing this satellite dll.

Here is in short how I'm trying to achieve it:
This is my csproj.
There I defined a <PackagePath> for the resource .dll according to the structure of creating-localized-packages

<Project Sdk="Microsoft.NET.Sdk">     
  <PropertyGroup>  
    <TargetFramework>net5.0-windows</TargetFramework>  
    <Nullable>enable</Nullable>  
  </PropertyGroup>      
  <ItemGroup>  
    <PackageReference Include="DevExpress.Wpf.Grid.Core" Version="21.1.10" />  
  </ItemGroup>      
  <ItemGroup>  
		<Content Include="lib\DevExpress.Xpf.Grid.v21.1.Core.resources.dll">  
			<Pack>true</Pack>  
			<PackagePath>lib\net5.0-windows7\de</PackagePath>  
		</Content>  
	</ItemGroup>  
</Project>  

I Create a nuget package with vs 244213-image.png

But if i install the nuget package in the project which shall use it.
the "net5.0-windows7\de" folder is not created there!

What am i missing here?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,456 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,497 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 27,801 Reputation points Microsoft Vendor
    2022-09-26T07:24:03.9+00:00

    Hi @Norman ,

    Welcome to Microsoft Q&A forum.

    This xml code: <PackagePath>lib\net5.0-windows7\de</PackagePath> is used to put(package) this DevExpress.Xpf.Grid.v21.1.Core.resources.dll file into this lib\net5.0-windows7\de directory. But this directory is included in .nupkg file(more specific, if you rename the generated .nupkg file to .zip file, you will see this directory in .zip file. XXXX.zip\lib\net5.0-windows7\de\DevExpress.Xpf.Grid.v21.1.Core.resources.dll).

    Based on my test, if you don't use Visual Studio's Pack feature, instead using nuget.exe command line to generate the .nuspec file and adding following similar xml codes(they do mostly the same things as the <PackagePath> codes) into the .nuspec file. After that using nuget.exe pack XXXX.nuspec to package the project, the .resources.dll file will be copied into your output folder, after you install this nuget to another project and build the project. But the .resources.dll file will still not be copied to any folder right after you installing this nuget package.

    <files>  
        <file src="XXXX\XXXX\XXXXX.resources.dll" target="XXXX\XXXX" />  
    </files>  
    

    As .NET Core/.NET projects use link properties to reference the files, some files which are included in nuget package will not be copied to any folder(your project folder) automatically during the installing of nuget package.

    There are some ways to copy them after the nuget package has been installed, you can firstly check if above method has solved your issue, and then considering whether you want to force to copy the .resources.dll file to the lib folder.

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful