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

ci: Adjust CI pipeline. #2

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ trigger:
include:
- main

resources:
containers:
- container: windows
image: nventive/vs_build-tools:17.2.5

variables:
- name: NUGET_VERSION
value: 6.2.0
Expand All @@ -19,9 +14,6 @@ variables:
value: GooseAnalyzers.sln
- name: IsReleaseBranch # Should this branch name use the release stage
value: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))]
# Pool names
- name: windowsPoolName
value: 'windows 2022'

stages:
- stage: Build
Expand All @@ -32,11 +24,11 @@ stages:
matrix:
Packages:
ApplicationConfiguration: Release
ApplicationPlatform: NuGet
ApplicationPlatform: Any CPU
GeneratePackageOnBuild: true

pool:
name: $(windowsPoolName)
vmImage : windows-2022

variables:
- name: PackageOutputPath # Path where nuget packages will be copied to.
Expand All @@ -45,8 +37,6 @@ stages:
workspace:
clean: all # Cleanup the workspaca before starting

container: windows

steps:
- template: stage-build.yml

Expand All @@ -57,7 +47,7 @@ stages:
- job: Publish_NuGet_External

pool:
name: $(windowsPoolName)
vmImage : windows-2022

workspace:
clean: all # Cleanup the workspaca before starting
Expand Down
58 changes: 22 additions & 36 deletions build/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,30 @@
versionSpec: $(NUGET_VERSION)
checkLatest: false

- task: MSBuild@1
displayName: 'Restore solution packages'
inputs:
solution: $(Build.SourcesDirectory)/src/$(SolutionFileName)
msbuildLocationMethod: version
msbuildVersion: latest
msbuildArchitecture: x86
msbuildArguments: >
/t:restore
configuration: $(ApplicationConfiguration)
platform: $(ApplicationPlatform)
clean: false
maximumCpuCount: true
restoreNugetPackages: false
logProjectEvents: false
createLogFile: false
# For some reason, we need to build the package first before any other command (like dotnet pack).
- script: >
dotnet build src/GooseAnalyzers/GooseAnalyzers.csproj
--configuration $(ApplicationConfiguration)
-p:PackageVersion=$(GitVersion.SemVer)
-p:ContinousIntegrationBuild=true
displayName: 'Build $(ApplicationConfiguration)'

- task: MSBuild@1
displayName: 'Build solution in $(ApplicationConfiguration) | $(ApplicationPlatform)'
inputs:
solution: $(Build.SourcesDirectory)/src/$(SolutionFileName)
msbuildLocationMethod: version
msbuildVersion: latest
msbuildArchitecture: x86
configuration: $(ApplicationConfiguration)
platform: $(ApplicationPlatform)
clean: false
maximumCpuCount: true
restoreNugetPackages: false
logProjectEvents: false
createLogFile: false
msbuildArguments: > # Set the version of the packages, will have no effect on application projects (Heads).
/p:PackageVersion=$(GitVersion.SemVer)
/p:ContinousIntegrationBuild=true

- script: dotnet test src --no-build --configuration $(ApplicationConfiguration) --logger trx --collect "Code coverage"
- script: >
dotnet pack src/GooseAnalyzers/GooseAnalyzers.csproj
--configuration $(ApplicationConfiguration)
-p:PackageVersion=$(GitVersion.SemVer)
-p:ContinousIntegrationBuild=true
--no-build
displayName: 'Pack $(ApplicationConfiguration)'

# Note that we specify IsPackable=false otherwise another package with the wrong version is generated by dotnet test.
- script: >
dotnet test src
-p:IsPackable=false
--configuration $(ApplicationConfiguration)
--logger trx
--collect "Code coverage"
displayName: 'Run tests'
condition: and(succeeded(), eq(variables['ApplicationPlatform'], 'NuGet'))

- task: PublishTestResults@2
displayName: 'Publish test results'
Expand Down
9 changes: 5 additions & 4 deletions src/GooseAnalyzers/GooseAnalyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
<AssemblyName>GooseAnalyzers</AssemblyName>
<PackageId>GooseAnalyzers</PackageId>
<Description>A collection of .NET analyzers and DiagnosticSuppressors for C#.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>analyzers;roslyn;diagnostics</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/nventive/GooseAnalyzers</PackageProjectUrl>

<!--Needed for Source Link support -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

</PropertyGroup>

Expand All @@ -44,6 +40,11 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup>
<IncludeBuildOutput>false</IncludeBuildOutput>
<NoPackageAnalysis>true</NoPackageAnalysis>
</PropertyGroup>

<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
Expand Down