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

Update "dotnet build" CLI command to treat warning as error #1767

Merged
merged 2 commits into from
Feb 4, 2021

Conversation

abhipsaMisra
Copy link
Member

@abhipsaMisra abhipsaMisra commented Feb 2, 2021

No description provided.

@abhipsaMisra
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@abhipsaMisra
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -120,9 +125,9 @@ Function BuildProject($path, $message)
}
}

& dotnet build $projectPath --verbosity $verbosity --configuration $configuration
& dotnet build $projectPath --verbosity $verbosity --configuration $configuration -warnAsError | Tee-Object ./buildlog.txt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what we are doing here is routing the command output to a file and searching the text for the string "Build FAILED".
This is required because:

  • dotnet build correctly marks the build as failed (on passing the flag -warnAsError)
  • powershell does not report the LASTEXITCODE as not 0 (this behavior is not deterministic, it works sometimes, doesn't at other times)

Linked github discussions see this as an issue in the .NET sdk: https://github.com/dotnet/installer/issues/1708

See two consecutive runs returning different results:

PS S:\csharp\azure> . 's:\csharp\azure\build.ps1' -clean -build -configuration DEBUG
Local packages being used for testing: False

BUILD: --- Azure IoT C# SDK Solution DEBUG ---
cleaning
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]

Build FAILED.

S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
    0 Warning(s)
    4 Error(s)

Time Elapsed 00:00:20.48
LASTEXITCODE: 1


Time Elapsed 00:00:23.7478540
Build failed (Build failed: BUILD: --- Azure IoT C# SDK Solution DEBUG ---)
PS S:\csharp\azure> . 's:\csharp\azure\build.ps1' -clean -build -configuration DEBUG
Local packages being used for testing: False

BUILD: --- Azure IoT C# SDK Solution DEBUG ---
cleaning
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]

Build FAILED.

S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
S:\csharp\azure\iothub\device\src\Edge\EdgeModuleClientFactory.cs(96,34): error CA2000: Call System.IDisposable.Dispose on object created by 'new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId)' before all references to it are out of scope [S:\csharp\azure\iothub\device\src\Microsoft.Azure.Devices.Client.csproj]
    0 Warning(s)
    4 Error(s)

Time Elapsed 00:00:22.52
LASTEXITCODE: 0


Time Elapsed 00:00:25.4949819
Build succeeded.

@abhipsaMisra
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@abhipsaMisra
Copy link
Member Author

The pipeline is expected to fail, since we have a warning pending: #1768

@vinagesh
Copy link
Member

vinagesh commented Feb 4, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@abhipsaMisra abhipsaMisra marked this pull request as ready for review February 4, 2021 02:07
@abhipsaMisra abhipsaMisra merged commit a46c26f into master Feb 4, 2021
@abhipsaMisra abhipsaMisra deleted the abmisr/build branch February 4, 2021 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants