Skip to content

Commit

Permalink
Fix dependency version of CI packages + SourceLink infrastructure (#131)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Happypig375 authored Jun 11, 2020
1 parent fe54246 commit 96aef6c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
34 changes: 18 additions & 16 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!--Directory.Build.props: MSBuild properties that are included in every project-->
<!--Info: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019#directorybuildprops-and-directorybuildtargets-->
<Project>
<Project InitialTargets="AppendCISignatureToPackageVersion">
<PropertyGroup Condition="$(MSBuildProjectName.StartsWith('CSharpMath'))"> <!--Don't apply to Typography projects-->
<LangVersion Condition="$(MSBuildProjectExtension) == '.csproj'">8.0</LangVersion> <!--Don't apply to F# projects-->
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>
CA1062,<!--Obsolete with C# 8 nullability annotations-->
CA1303,<!--Who localizes exception messages, anyway?-->
</NoWarn>

<!--Ordered according to https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-->
<!--NuGet properties: Ordered according to https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-->
<PackageId>$(MSBuildProjectName)</PackageId>
<PackageVersion>0.4.2</PackageVersion>
<Authors>CSharpMath Contributors (verybadcat, Happypig375, charlesroddie, FoggyFinder)</Authors>
Expand All @@ -32,9 +32,13 @@
<RepositoryUrl>https://github.com/verybadcat/CSharpMath.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryBranch>master</RepositoryBranch>
<RepositoryCommit>
6678311f2f4f711ce6992e20ea31cd095205f651
</RepositoryCommit>
<!--RepositoryCommit property is set dynamically below-->

<!--SourceLink properties: Ordered according to https://github.com/dotnet/sourcelink#using-source-link-in-net-projects-->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<!--Info on NuGet packaging properties: https://github.com/NuGet/Home/wiki/Adding-nuget-pack-as-a-msbuild-target-->
<GeneratePackageOnBuild Condition="
Expand All @@ -54,19 +58,17 @@
And !$([System.String]::IsNullOrEmpty($(GeneratePackageOnBuild)))
And $(GeneratePackageOnBuild)">
<None Include="$(MSBuildThisFileDirectory)Icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<Target Name="AppendCISignatureToPackageVersion" BeforeTargets="BeforeBuild" Condition="
$(MSBuildProjectName.StartsWith('CSharpMath'))
And !$([System.String]::IsNullOrEmpty($(GeneratePackageOnBuild)))
And $(GeneratePackageOnBuild)
And $(CI)">
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommit" />
<Target Name="AppendCISignatureToPackageVersion" Condition="$(MSBuildProjectName.StartsWith('CSharpMath'))">
<!--Setting StandardOutputImportance to Low ensures that EchoOff works: https://github.com/Microsoft/msbuild/issues/2826-->
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" EchoOff="true" StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="RepositoryCommit" />
</Exec>
<!-- Appending build date and time as metadata for version is blocked on https://github.community/t/bug-nuget-support-build-metadata-properly/117606 -->
<!-- <CreateProperty Value="$(PackageVersion)-ci-$(GitCommit)+$([System.DateTime]::UtcNow.ToString('yyyy.MM.dd-HH.mm.ss'))"> -->
<CreateProperty Value="$(PackageVersion)-ci-$(GitCommit)">
<!-- <CreateProperty Value="$(PackageVersion)-ci-$(RepositoryCommit)+$([System.DateTime]::UtcNow.ToString('yyyy.MM.dd-HH.mm.ss'))"> -->
<CreateProperty Condition="!$([System.String]::IsNullOrEmpty($(CI))) And $(CI)" Value="$(PackageVersion)-ci-$(RepositoryCommit)">
<Output TaskParameter="Value" PropertyName="PackageVersion" />
</CreateProperty>
</Target>
</Project>
</Project>
10 changes: 9 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,15 @@ For those who wish to be even more updated than prereleases, you can opt in to t
<PackageReference Include="PACKAGE" Version="VERSION" />
</ItemGroup>
```
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`.
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`.
### SourceLink for CI packages

Unfortunately, non-NuGet.org feeds do not support `.snupkg`s, so you will have to download all the packages yourself.
1. Go to https://github.com/verybadcat/CSharpMath/actions?query=workflow%3ABuild
2. Open the latest build
3. Download artifacts
4. Extract the files to a folder
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

# Project structure

Expand Down

0 comments on commit 96aef6c

Please sign in to comment.