I have the following issue:
I am running dotnet pack --no-build -c Release .\Client.csproj
and am getting error NU5026: The file 'Client\bin\ Release\net7.0\Client.dll' to be packed was not found on disk
However, when I don't pass a csproj, it works:
Successfully created package 'Client\bin\x64\Release\Client.1.0.0.nupkg'
It seems the packing command is struggling to identify the output path (x64 is missing).
The csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net7.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><OutputType>Library</OutputType><IsPackable>true</IsPackable><Platforms>AnyCPU;x64</Platforms><PlatformTarget>x64</PlatformTarget><StaticWebAssetsEnabled>false</StaticWebAssetsEnabled><!-- tried this trick, didn't work--><!--Platform Condition=" '$(Platform)' == ''">x64</Platform--></PropertyGroup></Project>
and an excerpt of the sln file:
Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {ED0EAE71-53F9-4C7B-BD5A-02B960CAFD5E}.Debug|x64.ActiveCfg = Debug|x64 {ED0EAE71-53F9-4C7B-BD5A-02B960CAFD5E}.Debug|x64.Build.0 = Debug|x64 {ED0EAE71-53F9-4C7B-BD5A-02B960CAFD5E}.Release|x64.ActiveCfg = Release|x64 {ED0EAE71-53F9-4C7B-BD5A-02B960CAFD5E}.Release|x64.Build.0 = Release|x64 {A4B1F3EA-12B9-4F54-B1C2-CE0401DC0335}.Debug|x64.ActiveCfg = Debug|x64 {A4B1F3EA-12B9-4F54-B1C2-CE0401DC0335}.Debug|x64.Build.0 = Debug|x64 {A4B1F3EA-12B9-4F54-B1C2-CE0401DC0335}.Release|x64.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1251856A-31D8-4464-A039-62134CBC30FF} EndGlobalSectionEndGlobal
I know the following solutions would work, but can't rely on them:
- building during packing (removing
--no-build
), because we do build in 2 steps so that we don't pack systematically (in local for example), and so we can version packed artifacts in AzureDevOps - packing during building (with
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
), same reason - not specifying a csproj in the packing command: as we don't want to pack every project, but just a subset of them
- use Debug configuration, I can't as the Release configuration is the one excluding unit tests and the likes