NETSDK1085 when packing with `--no-build`

See original GitHub issue

When packing an F# project that depends on another project via ProjectReference a spurious Build is triggered on the base project. This triggers the SDK error NETSDK1085. It doesn’t seem to matter if the project being referenced is an .fsproj or .csproj. In both cases the preojct being referenced will be re-built and trigger the error. Executables being packed as tools don’t seem to trigger this behaviour.

dotnet new classlib --language F# --name eff -o eff
dotnet new classlib --language F# --name gee -o gee
dotnet add gee/gee.fsproj reference eff/eff.fsproj
dotnet build gee/gee.fsproj && dotnet pack gee/gee.fsproj --no-build

Expected behavior

The project should produce a NuGet package with no errors

Actual behavior

The error NETSDK1085 is reported:

/usr/lib64/dotnet/sdk/5.0.206/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(146,5): error NETSDK1085: The 'NoBuild' property was set to true but the 'Build' target was invoked. [/testing/Gee.fsproj]

Known workarounds

Don’t provide the --no-build flag when packing.

Related information

  • Operating system: Fedora Linux 34
  • .NET Runtime kind .NET 5 (SDK 5.0.206)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
scottrudycommented, Jan 6, 2022

Confirming this same issue for C# and a csproj file that references another project via project reference. I am running this with .NET 6.0 SDK in Azure DevOps using a DotNetCoreCLI@2 task and noticed the same behavior. Removing nobuild: true from the inputs will work around the issue. The error from the log looks like the following

2:5>Done building target "ValidateCommandLineProperties" in project "XXX.XXX.csproj".
2:5>Target "BeforeBuild" in file "/opt/hostedtoolcache/dotnet/sdk/6.0.101/Microsoft.Common.CurrentVersion.targets" from project "/home/vsts/work/1/s/Utilities/XXX.XXX/XXX.XXX.csproj" (target "Build" depends on it):
2:5>Done building target "BeforeBuild" in project "XXX.XXX.csproj".
2:5>Target "_CheckForBuildWithNoBuild" in file "/opt/hostedtoolcache/dotnet/sdk/6.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets" from project "/home/vsts/work/1/s/Utilities/XXX.XXX/XXX.XXX.csproj" (target "CoreBuild" depends on it):
       Using "NETSdkError" task from assembly "/opt/hostedtoolcache/dotnet/sdk/6.0.101/Sdks/Microsoft.NET.Sdk/targets/../tools/net6.0/Microsoft.NET.Build.Tasks.dll".
       Task "NETSdkError"
2:5>/opt/hostedtoolcache/dotnet/sdk/6.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(136,5): error NETSDK1085: The 'NoBuild' property was set to true but the 'Build' target was invoked. [/home/vsts/work/1/s/Utilities/XXX.XXX/XXX.XXX.csproj]
       Done executing task "NETSdkError" -- FAILED.
2:5>Done building target "_CheckForBuildWithNoBuild" in project "XXX.XXX.csproj" -- FAILED.
1reaction
iwillspeakcommented, Mar 5, 2022

I was able to work around the issue by adding /p:TargetsForTfmSpecificContentInPackage= to the build command to prevent PackageFSharpDesignTimeTools from being run. The package seems to contain the same as if dotnet pack is run without --no-build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net core - Prevent `dotnet pack --no-build` from triggering a ...
Sdk.targets(133,5): error NETSDK1085: The 'NoBuild' property was set to true but the ... Pack all projects of the solution to NuGet packages.
Read more >
Include both Nuget Package References and project ...
using dotnet pack to geneate a nuget package with project ... Sdk.targets(143,5): error NETSDK1085: The 'NoBuild' property was set to true ...
Read more >
How to create asp.net webpublish package without ...
I'm trying to separate the build and packaging steps to sign the dll's before published. ... error NETSDK1085 : The 'NoBuild' property was...
Read more >
NET SDK error list - .NET CLI
Run a NuGet package restore to generate this file. ... NETSDK1085, The 'NoBuild' property was set to true but the 'Build' target was...
Read more >
dotnet pack passing the directory does not work
So, I want ot orun pack without a new build. The documentation for dotnet pack says:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found