Skip to content

Commit 96aef6c

Browse files
authored
Fix dependency version of CI packages + SourceLink infrastructure (#131)
* Update Directory.Build.props * No limiting to master for now * snupkgs * SourceLink! * Generate a package * Yooooo * dotnet/msbuild#2826 * Comment it * Use preview language features * Limit to master * Revert unintentional change * ReadMe: SourceLink for CI packages * Fix grammar
1 parent fe54246 commit 96aef6c

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

Directory.Build.props

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<!--Directory.Build.props: MSBuild properties that are included in every project-->
22
<!--Info: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019#directorybuildprops-and-directorybuildtargets-->
3-
<Project>
3+
<Project InitialTargets="AppendCISignatureToPackageVersion">
44
<PropertyGroup Condition="$(MSBuildProjectName.StartsWith('CSharpMath'))"> <!--Don't apply to Typography projects-->
5-
<LangVersion Condition="$(MSBuildProjectExtension) == '.csproj'">8.0</LangVersion> <!--Don't apply to F# projects-->
5+
<LangVersion>preview</LangVersion>
66
<Nullable>enable</Nullable>
77
<NoWarn>
88
CA1062,<!--Obsolete with C# 8 nullability annotations-->
99
CA1303,<!--Who localizes exception messages, anyway?-->
1010
</NoWarn>
1111

12-
<!--Ordered according to https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-->
12+
<!--NuGet properties: Ordered according to https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-->
1313
<PackageId>$(MSBuildProjectName)</PackageId>
1414
<PackageVersion>0.4.2</PackageVersion>
1515
<Authors>CSharpMath Contributors (verybadcat, Happypig375, charlesroddie, FoggyFinder)</Authors>
@@ -32,9 +32,13 @@
3232
<RepositoryUrl>https://github.com/verybadcat/CSharpMath.git</RepositoryUrl>
3333
<RepositoryType>git</RepositoryType>
3434
<RepositoryBranch>master</RepositoryBranch>
35-
<RepositoryCommit>
36-
6678311f2f4f711ce6992e20ea31cd095205f651
37-
</RepositoryCommit>
35+
<!--RepositoryCommit property is set dynamically below-->
36+
37+
<!--SourceLink properties: Ordered according to https://github.com/dotnet/sourcelink#using-source-link-in-net-projects-->
38+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
39+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
40+
<IncludeSymbols>true</IncludeSymbols>
41+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
3842

3943
<!--Info on NuGet packaging properties: https://github.com/NuGet/Home/wiki/Adding-nuget-pack-as-a-msbuild-target-->
4044
<GeneratePackageOnBuild Condition="
@@ -54,19 +58,17 @@
5458
And !$([System.String]::IsNullOrEmpty($(GeneratePackageOnBuild)))
5559
And $(GeneratePackageOnBuild)">
5660
<None Include="$(MSBuildThisFileDirectory)Icon.png" Pack="true" PackagePath="" />
61+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
5762
</ItemGroup>
58-
<Target Name="AppendCISignatureToPackageVersion" BeforeTargets="BeforeBuild" Condition="
59-
$(MSBuildProjectName.StartsWith('CSharpMath'))
60-
And !$([System.String]::IsNullOrEmpty($(GeneratePackageOnBuild)))
61-
And $(GeneratePackageOnBuild)
62-
And $(CI)">
63-
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true">
64-
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommit" />
63+
<Target Name="AppendCISignatureToPackageVersion" Condition="$(MSBuildProjectName.StartsWith('CSharpMath'))">
64+
<!--Setting StandardOutputImportance to Low ensures that EchoOff works: https://github.com/Microsoft/msbuild/issues/2826-->
65+
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" EchoOff="true" StandardOutputImportance="Low">
66+
<Output TaskParameter="ConsoleOutput" PropertyName="RepositoryCommit" />
6567
</Exec>
6668
<!-- Appending build date and time as metadata for version is blocked on https://github.community/t/bug-nuget-support-build-metadata-properly/117606 -->
67-
<!-- <CreateProperty Value="$(PackageVersion)-ci-$(GitCommit)+$([System.DateTime]::UtcNow.ToString('yyyy.MM.dd-HH.mm.ss'))"> -->
68-
<CreateProperty Value="$(PackageVersion)-ci-$(GitCommit)">
69+
<!-- <CreateProperty Value="$(PackageVersion)-ci-$(RepositoryCommit)+$([System.DateTime]::UtcNow.ToString('yyyy.MM.dd-HH.mm.ss'))"> -->
70+
<CreateProperty Condition="!$([System.String]::IsNullOrEmpty($(CI))) And $(CI)" Value="$(PackageVersion)-ci-$(RepositoryCommit)">
6971
<Output TaskParameter="Value" PropertyName="PackageVersion" />
7072
</CreateProperty>
7173
</Target>
72-
</Project>
74+
</Project>

ReadMe.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,15 @@ For those who wish to be even more updated than prereleases, you can opt in to t
291291
<PackageReference Include="PACKAGE" Version="VERSION" />
292292
</ItemGroup>
293293
```
294-
7. Replace `PACKAGE` in the above file by the package name in the webpage, e.g. `CSharpMath.SkiaSharp`, and `VERSION` by the version in the webpage, e.g. `0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083`. The 40-digit hexadecimal number at the end of the version is the Git commit that was the package was built on. CI versions are after the current version, aka `0.4.1-ci-xxx``0.4.2``0.4.2-ci-xxx`.
294+
7. Replace `PACKAGE` in the above file by the package name in the webpage, e.g. `CSharpMath.SkiaSharp`, and `VERSION` by the version in the webpage, e.g. `0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083`. The 40-digit hexadecimal number at the end of the version is the Git commit that was the package was built on. CI versions for a version are newer than that version, aka chronologically `0.4.1-ci-xxx``0.4.2``0.4.2-ci-xxx`.
295+
### SourceLink for CI packages
296+
297+
Unfortunately, non-NuGet.org feeds do not support `.snupkg`s, so you will have to download all the packages yourself.
298+
1. Go to https://github.com/verybadcat/CSharpMath/actions?query=workflow%3ABuild
299+
2. Open the latest build
300+
3. Download artifacts
301+
4. Extract the files to a folder
302+
5. Add the folder as a local NuGet feed to Visual Studio according to https://docs.microsoft.com/en-gb/nuget/consume-packages/install-use-packages-visual-studio#package-sources
295303

296304
# Project structure
297305

0 commit comments

Comments
 (0)