Skip to content

Commit

Permalink
Updating the repo infrastructure for .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Dec 10, 2022
1 parent 1c75c46 commit 1c3a079
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 57 deletions.
8 changes: 6 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
tab_width = 4
trim_trailing_whitespace = true

###############################################################################
Expand Down Expand Up @@ -176,6 +177,7 @@ dotnet_sort_system_directives_first = true
# require null-coalescing expressions,
# require collection-initializers,
# require explicit tuple names,
# suggest namespace match folder names,
# require null-propogation
# require object-initializers,
#
Expand Down Expand Up @@ -210,6 +212,7 @@ dotnet_sort_system_directives_first = true
dotnet_style_coalesce_expression = true:error
dotnet_style_collection_initializer = true:error
dotnet_style_explicit_tuple_names = true:error
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_null_propagation = true:error
dotnet_style_object_initializer = true:error

Expand Down Expand Up @@ -414,16 +417,17 @@ csharp_style_implicit_object_creation_when_type_is_apparent = false:error

csharp_style_inlined_variable_declaration = true:error

csharp_style_namespace_declarations=file_scoped:error
csharp_style_namespace_declarations= file_scoped:error

csharp_style_pattern_local_over_anonymous_function = true:error
csharp_style_pattern_matching_over_as_with_null_check = true:error
csharp_style_pattern_matching_over_is_with_cast_check = true:error

csharp_style_prefer_index_operator = false:error
csharp_style_prefer_range_operator = false:error
csharp_style_prefer_method_group_conversion = true:suggestion
csharp_style_prefer_not_pattern = true:error
csharp_style_prefer_pattern_matching = true:error
csharp_style_prefer_range_operator = false:error
csharp_style_prefer_switch_expression = true:error

csharp_style_throw_expression = true:error
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ci

on:
push:
branches: [ main ]
branches: [ main, v* ]
pull_request:
branches: [ main ]
branches: [ main, v* ]

jobs:
windows-x64:
Expand All @@ -15,10 +15,10 @@ jobs:
configuration: [ debug, release ]
os: [ windows ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/cibuild.cmd -configuration ${{ matrix.configuration }} -architecture ${{ matrix.architecture }}
shell: cmd
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
Expand All @@ -35,10 +35,10 @@ jobs:
configuration: [ debug, release ]
os: [ windows ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/cibuild.cmd -configuration ${{ matrix.configuration }} -architecture ${{ matrix.architecture }} /p:PlatformTarget=${{ matrix.architecture }}
shell: cmd
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_x86
path: |
Expand All @@ -55,10 +55,10 @@ jobs:
configuration: [ debug, release ]
os: [ ubuntu ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }}
shell: bash
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
Expand All @@ -75,10 +75,10 @@ jobs:
configuration: [ debug, release ]
os: [ macos ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }}
shell: bash
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
Expand All @@ -90,13 +90,13 @@ jobs:
build-nuget-preview:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/cibuild.cmd -configuration release -architecture x64
shell: cmd
env:
EXCLUDE_RUN_ID_FROM_PACKAGE: true
EXCLUDE_SUFFIX_FROM_VERSION: false
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: nuget_preview
path: |
Expand All @@ -109,13 +109,13 @@ jobs:
runs-on: windows-latest
if: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/cibuild.cmd -configuration release -architecture x64
shell: cmd
env:
EXCLUDE_RUN_ID_FROM_PACKAGE: true
EXCLUDE_SUFFIX_FROM_VERSION: true
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: nuget_release
path: |
Expand All @@ -133,7 +133,7 @@ jobs:
with:
name: windows_release_x64
path: ./artifacts
- uses: actions/setup-dotnet@v1
- uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'
source-url: https://pkgs.terrafx.dev/index.json
Expand All @@ -149,7 +149,7 @@ jobs:
with:
name: windows_release_x64
path: ./artifacts
- uses: actions/setup-dotnet@v1
- uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'
- run: dotnet nuget push "./artifacts/pkg/Release/*.nupkg" --source https://nuget.pkg.github.com/terrafx/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
8 changes: 3 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
<!-- Default settings that explicitly differ from the Sdk.props defaults -->
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AnalysisLevel>preview</AnalysisLevel>
<BaseIntermediateOutputPath>$(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/</BaseIntermediateOutputPath>
<DebugType>embedded</DebugType>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<Nullable>enable</Nullable>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>true</SignAssembly>
Expand All @@ -43,7 +45,6 @@
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(Configuration)/</PackageOutputPath>
<Product>TerraFX.Optimizer</Product>
<VersionPrefix>0.1.0.0</VersionPrefix>
<VersionSuffix>alpha1</VersionSuffix>
<VersionSuffix Condition="'$(EXCLUDE_SUFFIX_FROM_VERSION)' != 'true'">alpha</VersionSuffix>
<VersionSuffix Condition="'$(GITHUB_EVENT_NAME)' == 'pull_request'">pr</VersionSuffix>
</PropertyGroup>
Expand All @@ -66,10 +67,7 @@
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<PublicSign>true</PublicSign>
<RepositoryType>git</RepositoryType>
<RestoreSources>
https://api.nuget.org/v3/index.json;
https://pkgs.terrafx.dev/index.json;
</RestoreSources>
<RestoreConfigFile>$(MSBuildThisFileDirectory)NuGet.config</RestoreConfigFile>
<UseSharedCompilation>true</UseSharedCompilation>
</PropertyGroup>

Expand Down
15 changes: 3 additions & 12 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- Settings that append the existing setting value -->
<PropertyGroup>
<NoWarn>$(NoWarn);NU5105</NoWarn>
<NoWarn>$(NoWarn)</NoWarn>
</PropertyGroup>

<!-- Settings that are only set for CI builds -->
Expand All @@ -27,17 +27,8 @@

<!-- Settings that are only set for libraries -->
<PropertyGroup Condition="'$(OutputType)' == 'Library'">
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
<IsTrimmable>false</IsTrimmable>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<!-- Package versions for package references across all projects -->
<ItemGroup>
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.0" />
<PackageReference Update="NUnit" Version="3.13.2" />
<PackageReference Update="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Update="System.CommandLine" Version="2.0.0-beta1.21308.1" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<!--
Directory.Packages.props is automatically picked up and imported by
Microsoft.Common.targets. This file needs to exist, even if empty so that
files in the parent directory tree, with the same name, are not imported
instead. The import fairly late and most other props/targets will have been
imported beforehand. We also don't need to add ourselves to
MSBuildAllProjects, as that is done by the file that imports us.
-->

<!-- Package versions for package references across all projects -->
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSourceMapping>
<packageSource key="nuget">
<package pattern="*" />
<package pattern="TerraFX.*" />
</packageSource>
<packageSource key="terrafx">
<package pattern="TerraFX.*" />
</packageSource>
</packageSourceMapping>
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="terrafx" value="https://pkgs.terrafx.dev/index.json" />
</packageSources>
</configuration>
9 changes: 5 additions & 4 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ErrorActionPreference = "Stop"

function Build() {
$logFile = Join-Path -Path $LogDir -ChildPath "$configuration\build.binlog"
& dotnet build -c "$configuration" --no-restore -v "$verbosity" /bl:"$logFile" /err "$properties" "$solution"
& dotnet build -c "$configuration" --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$properties" "$solution"

if ($LastExitCode -ne 0) {
throw "'Build' failed for '$solution'"
Expand Down Expand Up @@ -55,7 +55,7 @@ function Help() {

function Pack() {
$logFile = Join-Path -Path $LogDir -ChildPath "$configuration\pack.binlog"
& dotnet pack -c "$configuration" --no-build --no-restore -v "$verbosity" /bl:"$logFile" /err "$properties" "$solution"
& dotnet pack -c "$configuration" --no-build --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$properties" "$solution"

if ($LastExitCode -ne 0) {
throw "'Pack' failed for '$solution'"
Expand All @@ -64,7 +64,7 @@ function Pack() {

function Restore() {
$logFile = Join-Path -Path $LogDir -ChildPath "$configuration\restore.binlog"
& dotnet restore -v "$verbosity" /bl:"$logFile" /err "$properties" "$solution"
& dotnet restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$properties" "$solution"

if ($LastExitCode -ne 0) {
throw "'Restore' failed for '$solution'"
Expand All @@ -73,7 +73,7 @@ function Restore() {

function Test() {
$logFile = Join-Path -Path $LogDir -ChildPath "$configuration\test.binlog"
& dotnet test -c "$configuration" --no-build --no-restore -v "$verbosity" /bl:"$logFile" /err "$properties" "$solution"
& dotnet test -c "$configuration" --no-build --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$properties" "$solution"

if ($LastExitCode -ne 0) {
throw "'Test' failed for '$solution'"
Expand Down Expand Up @@ -121,6 +121,7 @@ try {
Create-Directory -Path $DotNetInstallDirectory

& $DotNetInstallScript -Channel 6.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
& $DotNetInstallScript -Channel 7.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture

$env:PATH="$DotNetInstallDirectory;$env:PATH"
}
Expand Down
17 changes: 9 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function Build {
logFile="$LogDir/$configuration/build.binlog"

if [[ -z "$properties" ]]; then
dotnet build -c "$configuration" --no-restore -v "$verbosity" /bl:"$logFile" /err "$solution"
dotnet build -c "$configuration" --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$solution"
else
dotnet build -c "$configuration" --no-restore -v "$verbosity" /bl:"$logFile" /err "${properties[@]}" "$solution"
dotnet build -c "$configuration" --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "${properties[@]}" "$solution"
fi

LASTEXITCODE=$?
Expand Down Expand Up @@ -118,9 +118,9 @@ function Pack {
logFile="$LogDir/$configuration/pack.binlog"

if [[ -z "$properties" ]]; then
dotnet pack -c "$configuration" --no-build --no-restore -v "$verbosity" /bl:"$logFile" /err "$solution"
dotnet pack -c "$configuration" --no-build --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$solution"
else
dotnet pack -c "$configuration" --no-build --no-restore -v "$verbosity" /bl:"$logFile" /err "${properties[@]}" "$solution"
dotnet pack -c "$configuration" --no-build --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "${properties[@]}" "$solution"
fi

LASTEXITCODE=$?
Expand All @@ -135,9 +135,9 @@ function Restore {
logFile="$LogDir/$configuration/restore.binlog"

if [[ -z "$properties" ]]; then
dotnet restore -v "$verbosity" /bl:"$logFile" /err "$solution"
dotnet restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$solution"
else
dotnet restore -v "$verbosity" /bl:"$logFile" /err "${properties[@]}" "$solution"
dotnet restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "${properties[@]}" "$solution"
fi

LASTEXITCODE=$?
Expand All @@ -152,9 +152,9 @@ function Test {
logFile="$LogDir/$configuration/test.binlog"

if [[ -z "$properties" ]]; then
dotnet test -c "$configuration" --no-build --no-restore -v "$verbosity" /bl:"$logFile" /err "$solution"
dotnet test -c "$configuration" --no-build --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "$solution"
else
dotnet test -c "$configuration" --no-build --no-restore -v "$verbosity" /bl:"$logFile" /err "${properties[@]}" "$solution"
dotnet test -c "$configuration" --no-build --no-restore -v "$verbosity" /p:Platform="Any CPU" /bl:"$logFile" /err "${properties[@]}" "$solution"
fi

LASTEXITCODE=$?
Expand Down Expand Up @@ -205,6 +205,7 @@ if [[ ! -z "$architecture" ]]; then
CreateDirectory "$DotNetInstallDirectory"

. "$DotNetInstallScript" --channel 6.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
. "$DotNetInstallScript" --channel 7.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"

PATH="$DotNetInstallDirectory:$PATH:"
fi
Expand Down
2 changes: 1 addition & 1 deletion sources/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" IsImplicitlyDefined="true" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions sources/Optimization/TerraFX.Optimization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<NoWarn>1591;$(NoWarn)</NoWarn>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

</Project>
5 changes: 2 additions & 3 deletions sources/Optimizer/TerraFX.Optimizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<NoWarn>1591;$(NoWarn)</NoWarn>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<OutputType>Exe</OutputType>
<RootNamespace>TerraFX.Optimization</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 1c3a079

Please sign in to comment.