Skip to content

Commit fdeb1c2

Browse files
authored
Merge pull request #13 from TurnerSoftware/multitarget
Support multiple targets
2 parents 5617341 + edb174a commit fdeb1c2

8 files changed

Lines changed: 207 additions & 162 deletions

File tree

.appveyor.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: Visual Studio 2019
1+
image: Visual Studio 2022
22
skip_branch_with_pr: true
33

44
environment:
@@ -11,15 +11,12 @@ environment:
1111

1212
BUILD_ARTIFACT_PATH: build-artifacts
1313

14-
install:
15-
- choco install dotnet-sdk --version 5.0.200
16-
1714
build_script:
18-
- ps: dotnet --version
15+
- ps: dotnet --info
1916
- ps: dotnet restore
20-
- ps: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true
17+
- ps: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true -bl:$env:BUILD_ARTIFACT_PATH/msbuild-build.binlog
2118
- ps: dotnet test --no-restore /p:SkipBuildVersioning=true
22-
- ps: dotnet pack --no-build -c Release /p:PackageOutputPath=$env:BUILD_ARTIFACT_PATH /p:ContinuousIntegrationBuild=true
19+
- ps: dotnet pack --no-build -c Release /p:PackageOutputPath=$env:BUILD_ARTIFACT_PATH /p:ContinuousIntegrationBuild=true -bl:$env:BUILD_ARTIFACT_PATH/msbuild-pack.binlog
2320

2421
test: false
2522
artifacts:

.github/workflows/build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,25 @@ jobs:
2727
steps:
2828
- name: Checkout
2929
uses: actions/checkout@v2
30-
- name: Setup dotnet 5.0
31-
uses: actions/setup-dotnet@v1
30+
- name: Install .NET SDKs
31+
uses: actions/setup-dotnet@v1.9.0
3232
with:
33-
dotnet-version: '5.0.x'
33+
dotnet-version: |
34+
5.0.x
35+
6.0.x
36+
- name: .NET info
37+
run: dotnet --info
3438
- name: Install dependencies
3539
run: dotnet restore
3640
- name: Build
37-
run: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true
41+
run: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true -bl:${{env.BUILD_ARTIFACT_PATH}}/msbuild-build.binlog
3842
- name: Test with Coverage
3943
run: dotnet test --no-restore --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings /p:SkipBuildVersioning=true
4044
- name: Pack
41-
run: dotnet pack --no-build -c Release /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}} /p:ContinuousIntegrationBuild=true
45+
run: dotnet pack --no-build -c Release /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}} /p:ContinuousIntegrationBuild=true -bl:${{env.BUILD_ARTIFACT_PATH}}/msbuild-pack.binlog
4246
- name: Publish artifacts
4347
uses: actions/upload-artifact@v2
48+
if: always()
4449
with:
4550
name: ${{matrix.os}}
4651
path: ${{env.BUILD_ARTIFACT_PATH}}

azure-pipelines.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,28 @@ jobs:
1010
BUILD_ARTIFACT_PATH: $(Build.ArtifactStagingDirectory)
1111

1212
steps:
13-
- script: dotnet --version
14-
displayName: .NET version
13+
- task: UseDotNet@2
14+
displayName: Install .NET 5 SDK
15+
inputs:
16+
version: 5.0.x
17+
- task: UseDotNet@2
18+
displayName: Install .NET 6 SDK
19+
inputs:
20+
version: 6.0.x
21+
22+
- script: dotnet --info
23+
displayName: .NET info
1524

1625
- script: dotnet restore
1726
displayName: Install dependencies
1827

19-
- script: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true
28+
- script: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true -bl:$(BUILD_ARTIFACT_PATH)/msbuild-build.binlog
2029
displayName: Build
2130

2231
- script: dotnet test --no-restore /p:SkipBuildVersioning=true
2332
displayName: Test
2433

25-
- script: dotnet pack --no-build -c Release /p:PackageOutputPath=$(BUILD_ARTIFACT_PATH) /p:ContinuousIntegrationBuild=true
34+
- script: dotnet pack --no-build -c Release /p:PackageOutputPath=$(BUILD_ARTIFACT_PATH) /p:ContinuousIntegrationBuild=true -bl:$(BUILD_ARTIFACT_PATH)/msbuild-pack.binlog
2635
displayName: Pack
2736

2837
- task: PublishBuildArtifacts@1

src/Directory.Build.props

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<RootNamespace>TurnerSoftware.BuildVersioning</RootNamespace>
5-
6-
<Company>Turner Software</Company>
7-
8-
<PackageId>$(AssemblyName)</PackageId>
9-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
10-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
11-
<PackageProjectUrl>https://github.com/TurnerSoftware/BuildVersioning</PackageProjectUrl>
12-
<PackageBaseTags>semver;semantic;versioning;git</PackageBaseTags>
13-
14-
<!-- SourceLink Support -->
15-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
16-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
17-
<IncludeSymbols>true</IncludeSymbols>
18-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
19-
20-
<LangVersion>Latest</LangVersion>
21-
</PropertyGroup>
22-
23-
<ItemGroup>
24-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
25-
</ItemGroup>
26-
3+
<PropertyGroup>
4+
<RootNamespace>TurnerSoftware.BuildVersioning</RootNamespace>
5+
6+
<Company>Turner Software</Company>
7+
8+
<PackageId>$(AssemblyName)</PackageId>
9+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
10+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
11+
<PackageIcon>icon.png</PackageIcon>
12+
<PackageReadmeFile>readme.md</PackageReadmeFile>
13+
<PackageProjectUrl>https://github.com/TurnerSoftware/BuildVersioning</PackageProjectUrl>
14+
<PackageBaseTags>semver;semantic;versioning;git</PackageBaseTags>
15+
16+
<!-- SourceLink Support -->
17+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
18+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
19+
<IncludeSymbols>true</IncludeSymbols>
20+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
21+
22+
<LangVersion>Latest</LangVersion>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<None Include="..\..\images\$(PackageIcon)" Pack="true" PackagePath="/" />
31+
<None Include="..\..\readme.md" Pack="true" PackagePath="/" />
32+
</ItemGroup>
33+
2734
</Project>

src/TurnerSoftware.BuildVersioning.Tool/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ static int Main(string[] args)
1212
{
1313
new Option<string>("--full-version-format")
1414
{
15-
Required = true,
15+
IsRequired = true,
1616
Description = "The string to format for the full version."
1717
},
1818
new Option<string>("--file-version-format")
1919
{
20-
Required = true,
20+
IsRequired = true,
2121
Description = "The string to format for the file version."
2222
},
2323
new Option<string>("--assembly-version-format")
2424
{
25-
Required = true,
25+
IsRequired = true,
2626
Description = "The string to format for the assembly version."
2727
},
28-
new Option<string>("--prerelease-format", defaultValue: string.Empty)
28+
new Option<string>("--prerelease-format", () => string.Empty)
2929
{
3030
Description = "The string to format for the pre-release."
3131
},
32-
new Option<string>("--build-metadata-format", defaultValue: string.Empty)
32+
new Option<string>("--build-metadata-format", () => string.Empty)
3333
{
3434
Description = "The string to format for the build metadata."
3535
}
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<AssemblyName>TurnerSoftware.BuildVersioning.Tool</AssemblyName>
5-
<Title>TurnerSoftware.BuildVersioning.Tool</Title>
6-
<Description>Simple build versioning for .NET, powered by Git tags (CLI Tool)</Description>
7-
<PackageTags>$(PackageBaseTags)</PackageTags>
8-
<Authors>James Turner</Authors>
9-
</PropertyGroup>
3+
<PropertyGroup>
4+
<AssemblyName>TurnerSoftware.BuildVersioning.Tool</AssemblyName>
5+
<Title>TurnerSoftware.BuildVersioning.Tool</Title>
6+
<Description>Simple build versioning for .NET, powered by Git tags (CLI Tool)</Description>
7+
<PackageTags>$(PackageBaseTags)</PackageTags>
8+
<Authors>James Turner</Authors>
9+
</PropertyGroup>
1010

11-
<PropertyGroup>
12-
<OutputType>Exe</OutputType>
13-
<TargetFramework>net5.0</TargetFramework>
14-
<BuildVersioningLogLevel>high</BuildVersioningLogLevel>
15-
<RootNamespace>TurnerSoftware.BuildVersioning.Tool</RootNamespace>
16-
<PackAsTool>true</PackAsTool>
17-
<ToolCommandName>buildversioning</ToolCommandName>
18-
</PropertyGroup>
11+
<PropertyGroup>
12+
<OutputType>Exe</OutputType>
13+
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
14+
<BuildVersioningLogLevel>high</BuildVersioningLogLevel>
15+
<RootNamespace>TurnerSoftware.BuildVersioning.Tool</RootNamespace>
16+
<PackAsTool>true</PackAsTool>
17+
<ToolCommandName>buildversioning</ToolCommandName>
18+
</PropertyGroup>
1919

20-
<PropertyGroup>
21-
<BuildVersioningToolPath>$(MSBuildThisFileDirectory)bin/$(Configuration)/$(TargetFramework)/TurnerSoftware.BuildVersioning.Tool.dll</BuildVersioningToolPath>
22-
<SelfHostedBuildVersioning Condition="$(DesignTimeBuild) != 'true' AND $(SkipBuildVersioning) != 'true'">true</SelfHostedBuildVersioning>
23-
</PropertyGroup>
24-
25-
<ItemGroup>
26-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" PrivateAssets="All" />
27-
</ItemGroup>
20+
<PropertyGroup>
21+
<BuildVersioningToolBasePath>$(MSBuildThisFileDirectory)bin/$(Configuration)</BuildVersioningToolBasePath>
22+
<SelfHostedBuildVersioning Condition="$(DesignTimeBuild) != 'true' AND $(SkipBuildVersioning) != 'true'">true</SelfHostedBuildVersioning>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" PrivateAssets="All" />
27+
</ItemGroup>
28+
29+
<!-- Self-hosting Support -->
30+
<Import Project="../TurnerSoftware.BuildVersioning/build/TurnerSoftware.BuildVersioning.targets" Condition="$(SelfHostedBuildVersioning) == 'true'" />
31+
<Target Name="_SelfHostedBuildVersioning" BeforeTargets="BeforeBuild" Condition="$(SelfHostedBuildVersioning) == 'true' AND !Exists($(BuildVersioningToolPath))">
32+
<Message Importance="high" Text="Build Versioning Self-Hosting ($(TargetFramework)): Started" />
33+
<Exec Command="dotnet build TurnerSoftware.BuildVersioning.Tool.csproj -c $(Configuration) -f $(TargetFramework) -v quiet --nologo /p:SkipBuildVersioning=true" StandardOutputImportance="low"></Exec>
34+
<Message Importance="high" Text="Build Versioning Self-Hosting ($(TargetFramework)): Complete" />
35+
</Target>
2836

29-
<!-- Self-hosting Support -->
30-
<Import Project="../TurnerSoftware.BuildVersioning/build/TurnerSoftware.BuildVersioning.targets" Condition="$(SelfHostedBuildVersioning) == 'true'" />
31-
<Target Name="_SelfHostedBuildVersioning" BeforeTargets="BeforeBuild" Condition="$(SelfHostedBuildVersioning) == 'true' AND !Exists($(BuildVersioningToolPath))">
32-
<Message Importance="high" Text="BuildVersioning-SelfHosting: Establishing a baseline build to provide versioning support" />
33-
<Exec Command="dotnet build TurnerSoftware.BuildVersioning.Tool.csproj -c $(Configuration) -v quiet --nologo /p:SkipBuildVersioning=true" StandardOutputImportance="low"></Exec>
34-
<Message Importance="high" Text="BuildVersioning-SelfHosting: Baseline build has been completed" />
35-
</Target>
36-
3737
</Project>
Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<AssemblyName>TurnerSoftware.BuildVersioning</AssemblyName>
5-
<Title>TurnerSoftware.BuildVersioning</Title>
6-
<Description>Simple build versioning for .NET, powered by Git tags</Description>
7-
<PackageTags>$(PackageBaseTags)</PackageTags>
8-
<Authors>James Turner</Authors>
9-
</PropertyGroup>
10-
11-
<PropertyGroup>
12-
<TargetFramework>net5.0</TargetFramework>
13-
<DevelopmentDependency>true</DevelopmentDependency>
14-
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
15-
<IncludeBuildOutput>false</IncludeBuildOutput>
16-
<NoWarn>$(NoWarn);NU5100;NU5104</NoWarn>
17-
<BuildVersioningLogLevel>high</BuildVersioningLogLevel>
18-
<IncludeSymbols>false</IncludeSymbols>
19-
</PropertyGroup>
3+
<PropertyGroup>
4+
<AssemblyName>TurnerSoftware.BuildVersioning</AssemblyName>
5+
<Title>TurnerSoftware.BuildVersioning</Title>
6+
<Description>Simple build versioning for .NET, powered by Git tags</Description>
7+
<PackageTags>$(PackageBaseTags)</PackageTags>
8+
<Authors>James Turner</Authors>
9+
</PropertyGroup>
2010

21-
<PropertyGroup>
22-
<BuildVersioningToolPath>$(MSBuildThisFileDirectory)../TurnerSoftware.BuildVersioning.Tool/bin/$(Configuration)/$(TargetFramework)/TurnerSoftware.BuildVersioning.Tool.dll</BuildVersioningToolPath>
23-
</PropertyGroup>
11+
<PropertyGroup>
12+
<TargetFramework>net6.0</TargetFramework>
13+
<DevelopmentDependency>true</DevelopmentDependency>
14+
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
15+
<IncludeBuildOutput>false</IncludeBuildOutput>
16+
<NoWarn>$(NoWarn);NU5100;NU5104</NoWarn>
17+
<BuildVersioningLogLevel>high</BuildVersioningLogLevel>
18+
<IncludeSymbols>false</IncludeSymbols>
19+
</PropertyGroup>
2420

25-
<Import Project="build/TurnerSoftware.BuildVersioning.targets" />
21+
<PropertyGroup>
22+
<BuildVersioningToolBasePath>$(MSBuildThisFileDirectory)../TurnerSoftware.BuildVersioning.Tool/bin/$(Configuration)</BuildVersioningToolBasePath>
23+
</PropertyGroup>
2624

27-
<ItemGroup>
28-
<ProjectReference Include="..\TurnerSoftware.BuildVersioning.Tool\TurnerSoftware.BuildVersioning.Tool.csproj" PrivateAssets="All" />
29-
</ItemGroup>
25+
<Import Project="build/TurnerSoftware.BuildVersioning.targets" />
26+
27+
<ItemGroup>
28+
<ProjectReference Include="..\TurnerSoftware.BuildVersioning.Tool\TurnerSoftware.BuildVersioning.Tool.csproj" PrivateAssets="All" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<Content Include="buildMultiTargeting\*" Pack="true" PackagePath="buildMultiTargeting" />
33+
<Content Include="build\*" Pack="true" PackagePath="build" />
34+
<None Include="$(BuildVersioningToolBasePath)/net5.0/*" Exclude="**/*.dev.json;**/*.exe" Pack="true" PackagePath="tools/net5.0" LinkBase="tools/net5.0" />
35+
<None Include="$(BuildVersioningToolBasePath)/net6.0/*" Exclude="**/*.dev.json;**/*.exe" Pack="true" PackagePath="tools/net6.0" LinkBase="tools/net6.0" />
36+
</ItemGroup>
3037

31-
<ItemGroup>
32-
<Content Include="buildMultiTargeting\*" Pack="true" PackagePath="buildMultiTargeting" />
33-
<Content Include="build\*" Pack="true" PackagePath="build" />
34-
<None Include="$(OutputPath)/*" Exclude="$(OutputPath)/*.dev.json;$(OutputPath)/TurnerSoftware.BuildVersioning.dll;$(OutputPath)/TurnerSoftware.BuildVersioning.pdb;$(OutputPath)/TurnerSoftware.BuildVersioning.deps.json" Pack="true" PackagePath="tools" />
35-
</ItemGroup>
3638
</Project>

0 commit comments

Comments
 (0)