Skip to content
This repository was archived by the owner on Dec 12, 2020. It is now read-only.

Commit 8ad7427

Browse files
authored
Use .NET Core SDK 3.1 (#178)
* Use .NET Core SDK 3.1, closes #177 * ci: install netcoreapp2.1 runtime * feature: Add back net20, net40 TFM to Attributes * build: Drop MSBuild.Sdk.Extras reference since it's no longer used * ci: Non-windows builds all use dotnet on AzP/Win, closes #153 * build: Reference Microsoft.NETFramework.ReferenceAssemblies package * docs: Update README, add CHANGELOG and CONTRIBUTING * build: Use ngbv v3.0.28 * feature: Use Roslyn v3.4.0 nuget * ci: Add binlog to gh actions * build: Fix the casing error that impacted only Ubuntu * build: Treat warnings as errors * docs: Add GH Actions badge to readme
1 parent 2b8456d commit 8ad7427

12 files changed

Lines changed: 123 additions & 42 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,28 @@ on:
1212

1313
env:
1414
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
15-
dotnet_sdk_version: '2.1.500'
1615
build_configuration: Release
1716

1817
jobs:
1918
build-windows:
2019
runs-on: windows-latest
2120
steps:
2221
- uses: actions/checkout@v1
22+
- name: Install .NET Core
23+
shell: pwsh
24+
run: |
25+
$info = dotnet --info
26+
$isRuntime = $info -contains 'Microsoft.NETCore.App 2.1'
27+
Push-Location src; dotnet --version > $null; Pop-Location; $isSdk = $LASTEXITCODE -eq 0; $LASTEXITCODE = 0
28+
if ($isSdk -and $isRuntime) { return }
29+
[string]$dotnetroot = "~/.dotnet" | %{ if (-not (Test-Path $_)) { mkdir $_ > $null }; Resolve-Path $_ }
30+
Invoke-WebRequest "https://dotnetwebsite.azurewebsites.net/download/dotnet-core/scripts/v1/dotnet-install.ps1" -OutFile ~/dotnet-install.ps1
31+
~/dotnet-install.ps1 -JsonFile src/global.json -InstallDir $dotnetroot
32+
~/dotnet-install.ps1 -Channel 2.1 -Runtime dotnet -InstallDir $dotnetroot
33+
Write-Output "::add-path::$dotnetroot"
34+
Write-Output "::set-env name=DOTNET_ROOT::$dotnetroot"
2335
- name: Setup .NET Core
2436
uses: actions/setup-dotnet@v1
25-
with:
26-
dotnet-version: ${{ env.dotnet_sdk_version }}
2737
- run: dotnet --info
2838
- name: Install and run nbgv
2939
run: |
@@ -32,7 +42,7 @@ jobs:
3242
- name: Restore
3343
run: dotnet restore src -v normal
3444
- name: Build
35-
run: dotnet build src -t:build,pack --no-restore -m -c ${{ env.build_configuration }}
45+
run: dotnet build src -t:build,pack --no-restore -m -c ${{ env.build_configuration }} -bl:obj/logs/build-windows.binlog
3646
- name: Test
3747
run: dotnet test src --no-build -c ${{ env.build_configuration }}
3848
- name: Upload nugets
@@ -41,28 +51,48 @@ jobs:
4151
with:
4252
name: nugets
4353
path: bin/Packages/${{ env.build_configuration }}
54+
- name: Upload logs
55+
uses: actions/upload-artifact@v1
56+
with:
57+
name: logs-windows
58+
path: obj/logs/
4459

4560
build-other:
4661
strategy:
4762
matrix:
4863
os: [ubuntu-latest, macos-latest]
49-
env:
50-
project_path: 'src/CodeGeneration.Roslyn.Tests'
5164
runs-on: ${{ matrix.os }}
5265
steps:
5366
- uses: actions/checkout@v1
67+
- name: Install .NET Core
68+
shell: pwsh
69+
run: |
70+
$info = dotnet --info
71+
$isRuntime = $info -contains 'Microsoft.NETCore.App 2.1'
72+
Push-Location src; dotnet --version > $null; Pop-Location; $isSdk = $LASTEXITCODE -eq 0; $LASTEXITCODE = 0
73+
if ($isSdk -and $isRuntime) { return }
74+
[string]$dotnetroot = "~/.dotnet" | %{ if (-not (Test-Path $_)) { mkdir $_ > $null }; Resolve-Path $_ }
75+
Invoke-WebRequest "https://dotnetwebsite.azurewebsites.net/download/dotnet-core/scripts/v1/dotnet-install.sh" -OutFile ~/dotnet-install.sh
76+
chmod +x ~/dotnet-install.sh
77+
~/dotnet-install.sh -JsonFile src/global.json -InstallDir $dotnetroot
78+
~/dotnet-install.sh -Channel 2.1 -Runtime dotnet -InstallDir $dotnetroot
79+
Write-Output "::add-path::$dotnetroot"
80+
Write-Output "::set-env name=DOTNET_ROOT::$dotnetroot"
5481
- name: Setup .NET Core
5582
uses: actions/setup-dotnet@v1
56-
with:
57-
dotnet-version: ${{ env.dotnet_sdk_version }}
5883
- run: dotnet --info
5984
- name: Install and run nbgv
6085
run: |
61-
dotnet tool install --tool-path . nbgv
86+
dotnet tool install --tool-path . nbgv --version 3.0.28
6287
./nbgv get-version -p src
6388
- name: Restore
64-
run: dotnet restore ${{ env.project_path }} -v normal
89+
run: dotnet restore src -v normal
6590
- name: Build
66-
run: dotnet build ${{ env.project_path }} --no-restore -m -c ${{ env.build_configuration }} -f netcoreapp2.1
91+
run: dotnet build src --no-restore -m -c ${{ env.build_configuration }} -bl:obj/logs/build-${{ matrix.os }}.binlog
6792
- name: Test
68-
run: dotnet test ${{ env.project_path }} --no-build -c ${{ env.build_configuration }} -f netcoreapp2.1
93+
run: dotnet test src --no-build -c ${{ env.build_configuration }} -f netcoreapp2.1
94+
- name: Upload logs
95+
uses: actions/upload-artifact@v1
96+
with:
97+
name: logs-${{ matrix.os }}
98+
path: obj/logs/

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
* GeneratorInCustomerSolution sample in `samples` folder
12+
* GitHub Actions CI
13+
14+
### Changed
15+
* .NET Core SDK version bumped to `3.1.100` ([#178]).
16+
* `Attributes` package now targets `net20;net40` in addition to `netstandard1.0` ([#178]).
17+
18+
[#178]: https://github.com/AArnott/CodeGeneration.Roslyn/pull/178
19+
20+
21+
## [0.6.1] - 2019-06-16
22+
23+
See https://github.com/AArnott/CodeGeneration.Roslyn/releases/tag/v0.6.1
24+
25+
[Unreleased]: https://github.com/amis92/RecordGenerator/compare/v0.6.1...HEAD
26+
[0.6.1]: #061---2019-06-16

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Prerequisites
2+
3+
* .NET Core SDK - version as specified in [src/global.json](src/global.json).
4+
* netcoreapp2.1 runtime (Microsoft.NETCore.App 2.1.x)
5+
6+
## Building
7+
8+
* Using shell/command line: `dotnet build src`
9+
* Using Visual Studio: min. VS2019 v16.4., open [src/CodeGeneration.Roslyn.sln](src/CodeGeneration.Roslyn.sln)

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Roslyn-based Code Generation
22

33
[![Build Status](https://andrewarnott.visualstudio.com/OSS/_apis/build/status/CodeGeneration.Roslyn)](https://andrewarnott.visualstudio.com/OSS/_build/latest?definitionId=15)
4+
[![GitHub Actions CI status](https://github.com/AArnott/CodeGeneration.Roslyn/workflows/CI/badge.svg?branch=master)](https://github.com/AArnott/CodeGeneration.Roslyn/actions?query=workflow%3ACI+branch%3Amaster)
45
[![NuGet package](https://img.shields.io/nuget/v/CodeGeneration.Roslyn.svg)][NuPkg]
56

67
Assists in performing Roslyn-based code generation during a build.
@@ -10,6 +11,8 @@ up to Intellisense as soon as the file is saved to disk.
1011

1112
See [who's generating code or consuming it using CodeGeneration.Roslyn](https://github.com/AArnott/CodeGeneration.Roslyn/wiki/Users).
1213

14+
Instructions on development and using this project's source code are in [CONTRIBUTING.md](CONTRIBUTING.md).
15+
1316
## Table of Contents
1417

1518
* [How to write your own code generator][]
@@ -30,8 +33,6 @@ your code generation attribute is applied to, but with a suffix appended to its
3033
If you don't have v2.1+ there will be cryptic error messages
3134
(see [#111](https://github.com/AArnott/CodeGeneration.Roslyn/issues/111)).
3235

33-
* .NET Core SDK v2.1.500 specifically for building this project
34-
3536
[dotnet-sdk-2.1]: https://dotnet.microsoft.com/download/dotnet-core/2.1
3637

3738
### Define code generator

azure-pipeline.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@ resources:
1717

1818
jobs:
1919
- job: Windows
20-
pool: Hosted VS2017
20+
pool:
21+
vmImage: 'windows-2019'
2122
steps:
22-
- task: DotNetCoreInstaller@0
23+
- task: UseDotNet@2
24+
displayName: Install .NET Core runtime v2.1
25+
inputs:
26+
packageType: runtime
27+
version: '2.1.x'
28+
29+
- task: UseDotNet@2
2330
displayName: Install/select .NET Core SDK
2431
inputs:
25-
version: '2.1.500'
32+
useGlobalJson: true
33+
workingDirectory: src
2634

2735
- script: |
28-
dotnet tool install --tool-path . nbgv
36+
dotnet tool install --tool-path . nbgv --version 3.0.28
2937
.\nbgv cloud -p src
3038
displayName: Set build number
3139
condition: ne(variables['system.pullrequest.isfork'], true)
@@ -36,22 +44,17 @@ jobs:
3644
- task: DotNetCoreCLI@2
3745
displayName: Restore NuGet packages
3846
inputs:
39-
command: restore
40-
verbosityRestore: normal # detailed, normal, minimal
47+
command: custom
48+
custom: restore
4149
projects: src/**/*.sln
42-
feedsToUse: config
43-
nugetConfigPath: src/nuget.config
4450

45-
# Use VSBuild on Windows so GitLink will work (it fails on dotnet build)
46-
# Also targeting net20, net40, PCLs etc requires full MSBuild
47-
- task: VSBuild@1
48-
displayName: Build Visual Studio solution
51+
- task: DotNetCoreCLI@2
52+
displayName: Build solutions
4953
inputs:
50-
vsVersion: '15.0'
51-
solution: src/**/*.sln
52-
msbuildArgs: /t:build,pack /m /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
53-
platform: $(BuildPlatform)
54-
configuration: $(BuildConfiguration)
54+
command: custom
55+
custom: build
56+
projects: src/**/*.sln
57+
arguments: -t:build,pack --no-restore -m -c $(BuildConfiguration) -bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
5558

5659
- task: DotNetCoreCLI@2
5760
displayName: Run tests

azure-pipelines/testfx.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
steps:
2+
- task: UseDotNet@2
3+
displayName: Install .NET Core runtime v2.1
4+
inputs:
5+
packageType: runtime
6+
version: '2.1.x'
7+
- task: UseDotNet@2
8+
displayName: Install/select .NET Core SDK
9+
inputs:
10+
useGlobalJson: true
11+
workingDirectory: src
212
- script: dotnet restore
313
displayName: Restore packages
414
workingDirectory: ${{ parameters.projectdirectory }}
5-
- script: dotnet build -v n -f netcoreapp2.1 -c $(BuildConfiguration) --no-restore /bl:"$(Build.ArtifactStagingDirectory)/build_logs/netcoreapp2.1.binlog" -p:GitLinkEnabled=false
15+
- script: dotnet build -v n -c $(BuildConfiguration) --no-restore /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
616
displayName: Build tests for netcoreapp2.1
717
workingDirectory: ${{ parameters.projectdirectory }}
818
- script: dotnet test -v n -f netcoreapp2.1 -c $(BuildConfiguration) --no-build

src/CodeGeneration.Roslyn.Attributes/CodeGeneration.Roslyn.Attributes.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="MSBuild.Sdk.Extras">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.0</TargetFrameworks>
4+
<TargetFrameworks>net20;net40;netstandard1.0</TargetFrameworks>
55
<RootNamespace>CodeGeneration.Roslyn</RootNamespace>
66
<Description>A package that offers attributes to drive code generation.</Description>
77
</PropertyGroup>

src/CodeGeneration.Roslyn.Tests.ruleset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RuleSet Name="Tests Rules" Description="Additional rules (exceptions) for test projects." ToolsVersion="15.0">
3-
<Include Path="codegeneration.roslyn.ruleset" Action="Default" />
3+
<Include Path="CodeGeneration.Roslyn.ruleset" Action="Default" />
44
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
55
<Rule Id="SA0001" Action="Hidden" />
66
<Rule Id="SA1402" Action="Hidden" />

src/CodeGeneration.Roslyn.Tool/CodeGeneration.Roslyn.Tool.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Description>The dotnet code generation tool that works with the CodeGeneration.Roslyn nuget package.</Description>
99
<CodeAnalysisRuleSet>CodeGeneration.Roslyn.Tool.ruleset</CodeAnalysisRuleSet>
1010
<NoWarn>$(NoWarn);CS1591</NoWarn>
11+
<RollForward>Major</RollForward>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

src/CodeGeneration.Roslyn.Tool/CodeGeneration.Roslyn.Tool.ruleset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RuleSet Name="Tests Rules" Description="Additional rules (exceptions) for test projects." ToolsVersion="15.0">
3-
<Include Path="../codegeneration.roslyn.tests.ruleset" Action="Default" />
3+
<Include Path="../CodeGeneration.Roslyn.Tests.ruleset" Action="Default" />
44
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
55
<!--for the CommandLine files-->
66
<Rule Id="SA1028" Action="Hidden" />

0 commit comments

Comments
 (0)