I am using Azure DevOps to build and package a .NET csproj with multiple project references. While the MSBuild task successfully compiles the csproj and includes all referenced projects in the bin\Release directory, the subsequent pack task does not include these referenced projects in the final NuGet package.
What works:
The msbuild command compiles the solution correctly, and the output in bin\Release contains all the necessary DLLs from the project references.
What doesn't work:
The NuGetCommand@2 command with the Pack target does not include all the necessary project references in the resulting NuGet package. Instead, only the output of the primary project is included.
What I've tried:
Using IncludeReferencedProjects=true with the Pack target, which should theoretically include the referenced projects in the NuGet package.Inspecting the csproj files to ensure all project references are correct includint their paths.Various configurations of the MSBuild task in Azure DevOps pipelines, including inline PowerShell scripts and YAML task definitions.
What I need:
I need the Pack target of the NuGetCommand@2 task to include the DLLs from the project references just as it appears in the bin\Release folder after a build.
Any insights or solutions to ensure that all referenced projects are included in the NuGet package when using Azure DevOps would be greatly appreciated.
- task: NuGetCommand@2 inputs: restoreSolution: '$(MainCsprojFile)' displayName: 'Restore NuGet Packages' - task: MSBuild@1 inputs: solution: '$(MainCsprojFile)' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' displayName: 'Build with MSBuild' - task: NuGetCommand@2 displayName: 'Pack NuGet package' inputs: command: 'pack' packagesToPack: '$(MainCsprojFile)' versioningScheme: 'off' versionEnvVar: 'PackageVersion' includeReferencedProjects: true outputDir: '$(Build.ArtifactStagingDirectory)'