NuKeeperDotNet / NuKeeper-AzureDevops-extension

NuKeeper AzureDevops and VSTS extension
12 stars 15 forks source link

Azure Pipeline task does not report an error when nukeeper fails. #53

Closed ghelyar closed 4 years ago

ghelyar commented 4 years ago

Here's a simple repro with the nukeeper CLI (tested on 0.28.0)

dotnet new console
dotnet add package SpecFlow.NUnit -v 3.1.82
dotnet add package SpecFlow.Tools.MsBuild.Generation -v 3.1.82
nukeeper update -m 100
echo %errorlevel%

Note that both of these packages have exact version constraints on a 3rd package, SpecFlow, which is what causes the error, because both packages have to be updated at the same time for it to be in a valid state. It would be nice if it didn't cause that error, but that's not what this issue is about.

Here is the log from the command line:

C:\nukeeper-test>nukeeper update -m 100
Found 2 packages
Found 2 packages in use, 2 distinct, in 1 projects.
SpecFlow.NUnit, SpecFlow.Tools.MsBuild.Generation
Found 2 possible updates
SpecFlow.NUnit from 3.1.82 to 3.1.97 in nukeeper-test.csproj
SpecFlow.Tools.MsBuild.Generation from 3.1.82 to 3.1.97 in nukeeper-test.csproj

Found 2 package updates
SpecFlow.NUnit to 3.1.97 from 3.1.82 in 1 place since 27 days ago.
SpecFlow.Tools.MsBuild.Generation to 3.1.97 from 3.1.82 in 1 place since 27 days ago.
Selection of package updates: 2 candidates
Updating SpecFlow.NUnit to 3.1.97 from 3.1.82 in 1 place since 27 days ago.
Updating SpecFlow.Tools.MsBuild.Generation to 3.1.97 from 3.1.82 in 1 place since 27 days ago.
NuKeeper.Abstractions.NuKeeperException: Command dotnet failed with exit code: 1

C:\nukeeper-test\nukeeper-test.csproj : error NU1107: Version conflict detected for SpecFlow. Install/reference SpecFlow 3.1.97 directly to project nukeeper-test to resolve this issue.
C:\nukeeper-test\nukeeper-test.csproj : error NU1107:  nukeeper-test -> SpecFlow.NUnit 3.1.97 -> SpecFlow (= 3.1.97)
C:\nukeeper-test\nukeeper-test.csproj : error NU1107:  nukeeper-test -> SpecFlow.Tools.MsBuild.Generation 3.1.82 -> SpecFlow (= 3.1.82).
  Restore failed in 336.76 ms for C:\nukeeper-test\nukeeper-test.csproj.

   at NuKeeper.Update.ProcessRunner.ExternalProcess.Run(String workingDirectory, String command, String arguments, Boolean ensureSuccess) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Update\ProcessRunner\ExternalProcess.cs:line 63
   at NuKeeper.Update.Process.DotNetUpdatePackageCommand.Invoke(PackageInProject currentPackage, NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Update\Process\DotNetUpdatePackageCommand.cs:line 30
   at NuKeeper.Update.UpdateRunner.Update(PackageUpdateSet updateSet, NuGetSources sources) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Update\UpdateRunner.cs:line 52
   at NuKeeper.Local.LocalUpdater.ApplyUpdates(IReadOnlyCollection`1 updates, IFolder workingFolder, NuGetSources sources) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Local\LocalUpdater.cs:line 66
   at NuKeeper.Local.LocalUpdater.ApplyUpdates(IReadOnlyCollection`1 updates, IFolder workingFolder, NuGetSources sources, SettingsContainer settings) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Local\LocalUpdater.cs:line 55
   at NuKeeper.Local.LocalEngine.Run(SettingsContainer settings, Boolean write) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Local\LocalEngine.cs:line 69
   at NuKeeper.Commands.UpdateCommand.Run(SettingsContainer settings) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Commands\UpdateCommand.cs:line 52
   at NuKeeper.Commands.CommandBase.OnExecute() in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Commands\CommandBase.cs:line 108
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at NuKeeper.Program.Main(String[] args) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Program.cs:line 34

C:\nukeeper-test>echo %errorlevel%
1

This returns an exit code of 1, but the pipeline task seems to ignore it, and reports success. Here is the log from the pipeline:

...
2020-05-14T00:07:36.1035201Z Updates failed NuKeeperException : Command dotnet failed with exit code: 1
2020-05-14T00:07:36.1036025Z 
2020-05-14T00:07:36.1047848Z D:\a\1\s\Tests\Tests.csproj : error NU1107: Version conflict detected for SpecFlow. Install/reference SpecFlow 3.1.97 directly to project Tests to resolve this issue. 
2020-05-14T00:07:36.1057285Z D:\a\1\s\Tests\Tests.csproj : error NU1107:  Tests -> SpecFlow.NUnit 3.1.97 -> SpecFlow (= 3.1.97) 
2020-05-14T00:07:36.1059714Z D:\a\1\s\Tests\Tests.csproj : error NU1107:  Tests -> SpecFlow.Tools.MsBuild.Generation 3.1.82 -> SpecFlow (= 3.1.82).
2020-05-14T00:07:36.1061702Z   Restore failed in 766.16 ms for D:\a\1\s\Tests\Tests.csproj.
2020-05-14T00:07:36.1064086Z 
2020-05-14T00:07:36.1077165Z 
2020-05-14T00:07:36.1080982Z 
2020-05-14T00:07:36.1081862Z Attempted 14 updates and did 0
2020-05-14T00:07:36.1510678Z ##[section]Finishing: NuKeeper

The expected behaviour is that the pipeline task should have reported failure. You shouldn't have to look in the logs to realise it hasn't worked.

MarcBruins commented 4 years ago

Agreed, should be fixed in 0.4.40