I'm using a few .csproj features:
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Locally, this all works fine.
Cause a warning, it won't build
Format something in non-standard way, it won't build
The issue is: it builds fine locally, but Azure DevOps fails, citing IDE0055 for in-line comments on chained methods:
var list = new List<string>();
var cleanList = list
// ignore zero-length strings
.Where(l => l.Length == 0)
// ignore too-long strings
.Where(l => l.Length > 10)
.ToList();
There are two differences:
Local: Windows and MSBuild version 17.4.0+18d5aef85 for .NET
DevOps: Linux and Build Engine version 17.1.1+a02f73656 for .NET
I'm assuming this outdated (?) build engine is to blame. Is there a way to target a different build engine? Hopefully it's not tied to UseDotNet#2 packageType, as that needed to be set to 6.0.202 so the code could run on AWS Lambda.
The full DevOps output:
Starting: Build projects
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.210.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
/opt/hostedtoolcache/dotnet/dotnet build /home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.210.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.210.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" -c Release -r linux-x64 -p:PublishReadyToRun=true
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored /home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj (in 367 ms).
##[error]Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(22,33): Error IDE0055: Fix formatting
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(22,33): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
##[error]Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(23,46): Error IDE0055: Fix formatting
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(23,46): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
##[error]Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(24,43): Error IDE0055: Fix formatting
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(24,43): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
##[error]Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(25,43): Error IDE0055: Fix formatting
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(25,43): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
Build FAILED.
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(22,33): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(23,46): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(24,43): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/AdjustEmployeeScheduleRequest.cs(25,43): error IDE0055: Fix formatting [/home/vsts/work/1/s/Psrm.ScheduleCalculator.Contract/Psrm.ScheduleCalculator.Contract.csproj]
0 Warning(s)
4 Error(s)
Time Elapsed 00:00:03.50
##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1
/opt/hostedtoolcache/dotnet/dotnet build /home/vsts/work/1/s/Psrm.ScheduleCalculator.InternalContract/Psrm.ScheduleCalculator.InternalContract.csproj -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.210.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.210.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" -c Release -r linux-x64 -p:PublishReadyToRun=true
Based on your description, the problem looks like is related to the different OSs (Windows and Linux) where the build is running.
Since you develop and edit the C# code on your local Windows machine, it can match the consistent code style when you directly build the code on the local Windows machine.
However, when you move to the Linux machine to build, for how indentation, spaces, and new lines are aligned around .NET programming language constructs, it may be different with Windows.
For more details about the IDE0055 Error, you can reference the document "Formatting rule (IDE0055)".
For your case, you can try to select a Windows agent to run the build pipeline on Azure DevOps. We have provided the Microsoft-hosted Windows agents (windows-2022 and windows-2019) for Azure Pipelines on Azure DevOps. Or you can set up a self-hosted agent on your local Windows machine to run the build pipeline.
Related
I'm not able to build my unity project into apk, whenever i try to build it throw errors
I'm using unity 2020.3.21
I'm using api level 31 because i want to submit the update of my game on playstore and now they changed the api level to 31.
errors
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseAidl'.
> Installed Build Tools revision 33.0.0 is corrupted. Remove and install again using the SDK Manager.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with -
The other error
Could not determine the dependencies of task ':unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseAidl'.
> Installed Build Tools revision 33.0.0 is corrupted. Remove and install again using the SDK Manager.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
As i can see in the error it is mentioned that Build Tools revision 33.0.0 is corrupted i already renistalled using the android studio but still the same error or maybe i did it wrong. if you know anything about this error then you are welcome any help should be appericiated.
try to install via unity package manager instead of android studio since it may have different file names for the different applications
hope this helps!
1) When I Try to use Rebuild option
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/MSBuild.SonarQube.Runner.exe /t:Rebuild
WARNING: ------------------------------------------------------------------------
This executable is deprecated and may be removed in next major version of the SonarScanner for MSBuild. Please use 'SonarScanner.MSBuild.exe' instead.
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
WARNING: Please specify the command 'begin' or 'end' to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
Pre-processing started.
Preparing working directories...
05:23:39.463 05:23:39.454 Unrecognized command line argument: /t:Rebuild
05:23:39.464 05:23:39.462 A required argument is missing: /key:[SonarQube project key]
05:23:39.464 Expecting at least the following command line argument:
SonarQube project key
When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
SonarQube project name
SonarQube project version
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
05:23:39.464 Pre-processing failed. Exit code: 1
2) I get some other error with authentication problems. Any work around this.
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarScanner.MSBuild.exe begin /k:"Xamarin" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token1"
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
05:18:52.798 Updating build integration targets...
05:18:52.833 Fetching analysis configuration settings...
05:18:52.94 Failed to request and parse 'http://localhost:9000/api/settings/values?component=Xamarin': The remote server returned an error: (401) .
05:18:52.94 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
05:18:52.941 Pre-processing failed. Exit code: 1
I'm pretty new to CI (from a brand new set up point at least). I created a project in Rider, using the default version of NUnit that is provided if you select to 'Create new NUnit Project', and I am now trying to set up an automated build for it using travis-CI.
The target .NET framework version of my project and test projects (confirmed in Project properties in Rider) is 4.5.
The version of Nunit I am using is the default version provided with Rider, 3.5.
Here is my .travis.yml build file:
language: csharp
solution: .sln
install:
- nuget restore FindWordsWithConcatenations.sln
- nuget install NUnit.Runners -Version 3.5.0 -OutputDirectory testrunner
script:
- xbuild /p:Configuration=Debug ./FindWordsWithConcatenations.sln
- mono ./testrunner/NUnit.ConsoleRunner.3.5.0/tools/nunit-agent.exe ./TestFindWordsWithConcatenations/bin/Debug/TestFindWordsWithConcatenations.dll
I confirmed on my own machine by running the nuget command that the test runner path should be correct, when I run the nunit-agent (via agent, agent-x86, or agent-console) I get the following error (locally, and on the server):
Unhandled Exception: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid..ctor(String g)
at NUnit.Agent.NUnitTestAgent.Main(String[] args)
I've also tried running with no configuration mode specified, and with configuration mode of Debug and Release specified.
Unfortunately, the normal tactic of googling/stack overflow hasn't helped, I've seen this error in a few questions, but the cause never seems related to what I'm experiencing.
The last build of the pipeline is available to view here, all the builds thus far have failed, previous builds can be seen here.
Thanks in advance, I would be very grateful if someone had any idea about the cause of this issue, or how I could tackle the test running in a different way.
Solved it.
Updated the script section of the travis config to:
script:
- xbuild /p:Configuration=Debug ./FindWordsWithConcatenations.sln
- mono ./testrunner/NUnit.ConsoleRunner.3.5.0/tools/nunit3-console.exe ./TestFindWordsWithConcatenations/bin/Debug/TestFindWordsWithConcatenations.dll
So it's now running the correct console application. Also had to modify the test paths a bit for it to run on the server.
I've got a .Net application being built by Jenkins Pipelines and jenkinsfile. My Jenkins installation (up to date on the LTS versions) is unable to build my .Net application the first time within a workspace. Any new branch creates a new workspace then fails to build:
"<JENKINS_WORKSPACE_FOR_BRANCH\src\MY_SOLUTION.sln" (default target) (1) ->
"<JENKINS_WORKSPACE_FOR_BRANCH\src\Core\MySln.Core.csproj" (default target) (2) ->
(CoreCompile target) ->
Configuration\DefaultConfiguration.cs(143,51): error CS1002: ; expected [<JENKINS_WORKSPACE_FOR_BRANCH\src\Core\MySln.Core.csproj]
Configuration\DefaultConfiguration.cs(143,54): error CS1520: Method must have a return type [<JENKINS_WORKSPACE_FOR_BRANCH\src\Core\MySln.Core.csproj]
Configuration\DefaultConfiguration.cs(143,66): error CS1031: Type expected [<JENKINS_WORKSPACE_FOR_BRANCH\src\Core\MySln.Core.csproj]
Model\User.cs(48,24): error CS1056: Unexpected character '$' [<JENKINS_WORKSPACE_FOR_BRANCH\src\Core\MySln.Core.csproj]
Model\User.cs(75,20): error CS1056: Unexpected character '$' [<JENKINS_WORKSPACE_FOR_BRANCH\src\Core\MySln.Core.csproj]
Line 143 is
public string MyProperty=> ConfigValue("MyProperty");
Using the new C# 6 Expression Bodied Function Members syntax. The unexpected Character '$' is the c# 6 string formatting syntax:
var mystring = $"This is where I'll put {thisProperty} in my string";
My build call is:
bat "\"${tool 'MSBuildPipeline'}\" src\\MY_SOLUTION.sln /p:Configuration=Release /p:PlatformTarget=x64 /p:ProductVersion=1.3.5.${env.BUILD_NUMBER} /p:VisualStudioVersion=12.0 /p:TargetFrameworkVersion=v4.5 /ToolsVersion:12.0 /p:FrameworkOverride=\"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\""
Which used to be much simpler but I've been trying to specify more and more to get to the bottom of this. I'm using MSBuild 12. I attempted to use MSBuild 14 but there's a problem with building on MSBuild 14 where you need to install a Windows 10 SDK to enable license generation and the SDKs only exist for .Net versions 4.6.x. I've got the Microsoft.Net.Compilers 1.3.2 NuGet packages installed to help enable the c# 6 syntax. The new 2.0.1 version only supports MSBuild 14.0+.
Again, it will only error out for the first build in this workspace. If I hit build again it will succeed without issue, despite no code changes. I'm assuming it's pulling some sort of .dll or asset the first time which fixes the issue for subsequent builds but I don't know what.
I've a C# project: https://github.com/Pro/dkim-exchange
It uses Travis CI: https://travis-ci.org/Pro/dkim-exchange
Travis successfully builds my project.
I wanted to set up Coverity to do automatic code quality measurements. For this I configured my .travis.yml as follows:
language: objective-c
env:
global:
- EnableNuGetPackageRestore=true
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "kC7O0CWm9h4g+tzCwhIZEGwcdiLrb1/1PijeOKGbIWGuWS7cIksAkj2tRNMgtxxcE9CFQr8W7xDv2YzflCIlqN1nGkFjbyD4CrNg6+V1j0fZjPOQ6ssdBBVPrfrvecsAUJ0/48Tqa9VTkEpZSlwOF/VS1sO2ob36FVyWjtxvG9s="
matrix:
- MONO_VERSION="3.10.0"
install:
# Fetch Mono
- wget "http://download.mono-project.com/archive/${MONO_VERSION}/macos-10-x86/MonoFramework-MDK-${MONO_VERSION}.macos10.xamarin.x86.pkg"
- sudo installer -pkg "MonoFramework-MDK-${MONO_VERSION}.macos10.xamarin.x86.pkg" -target /
script:
- xbuild travis.proj
addons:
coverity_scan:
project:
name: "Pro/dkim-exchange"
description: "Build submitted via Travis CI"
notification_email: mail#example.com
build_command_prepend: "xbuild /t:CleanAll travis.proj"
build_command: "xbuild /t:Build travis.proj"
branch_pattern: coverity_scan
If I execute the coverity build commands as indicated here (using msbuild): https://scan.coverity.com/download?tab=csharp the uploaded archive is analyzed correctly, but in combination with travis, the coverity analysis fails (see e.g. this build log: https://travis-ci.org/Pro/dkim-exchange/builds/42295611).
There's this warning:
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
I think this may be related to xbuild from Mono. Unfortunately Dr. Google didn't find anythin about Coverity+xbuild. Does Coverity support xbuild? If yes, how can I correctly setup the project?
When it comes to C#, Coverity actually only supports msbuild.
You can find some more official information about this in the following
http://www.coverity.com/library/pdf/CoverityStaticAnalysis.pdf
https://communities.coverity.com/message/6251#6251
The last link explicitly states
Our C# analysis only supports the Visual Studio C# compilers
So, no xbuild support as of now.
Update:
When you download the Coverity build tool, the doc/en/help/cov-build.txt explicitly states the following:
C# build capture is only supported on Windows.