-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packing with ContinuePackingAfterGeneratingNuspec=false should not fail when there are no errors #9786
Comments
Hi @aggieben, I tried the following steps to repro, but failed:
I also tried to install dotnet SDK 3.1.400, but the result is the same as above. Can you pls provide the repro steps if the above is not accurate? Thanks! |
Same thing here, using SDK 3.1.401 to build FSharp.Formatting. No problem when forcing 3.1.302 through |
Also been reported to Paket: fsprojects/Paket#3897 |
This appears to be because if ContinuePackingAfterGeneratingNuspec task parameter to PackTask is set false, PackCommandRunner.BuildPackage will return null (as there is no package built, as GenerateNugetPackage is false). This in turn means that PackCommandRunner.RunPackageBuild returns false, which is treated by PackTask.Execute as failure. Not generating a package when the generation of a package is not requested should not be considered failure. |
This has completely killed any project that uses Paket from updating to newer SDKs, or even participating in testing the 5.x previews. Paket calls the Pack Task twice:
|
@heng-liu previously attempted to reproduce the problem, but was unable to, as she got a different error. Can someone provide us with a simple repro? |
The linked paket issue contains a zip of a project that triggers this, along with reproduction steps. |
I think she didn't do |
I'm taking a quick look, but it seems I need to use the paket and fake CLIs, both products that the NuGet team doesn't support, so first I have to figure out how these tools are using NuGet. If someone has a repro that minimises usage of 3rd party tools, that could speed up our investigation. edit: never mind. I just noticed that the issue reporter said that running |
@zivkan the entire point is the usage of third-party tools :) The way the targets delegated to the PackTask relies on an invariant that has changed between 3.1.30x and 3.1.40x, and the contention is that this invariant change is a bug. The core question is: should not making a nuget package when the user explicitly requested that behavior cause a failing build? |
3rd party tools still invoke NuGet somehow. If someone can peel away those layers and report just the NuGet command that fails, I can investigate that. Otherwise, I have to spend time learning a new tool before I can even begin investigating the reported problem. If the problem is how the 3rd party tools use NuGet, I don't know how to write this without sounding like a jerk, but it's out of my job description. Anyway, I've figured out how to invoke NuGet in a way that reports the error. Debugging the .NET SDK is not easy and requires setup, but I'll take a quick look to see if I spot something obvious. |
The problem is an unintended consequence from fixing #7404 (when a pack warning is elevated to error via WarnAsError, NuGet was not telling MSBuild there was an error, even though it logged errors). It looks the implementation was to: delete the zip file on error, and report to MSBuild whether the zip file exists. This doesn't take into account |
Nice investigation work! Thanks for narrowing down the root cause. |
I expect the fix will be available in NuGet 5.8 and the .NET 5 SDK (rc2 maybe. I'm not sure if there's time for us to make rc1 still) |
Are there any workarounds in the meantime? I.e. any other way to produce a |
I've been editing my .paket\packet.restore.targets file and commenting out the |
Nice, that works, thanks @AlexVallat ! |
Yep, this was it. Sorry - I forgot about this issue. The repro would need:
Hopefullly I didn't leave out a step this time 😬 |
Could this issue result in a i.e. if I used the workaround of commenting out the |
I can confirm this goes away with net5-rc2. |
Just had a fun day dealing with this in .NET Core 3.1.407 while trying to address CVE-2021-26701. The workaround @AlexVallat suggested was very helpful, but I found that <Target Name="PaketDisableDirectPack" AfterTargets="_IntermediatePack" BeforeTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" >
</Target> Is there any chance of this being fixed in .NET Core 3.1? |
Something similar to set the <!-- Workaround for https://github.com/NuGet/Home/issues/9786 -->
<Target Name="PaketDisableDirectPackWorkaround" AfterTargets="PaketDisableDirectPack">
<PropertyGroup>
<ContinuePackingAfterGeneratingNuspec>true</ContinuePackingAfterGeneratingNuspec>
</PropertyGroup>
</Target> so paket install doesnt override it |
Issue moved from dotnet/sdk#12292
From @aggieben on Tuesday, June 30, 2020 7:41:03 PM
Using the 5.0.0-preview.5.20279.10 SDK on Windows 10, the tooling fails to pack a nupkg for the project located here: https://github.com/aggieben/ConstrainedTypes (
master
branch).I used the following command:
dotnet pack -o pkg ConstrainedTypes.fsproj -v diag
. The error message reported is:The exact same command works just fine with SDK version 3.1.300.
The text was updated successfully, but these errors were encountered: