Skip to content
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

MSBuild Task doesn't fail the build on build failure in Hosted VS2019 #11958

Closed
blueelvis opened this issue Dec 12, 2019 · 7 comments
Closed

Comments

@blueelvis
Copy link

blueelvis commented Dec 12, 2019

Note

Issues in this repo are for tracking bugs, feature requests and questions for the tasks in this repo

For a list:
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

If you have an issue or request for the Azure Pipelines service, use developer community instead:

https://developercommunity.visualstudio.com/spaces/21/index.html )

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name:
MSBUILD V1

Environment

  • Server - Azure Pipelines

  • Agent - Hosted (Windows 2019 with VS 2019)

Issue Description

We have a SQL Server project to build. I have set an additional argument in the MSbuild task - /WarnasError. Now, this works properly and fails the entire build when using the task with Windows 2016 VS 2017 Hosted agent but this doesn't fail the build when the Hosted agent is set to `Windows 2019 VS 2019) while still using the exact same task definition. -
image

Task logs

Please let me know if there is a way to send the logs privately.

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Error logs

image

[Insert error from the logs here for a quick overview]


2019-12-11T13:44:32.3384320Z          Loading project files...
2019-12-11T13:44:48.2977396Z          Building the project model and resolving object interdependencies...
2019-12-11T13:45:06.0867913Z          Validating the project model...
2019-12-11T13:45:13.2337102Z          Writing model to D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\obj\Release\Model.xml...
2019-12-11T13:45:19.3486039Z ##[error]AAA.CP\10.Databases\AAA.CP.DB.BBB\Data\StoredProcedures\usp_Api_Upsert.sql(1,1): Error SQL71558: The object reference [Data].[Requirement].[EffectiveStartDateTime] differs only by case from the object definition [Data].[Requirement].[EffectiveStartDatetime].
2019-12-11T13:45:19.3496632Z      1>D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\Data\StoredProcedures\usp_Api_Upsert.sql(1,1,1,1): Build error SQL71558: The object reference [Data].[Requirement].[EffectiveStartDateTime] differs only by case from the object definition [Data].[Requirement].[EffectiveStartDatetime]. [D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\AAA.CP.DB.BBB.sqlproj]
2019-12-11T13:45:20.0617689Z        _CopyFilesMarkedCopyLocal:
2019-12-11T13:45:20.0618201Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\Hello.BBBPAC" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\Hello.BBBPAC".
2019-12-11T13:45:20.0722274Z          Creating "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\obj\Release\AAA.CP.DB.BBB.sqlproj.CopyComplete" because "AlwaysCreate" was specified.
2019-12-11T13:45:20.1232473Z        _CopyOutOfDateSourceItemsToOutputDirectoryAlways:
2019-12-11T13:45:20.1239016Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\Hello.BBBPAC" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\Hello.BBBPAC".
2019-12-11T13:45:20.1241881Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\appsettings.Dev.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\appsettings.Dev.json".
2019-12-11T13:45:20.1244446Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\appsettings.Production.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\appsettings.Production.json".
2019-12-11T13:45:20.1247035Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\appsettings.Qa.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\appsettings.Qa.json".
2019-12-11T13:45:20.1249537Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\New-SqlDatabase.Parameters.Dev.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\New-SqlDatabase.Parameters.Dev.json".
2019-12-11T13:45:20.1252161Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\New-SqlDatabase.Parameters.Qa.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\New-SqlDatabase.Parameters.Qa.json".
2019-12-11T13:45:20.1254963Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\New-SqlDatabase.Parameters.Production.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\New-SqlDatabase.Parameters.Production.json".
2019-12-11T13:45:20.1328821Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\appsettings.Uat.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\appsettings.Uat.json".
2019-12-11T13:45:20.1332300Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\New-SqlDatabase.Parameters.Uat.json" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\New-SqlDatabase.Parameters.Uat.json".
2019-12-11T13:45:20.1335015Z        CopyFilesToOutputDirectory:
2019-12-11T13:45:20.1338481Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\obj\Release\AAA.CP.DB.HelloData.dll" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\AAA.CP.DB.HelloData.dll".
2019-12-11T13:45:20.1341489Z          AAA.CP.DB.BBB -> D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\AAA.CP.DB.HelloData.dll
2019-12-11T13:45:20.1344127Z          Copying file from "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\obj\Release\AAA.CP.DB.HelloData.pdb" to "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\AAA.CP.DB.HelloData.pdb".
2019-12-11T13:45:20.1346647Z        SqlPrepareForRun:
2019-12-11T13:45:20.1349184Z          AAA.CP.DB.BBB -> D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\bin\Release\AAA.CP.DB.BBB.BBBpac
2019-12-11T13:45:20.1353079Z      1>Done Building Project "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\AAA.CP.DB.BBB.sqlproj" (default targets).
2019-12-11T13:45:20.1355701Z 
2019-12-11T13:45:20.1357336Z Build FAILED.
2019-12-11T13:45:20.1494657Z 
2019-12-11T13:45:20.1502484Z        "D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\AAA.CP.DB.BBB.sqlproj" (default target) (1) ->
2019-12-11T13:45:20.1502798Z        (SqlBuild target) -> 
2019-12-11T13:45:20.1503000Z          D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\Data\StoredProcedures\usp_Api_Upsert.sql(1,1,1,1): Build error SQL71558: The object reference [HelloData].[Requirement].[EffectiveStartDateTime] differs only by case from the object definition [Data].[Requirement].[EffectiveStartDatetime]. [D:\a\1\s\AAA.CP\10.Databases\AAA.CP.DB.BBB\AAA.CP.DB.BBB.sqlproj]
2019-12-11T13:45:20.1503467Z 
2019-12-11T13:45:20.1503632Z     0 Warning(s)
2019-12-11T13:45:20.1503809Z     1 Error(s)
2019-12-11T13:45:20.1503944Z 
2019-12-11T13:45:20.1504089Z Time Elapsed 00:01:00.07
2019-12-11T13:45:20.2488187Z ##[section]Finishing: Build All SQL Projects

@davekenn
Copy link
Contributor

@wireznak could you please help out here? Thanks!

@wireznak
Copy link
Contributor

There are two things I'd like to look into from your end, @blueelvis .

  1. In your pipeline definition, please check that "Continue on error" is not checked for the steps in question. Since this was previously working, I suspect that it was and still is unchecked, but it never hurts to make sure.
  2. Please try checking the box that says "Enable system diagnostics" when running the pipeline, as shown below. This will add more diagnostic logging, including the return code from each process run. It is important for us to know what the return code from SQLBuild is.
    image

@maboivin
Copy link

maboivin commented Jul 27, 2020

@wireznak I'm trying an experiment with our build pipelines. During development, code analysis and stylecop warnings may occur but we don't want them when our checks run on a pull request that is to be merged into the master branch. I'm also using the MSBuild task 1.*. I tried to send /WarnAsError as the MSBuild arguments and while it fails on my dev machine, it succeeds on the hosted build agent.

I have verified and "Continue on error" is not checked.

I have also enabled diagnostics when running the pipeline and here's part of the log:

2020-07-27T19:21:56.4947826Z ##[debug]VstsTaskSdk 0.8.2 commit 
2020-07-27T19:21:57.9587183Z ##[debug]Entering D:\agent\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\MSBuild.ps1.
2020-07-27T19:21:57.9588588Z ##[debug]Loading resource strings from: D:\agent\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\Task.json
2020-07-27T19:21:57.9589667Z ##[debug]Loaded 3 strings.
2020-07-27T19:21:57.9590320Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-07-27T19:21:57.9591228Z ##[debug]Loading resource strings from: D:\agent\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\Strings\resources.resjson\en-US\resources.resjson
2020-07-27T19:21:57.9592081Z ##[debug]Loaded 3 strings.
2020-07-27T19:21:57.9592511Z ##[debug]SYSTEM_DEBUG: 'true'
2020-07-27T19:21:57.9592934Z ##[debug] Converted to bool: True
2020-07-27T19:21:57.9593373Z ##[debug]INPUT_MSBUILDLOCATIONMETHOD: 'version'
2020-07-27T19:21:57.9593824Z ##[debug]INPUT_MSBUILDLOCATION (empty)
2020-07-27T19:21:57.9594259Z ##[debug]INPUT_MSBUILDARGUMENTS: '/WarnAsError'
2020-07-27T19:21:57.9594819Z ##[debug]INPUT_SOLUTION: 'D:\agent\_work\25\s\***.sln'
2020-07-27T19:21:57.9595319Z ##[debug]INPUT_PLATFORM: 'any cpu'
2020-07-27T19:21:57.9595791Z ##[debug]INPUT_CONFIGURATION: 'Debug'
2020-07-27T19:21:57.9596231Z ##[debug]INPUT_CLEAN: 'false'

Then, a build error occurs which would normally be a warning:

2020-07-27T19:22:29.8792556Z ##[debug]Processed: ##vso[task.logdetail id=7ff5d48c-3eaf-4eb1-aea5-bcdd2a5a6e99;parentid=;name=src\***.cs;type=Build;starttime=2020-07-27T19:22:29.8644382Z;state=InProgress;]
2020-07-27T19:22:29.8844003Z ##[error]src\***.cs(591,46): Error CA5394: Random is an insecure random number generator. Use cryptographically secure random number generators when randomness is required for security
2020-07-27T19:22:29.8907374Z ##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=D:\agent\_work\25\s\src\***.cs;linenumber=591;columnnumber=46;code=CA5394;]Random is an insecure random number generator. Use cryptographically secure random number generators when randomness is required for security
2020-07-27T19:22:29.8910191Z ##[debug]Processed: ##vso[task.logdetail id=7ff5d48c-3eaf-4eb1-aea5-bcdd2a5a6e99;parentid=;type=Build;result=Failed;finishtime=2020-07-27T19:22:29.8644382Z;progress=100;state=Completed;parentid=;name=;]
2020-07-27T19:22:29.8911366Z ***.cs(591,46): error CA5394: Random is an insecure random number generator. Use cryptographically secure random number generators when randomness is required for security [D:\agent\_work\25\s\src\***.csproj]

Then the build should fail because 8 warnings were converted to 8 errors:

2020-07-27T19:29:29.7875868Z 
2020-07-27T19:29:29.7884556Z     0 Warning(s)
2020-07-27T19:29:29.7885168Z     8 Error(s)
2020-07-27T19:29:29.7885432Z 
2020-07-27T19:29:29.7885772Z Time Elapsed 00:07:31.19

But the MSBuild task succeeds:

2020-07-27T19:29:29.8965220Z ##[debug]Exit code: 0
2020-07-27T19:29:29.8979360Z ##[debug]Leaving Invoke-VstsTool.
2020-07-27T19:29:29.9013145Z ##[debug]Processed: ##vso[task.uploadfile]D:\agent\_work\25\s\***.sln.log
2020-07-27T19:29:29.9035508Z ##[debug]Leaving Invoke-MSBuild.
2020-07-27T19:29:29.9081153Z ##[debug]Leaving Invoke-BuildTools.
2020-07-27T19:29:29.9085516Z ##[debug]Leaving D:\agent\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\MSBuild.ps1.
2020-07-27T19:29:29.9562080Z ##[section]Finishing: Build solution ***.sln

Do you need more information?

@wireznak
Copy link
Contributor

@maboivin This appears to be a known issue with the msbuild tool itself in which it does not issue the correct return code when the only errors are warnings that were promoted through the /WarnAsErrors switch: dotnet/msbuild#9825

Based on the debug log you provided, it appears that the MSBuild Task is correctly interpreting the return code it's been given-- the problem is that msbuild.exe is returning the wrong return code. Please report this to the DotNet team.

@maboivin
Copy link

maboivin commented Jul 27, 2020

Just a question for you then.

On my dev machine, when I run:

>msbuild ***.sln /warnaserror

And then echo %errorlevel%, it returns 1:

>echo %errorlevel%
1

Should I get 0 as well?

@wireznak
Copy link
Contributor

As I understand it, the issue appears sporadically, and may be exacerbated by the specific conditions on the build agent (meaning, our debug logging and other activities may be changing when and how much disk and processor is available to msbuild in a way that msbuild running uncontested on your machine isn't).

@github-actions
Copy link

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants