Skip to content

Commit 6fa2da4

Browse files
committed
Generalise local and CI build experiences
The app can be build with "dotnet" without custom scripts. Packaging and publishing moved into MSBuild targets.
1 parent 013e2be commit 6fa2da4

14 files changed

+267
-180
lines changed

Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<LangVersion>latest</LangVersion>
66
<NoWarn>$(NoWarn);1573;1591;1712</NoWarn>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8+
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
9+
<PackageManagerUIRuntimeIdentifier>win-x86</PackageManagerUIRuntimeIdentifier>
810
</PropertyGroup>
911

1012
<PropertyGroup>
@@ -19,4 +21,15 @@
1921
<PackageVersion>0.0.0.1</PackageVersion>
2022
</PropertyGroup>
2123

24+
<!-- Repo layout -->
25+
<PropertyGroup>
26+
<RepoRoot Condition="'$(RepoRoot)' == ''">$([MSBuild]::NormalizeDirectory('$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'appveyor.yml'))'))</RepoRoot>
27+
28+
<ArtifactsDir Condition="'$(ArtifactsDir)' == ''">$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', '$(Configuration)'))</ArtifactsDir>
29+
<ArtifactsObjDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'obj'))</ArtifactsObjDir>
30+
<ArtifactsBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'bin'))</ArtifactsBinDir>
31+
<ArtifactsTestResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'TestResults'))</ArtifactsTestResultsDir>
32+
<ArtifactsTmpDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'tmp'))</ArtifactsTmpDir>
33+
</PropertyGroup>
34+
2235
</Project>

Directory.Build.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
<Project>
22

3-
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
4-
53
</Project>

Directory.Packages.props

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<!-- To support GitExtensions.Extensibility 0.3.*, see https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1011 -->
6+
<CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
7+
</PropertyGroup>
8+
9+
<!-- Solution dependencies -->
10+
<ItemGroup>
11+
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.2.41" />
12+
<PackageVersion Include="GitExtensions.Extensibility" Version="0.3.*" />
13+
<PackageVersion Include="Neptuo" Version="6.0.2" />
14+
<PackageVersion Include="Neptuo.Exceptions" Version="1.2.2" />
15+
<PackageVersion Include="Neptuo.Observables" Version="2.1.1" />
16+
<PackageVersion Include="NuGet.PackageManagement" Version="6.8.0" />
17+
<PackageVersion Include="System.Resources.Extensions" Version="8.0.0" />
18+
</ItemGroup>
19+
20+
<!-- Test-related -->
21+
<ItemGroup>
22+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
23+
<PackageVersion Include="Moq" Version="4.18.2" />
24+
<PackageVersion Include="MSTest.TestAdapter" Version="2.2.10" />
25+
<PackageVersion Include="MSTest.TestFramework" Version="2.2.10" />
26+
<PackageVersion Include="Appveyor.TestLogger" Version="2.0.0" />
27+
</ItemGroup>
28+
29+
</Project>

GitExtensions.PluginManager.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
44
VisualStudioVersion = 17.5.33130.490
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitExtensions.PluginManager", "src\GitExtensions.PluginManager\GitExtensions.PluginManager.csproj", "{4EB0566E-6D4F-43AF-AA97-2A15ABB66787}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{3B5E3720-B3CB-4A12-B2D4-6BCB6BE78FF1} = {3B5E3720-B3CB-4A12-B2D4-6BCB6BE78FF1}
9+
{B302D166-37CE-439D-8AE1-0CCB80BAD332} = {B302D166-37CE-439D-8AE1-0CCB80BAD332}
10+
{E7AD4376-D8B1-469D-A2E3-38059A5EB152} = {E7AD4376-D8B1-469D-A2E3-38059A5EB152}
11+
EndProjectSection
712
EndProject
813
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PackageManager.UI", "src\PackageManager.UI\PackageManager.UI.csproj", "{6F4FA02A-B061-4607-925E-27B122DE60BC}"
914
EndProject

Packages.props

Lines changed: 0 additions & 22 deletions
This file was deleted.

appveyor.yml

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
#---------------------------------#
2-
# general configuration #
3-
#---------------------------------#
4-
51
# version format
62
version: 3.0.0.{build}
73

4+
matrix:
5+
fast_finish: true
6+
7+
# Build worker image (VM template)
8+
image:
9+
- Visual Studio 2022
10+
811
# version suffix, if any (e.g. '-RC1', '-beta' otherwise '')
912
environment:
1013
version_suffix: ''
@@ -13,17 +16,16 @@ environment:
1316
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
1417
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
1518

16-
1719
# Do not build on tags (GitHub and BitBucket)
1820
skip_tags: true
1921

20-
#---------------------------------#
21-
# environment configuration #
22-
#---------------------------------#
23-
24-
# Build worker image (VM template)
25-
image:
26-
- Visual Studio 2022
22+
# Build settings, not to be confused with "before_build" and "after_build".
23+
# "project" is relative to the original build directory and not influenced by directory changes in "before_build".
24+
build:
25+
# enable MSBuild parallel builds
26+
parallel: true
27+
# MSBuild verbosity level
28+
verbosity: minimal
2729

2830
# enable patching of Directory.Build.props
2931
dotnet_csproj:
@@ -39,21 +41,62 @@ dotnet_csproj:
3941
# build configuration #
4042
#---------------------------------#
4143

44+
install:
45+
- ps: |
46+
# Install the required .NET SDK
47+
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1"
48+
./dotnet-install.ps1 -Channel LTS -InstallDir 'C:\Program Files\dotnet'
49+
# Remove the script so it doesn't "pollute" the build
50+
Remove-Item -Path .\dotnet-install.ps1
51+
4252
build_script:
43-
- ps: .\tools\Prepare-Release.ps1
53+
- ps: |
54+
dotnet restore --verbosity q --nologo /bl:.\artifacts\logs\restore.binlog
55+
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
56+
57+
- ps: |
58+
dotnet build -c Release --verbosity q --nologo /bl:.\artifacts\logs\build.binlog
59+
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
60+
61+
- ps: |
62+
dotnet publish --configuration Release --verbosity q -bl:.\artifacts\logs\publish.binlog
63+
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
4464
4565
#---------------------------------#
4666
# tests configuration #
4767
#---------------------------------#
4868

4969
test_script:
50-
- ps: .\tools\Run-Tests.ps1
70+
- ps: |
71+
dotnet test -c Release --no-restore --no-build --nologo --verbosity q --test-adapter-path:. --logger:Appveyor --logger:trx /bl:.\artifacts\logs\tests.binlog
72+
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
5173
5274
#---------------------------------#
5375
# artifacts configuration #
5476
#---------------------------------#
5577

5678
artifacts:
57-
- path: .\GitExtensions.PluginManager.*.zip
58-
- path: .\GitExtensions.PluginManager.*.nupkg
59-
- path: .\*.binlog
79+
- path: .\artifacts\GitExtensions.PluginManager.*.zip
80+
- path: .\artifacts\GitExtensions.PluginManager.*.nupkg
81+
- path: .\artifacts\logs\*.binlog
82+
83+
84+
# on build failure
85+
on_failure:
86+
- ps: |
87+
Get-ChildItem -recurse artifacts\Release\TestsResults\*.trx -ErrorAction SilentlyContinue `
88+
| ForEach-Object {
89+
Push-AppveyorArtifact "$_"
90+
}
91+
- ps: |
92+
Get-ChildItem -recurse artifacts\Release\TestsResults\*.trx | `
93+
ForEach-Object {
94+
$file = $_.FullName.Replace('[', '``[').Replace(']', '``]')
95+
#Write-Output "Processing $file"
96+
97+
[xml]$xml = Get-Content -Path $file
98+
$xml.TestRun.Results.UnitTestResult | Where-Object outcome -eq 'Failed' | ForEach-Object {
99+
$errorMessage = "$($_.Output.ErrorInfo.Message)`r`n$($_.Output.ErrorInfo.StackTrace)`r`n"
100+
Write-Host $errorMessage -ForegroundColor Red
101+
}
102+
}
Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="$(MSBuildProjectDirectory)\Project.Publish.targets" />
23

34
<PropertyGroup>
45
<UseWindowsForms>true</UseWindowsForms>
@@ -9,12 +10,7 @@
910
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
1011
<NuspecFile>$(MSBuildThisFileDirectory)$(MSBuildProjectName).nuspec</NuspecFile>
1112
<NoWarn>1701;1702;NU5100;NU5101;NU5103;NU5128</NoWarn>
12-
</PropertyGroup>
13-
14-
<PropertyGroup>
15-
<PackageManagerTargetPath>PackageManager\PackageManager.UI.exe</PackageManagerTargetPath>
16-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
17-
<PackageManagerSourcePath>..\PackageManager.UI\bin\$(Configuration)\$(TargetFramework)\publish\PackageManager.UI.exe</PackageManagerSourcePath>
13+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
1814
</PropertyGroup>
1915

2016
<ItemGroup>
@@ -37,7 +33,8 @@
3733
</ItemGroup>
3834

3935
<ItemGroup>
40-
<ProjectReference Include="..\PackageManager.UI\PackageManager.UI.csproj" ReferenceOutputAssembly="false" />
36+
<ProjectReference Include="..\PackageManager.UI\PackageManager.UI.csproj"
37+
ReferenceOutputAssembly="false" />
4138
</ItemGroup>
4239

4340
<ItemGroup>
@@ -51,38 +48,10 @@
5148
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
5249
</EmbeddedResource>
5350
</ItemGroup>
54-
55-
<Target Name="CopyPackageManager" AfterTargets="PostBuildEvent">
56-
<Copy SourceFiles="$(PackageManagerSourcePath)" DestinationFiles="$(TargetDir)$(PackageManagerTargetPath)" />
57-
<Copy SourceFiles="$(PackageManagerSourcePath)" DestinationFiles="$(GitExtensionsPluginsPath)\$(ProjectName)\$(PackageManagerTargetPath)" />
58-
</Target>
5951

6052
<Target Name="PreClean" BeforeTargets="Clean">
6153
<Message Text="Deleting PackageManager" Importance="high" />
6254
<Delete Files="$(TargetDir)$(PackageManagerTargetPath)" ContinueOnError="true" />
6355
</Target>
6456

65-
<Target Name="SetPackageProperties" BeforeTargets="GenerateNuspec">
66-
<PropertyGroup>
67-
<NuspecProperties>
68-
id=$(PackageId);
69-
version=$(PackageVersion);
70-
configuration=$(Configuration);
71-
tags=$(PackageTags.Replace(';',' '));
72-
projectUrl=$(PackageProjectUrl);
73-
iconUrl=$(PackageIconUrl);
74-
repositoryUrl=$(RepositoryUrl);
75-
repositoryType=$(RepositoryType);
76-
repositoryCommit=$(RepositoryCommit);
77-
author=$(Authors);
78-
copyright=$(Copyright);
79-
description=$(Description);
80-
targetDir=$(TargetDir);
81-
</NuspecProperties>
82-
</PropertyGroup>
83-
</Target>
84-
85-
<Target Name="Zip" AfterTargets="Pack">
86-
<Exec Command="powershell -ExecutionPolicy Unrestricted $(MSBuildProjectDirectory)\..\..\tools\Zip-GitExtensionsPlugin.ps1 -Version $(PackageVersion) -Configuration $(Configuration)" />
87-
</Target>
88-
</Project>
57+
</Project>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<Project>
2+
<PropertyGroup>
3+
<_PackageManagerFolder>PackageManager</_PackageManagerFolder>
4+
</PropertyGroup>
5+
6+
<!--
7+
============================================================
8+
_CopyPackageManager
9+
10+
Copy PackageManager.UI into GitExtensions.PluginManager so it can get packed and
11+
to Git Extensions shared installation so we can test it locally
12+
============================================================
13+
-->
14+
<Target Name="_CopyPackageManager">
15+
<PropertyGroup>
16+
<_PackageManagerSourcePath>$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'PackageManager.UI', 'bin', '$(Configuration)', '$(TargetFramework)', '$(PackageManagerUIRuntimeIdentifier)', 'publish', 'PackageManager.UI.exe'))</_PackageManagerSourcePath>
17+
<_PackageManagerTargetPath>$(_PackageManagerFolder)\PackageManager.UI.exe</_PackageManagerTargetPath>
18+
</PropertyGroup>
19+
20+
<!-- Copying to we can pack it -->
21+
<Copy SourceFiles="$(_PackageManagerSourcePath)"
22+
DestinationFiles="$(TargetDir)$(_PackageManagerTargetPath)" />
23+
24+
<!-- Copying to Git Extensions shared installation so we can test it locally -->
25+
<Copy SourceFiles="$(_PackageManagerSourcePath)"
26+
DestinationFiles="$(GitExtensionsPluginsPath)\$(ProjectName)\$(_PackageManagerTargetPath)" />
27+
</Target>
28+
29+
<!--
30+
============================================================
31+
_SetPackageProperties
32+
33+
Update nuspec properties.
34+
============================================================
35+
-->
36+
<Target Name="_SetPackageProperties" BeforeTargets="GenerateNuspec">
37+
<PropertyGroup>
38+
<NuspecProperties>
39+
id=$(PackageId);
40+
version=$(PackageVersion);
41+
configuration=$(Configuration);
42+
tags=$(PackageTags.Replace(';',' '));
43+
projectUrl=$(PackageProjectUrl);
44+
iconUrl=$(PackageIconUrl);
45+
repositoryUrl=$(RepositoryUrl);
46+
repositoryType=$(RepositoryType);
47+
repositoryCommit=$(RepositoryCommit);
48+
author=$(Authors);
49+
copyright=$(Copyright);
50+
description=$(Description);
51+
targetDir=$(TargetDir);
52+
</NuspecProperties>
53+
</PropertyGroup>
54+
</Target>
55+
56+
<!--
57+
============================================================
58+
_OverrideGetAbsoluteOutputPathsForPack
59+
60+
Override PackageOutputAbsolutePath to output the nupkg in artifacts folder instead of bin.
61+
============================================================
62+
-->
63+
<Target Name="_OverrideGetAbsoluteOutputPathsForPack" AfterTargets="_GetAbsoluteOutputPathsForPack">
64+
<PropertyGroup>
65+
<!-- Set the nupkg output path, used by GenerateNuspec targets, PackTask task -->
66+
<PackageOutputAbsolutePath>$([MSBuild]::NormalizePath('$(ArtifactsDir)', '..'))</PackageOutputAbsolutePath>
67+
</PropertyGroup>
68+
</Target>
69+
70+
<!--
71+
============================================================
72+
CreatePortable
73+
74+
Creates a portable archive.
75+
============================================================
76+
-->
77+
<Target Name="CreatePortable"
78+
AfterTargets="Publish"
79+
DependsOnTargets="_CopyPackageManager;Pack">
80+
<PropertyGroup>
81+
<_PublishPortableFileName>GitExtensions.PluginManager.$(PackageVersion).zip</_PublishPortableFileName>
82+
<_PublishPortablePath>$([MSBuild]::NormalizePath('$(ArtifactsDir)', '..', '$(_PublishPortableFileName)'))</_PublishPortablePath>
83+
84+
<!-- We want to archive the whole publish folder, so get one level up -->
85+
<_PublishedPath>$([MSBuild]::NormalizeDirectory('$(PublishDir)'))</_PublishedPath>
86+
</PropertyGroup>
87+
<!-- 1. Copy GitExtensions.PluginManager.dll and PackageManager\PackageManager.UI.exe files -->
88+
<Copy
89+
SourceFiles="$(TargetPath)"
90+
DestinationFolder="$(ArtifactsTmpDir)"
91+
ContinueOnError="ErrorAndStop"
92+
/>
93+
<ItemGroup>
94+
<_ZipContent Include="$([MSBuild]::NormalizePath('$(TargetDir)', '$(_PackageManagerFolder)'))\*.*" />
95+
</ItemGroup>
96+
<Copy
97+
SourceFiles="@(_ZipContent)"
98+
DestinationFolder="$(ArtifactsTmpDir)$(_PackageManagerFolder)\%(RecursiveDir)"
99+
ContinueOnError="ErrorAndStop"
100+
/>
101+
102+
<!-- 2. Create a portable archive -->
103+
<ZipDirectory
104+
SourceDirectory="$(ArtifactsTmpDir)"
105+
DestinationFile="$(_PublishPortablePath)"
106+
Overwrite="true"
107+
ContinueOnError="ErrorAndStop"
108+
/>
109+
</Target>
110+
</Project>

src/PackageManager.UI/PackageManager.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<PublishSingleFile>true</PublishSingleFile>
1212
<SelfContained>false</SelfContained>
13-
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
13+
<RuntimeIdentifier>$(PackageManagerUIRuntimeIdentifier)</RuntimeIdentifier>
1414
<PublishReadyToRun>true</PublishReadyToRun>
1515
</PropertyGroup>
1616

0 commit comments

Comments
 (0)