admin管理员组

文章数量:1335414

This is in ADO pipeline, but I can't get it to work properly locally either.

I am using dotnet pack to create a nuget package from a .csproj file (that builds several dependent DLLs). If I include symbols (IncludeSymbols in csproj), I get all .pdbs in nuget (.nupkg) and in the symbols (.snupkg). I don't want them in the nupkg so I use this in the csproj: <Content Include="..\host\bin\Release\net8.0\*.dll" Pack="true" PackagePath="lib\net8.0" />

That keeps the pdbs out of the nuget (good!) but only the .csproj pdb is in the .snupkg. It does NOT have all the pdbs from the dependencies in the .snupkg file (bad!).

I have tried setting this property in csproj: SuppressDependenciesWhenPacking to false and it didn't seem to do anything.

I have set DebugType property in csproj to "portable" and this didn't seem to do anything.

This does not work either: <Content Include="..\host\bin\Release\net8.0\*.pdb" Pack="true" PackagePath="lib\net8.0" ExcludeFromPackage="true" />

Using this: Content Include="..\host\bin\Release\net8.0\*" Pack="true" PackagePath="lib\net8.0" includes all files including .pdbs

It seems either I need to accept all pdbs in both nupkg and snupkg or just have the .csproj pdb that dotnet pack is building in the snupkg (with no pdbs for the dependent DLLs). It doesn't seem possible to have none in nupkg but all in snupkg.

This is in ADO pipeline, but I can't get it to work properly locally either.

I am using dotnet pack to create a nuget package from a .csproj file (that builds several dependent DLLs). If I include symbols (IncludeSymbols in csproj), I get all .pdbs in nuget (.nupkg) and in the symbols (.snupkg). I don't want them in the nupkg so I use this in the csproj: <Content Include="..\host\bin\Release\net8.0\*.dll" Pack="true" PackagePath="lib\net8.0" />

That keeps the pdbs out of the nuget (good!) but only the .csproj pdb is in the .snupkg. It does NOT have all the pdbs from the dependencies in the .snupkg file (bad!).

I have tried setting this property in csproj: SuppressDependenciesWhenPacking to false and it didn't seem to do anything.

I have set DebugType property in csproj to "portable" and this didn't seem to do anything.

This does not work either: <Content Include="..\host\bin\Release\net8.0\*.pdb" Pack="true" PackagePath="lib\net8.0" ExcludeFromPackage="true" />

Using this: Content Include="..\host\bin\Release\net8.0\*" Pack="true" PackagePath="lib\net8.0" includes all files including .pdbs

It seems either I need to accept all pdbs in both nupkg and snupkg or just have the .csproj pdb that dotnet pack is building in the snupkg (with no pdbs for the dependent DLLs). It doesn't seem possible to have none in nupkg but all in snupkg.

Share Improve this question asked Nov 20, 2024 at 2:10 Darren GDarren G 658 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 0

Based on your description, you need to include dlls in the .nupkg package and all.pdbs (including dependents) in snupkg file.

To meet your requirement, you can try to use .nuspec file to define the list of files to be packaged.

Here is an example:

.nuspec file sample:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>MultiLib.Project</id>
    <version>1.1.2</version>
    <title>MultiLibrary Project</title>
    <authors>Project Authors</authors>
    <owners>Project Owners</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>A sample project with dependencies</description>
    <dependencies />
  </metadata>
  <files>
    <file src="bin\release\net8.0\*.dll" target="lib\net8.0" />
    <file src="bin\release\net8.0\*.pdb" target="lib\net8.0" />
  </files>
</package>

For.csproj file, we need to add <IncludeSymbols>true</IncludeSymbols> and <SymbolPackageFormat>snupkg</SymbolPackageFormat>

Here is an example:

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

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Authors>Project authors</Authors>
    <Company>Project company</Company>
    <Product>Project product</Product>
    <Description>A sample project with dependencies</Description>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
    <Version>1.2.0</Version>
  </PropertyGroup>
 
  <ItemGroup>
    <ProjectReference Include="..\MultiLib.Dependency1\MultiLib.Dependency1.csproj" />
    <ProjectReference Include="..\MultiLib.Dependency2\MultiLib.Dependency2.csproj" />
  </ItemGroup>

</Project>

Pipeline sample: we can add -p:NuspecFile=xx.nuspec in dotnet pack argument

steps:
- task: DotNetCoreCLI@2
  displayName: Pack
  inputs:
    command: custom
    projects: MultiLib.Project/MultiLib.Project.csproj
    custom: pack
    arguments: '--configuration $(BuildConfiguration) -p:NuspecFile=xx.nuspec --output $(build.artifactstagingdirectory)'


- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

Result:

Files in .snupkg package:

Files in .nupkg package:

We ended up using embedded symbols (in the DLL). It was quite an ordeal trying to get it working with all dependencies etc but we finally got it working.

Project: https://github/microsoft/garnet Garnet Server that built into nuget: https://github/microsoft/garnet/blob/main/main/GarnetServer/GarnetServer.csproj Garnet Lib project: https://github/microsoft/garnet/blob/main/libs/host/Garnet.host.csproj

Nuget Packages: Server: https://www.nuget./packages/garnet-server Lib: https://www.nuget./packages/Microsoft.Garnet

本文标签: