Skip to content

Commit

Permalink
🖆 Apply kzu/oss template via dotnet-file
Browse files Browse the repository at this point in the history
Fixes #59
  • Loading branch information
kzu committed Dec 9, 2020
1 parent 0ddb8e0 commit 55e25d8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .netconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
weak
[file "src/Directory.Build.props"]
url = https://github.com/kzu/oss/blob/main/src/Directory.Build.props
etag = 5b0cf9c055f179dc0b0f15a7e6dfbc6b8ea4b949eec61c0f3000afa2198970a6
etag = d0b93d7533832a4d62cff69c71540bad3284bf92a7d2096b1a91607d72099d2b
weak
[file "src/Directory.Build.targets"]
url = https://github.com/kzu/oss/blob/main/src/Directory.Build.targets
etag = 6e628510436de9303695f2f8c8fb743b698a0d93adc8e4c127bbbae0f74166b7
etag = 87357cb36379ac589c3981bddec4c5f7f89c55356573bd203acbea4b66fe3427
weak
[file "src/kzu.snk"]
url = https://github.com/kzu/oss/blob/main/src/kzu.snk
Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@

<!-- Generate satellite assemblies using csc.exe to avoid some al.exe issues. See https://github.com/dotnet/msbuild/pull/2726 -->
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>

<!-- See: https://www.cazzulino.com/project-dependencies-as-project-references.html -->
<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>
</PropertyGroup>

<PropertyGroup Label="Version">
Expand Down
31 changes: 24 additions & 7 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<!-- To extend/change the defaults, create a Directory.targets alongside this file -->

<PropertyGroup>
<PropertyGroup Condition="'$(IsPackable)' == ''">
<!-- The Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets unconditionally sets
PackageId=AssemblyName if no PackageId is provided, and then defaults IsPackable=true if
a PackageId is set (?!), meaning that by default everything is packable in Sdk-style
Expand All @@ -13,6 +13,7 @@
IsPackable a more sensible default, making it false if no PackageId was provided at this
point. -->
<IsPackable Condition="'$(PackageId)' == ''">false</IsPackable>
<IsPackable Condition="'$(PackageId)' != ''">true</IsPackable>
</PropertyGroup>

<!-- Microsoft.NET.Sdk\targets\Microsoft.NET.DefaultAssemblyInfo.targets does this and is imported
Expand Down Expand Up @@ -57,19 +58,35 @@
<ProjectProperty Include="RepositoryCommit" />
</ItemGroup>

<!-- Make sure the source control info is available before calling source generators -->
<Target Name="EnsureProjectInformation" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" DependsOnTargets="InitializeSourceControlInformation" />

<Target Name="_InitializeRepositoryProperties"
DependsOnTargets="InitializeSourceControlInformation"
Condition="'$(SourceControlInformationFeatureSupported)' == 'true'">
<PropertyGroup>
</PropertyGroup>
</Target>

<!-- Always append the link to the direct source tree for the current build -->
<Target Name="UpdatePackageMetadata"
BeforeTargets="PrepareForBuild;GetAssemblyVersion;GetPackageMetadata;GenerateNuspec;Pack"
BeforeTargets="PrepareForBuild;GenerateMSBuildEditorConfigFileShouldRun;GetAssemblyVersion;GetPackageMetadata;GenerateNuspec;Pack"
DependsOnTargets="InitializeSourceControlInformation"
Condition="'$(SourceControlInformationFeatureSupported)' == 'true' And
'$(IsPackable)' == 'true' And
'$(RepositoryUrl)' != '' And
'$(SourceRevisionId)' != ''">
'$(IsPackable)' == 'true'">
<PropertyGroup>
<Description>$(Description)
<Description Condition="'$(SourceRevisionId)' != ''">$(Description)

Built from $(RepositoryUrl)/tree/$(SourceRevisionId.Substring(0, 9))</Description>
Built from $(RepositoryUrl)/tree/$(SourceRevisionId.Substring(0, 9))
</Description>
<PackageDescription>$(Description)</PackageDescription>

<!-- The project must specify PublishRepositoryUrl=true in order to publish the URL, in order to prevent inadvertent leak of internal URL. -->
<RepositoryUrl Condition="'$(RepositoryUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(PrivateRepositoryUrl)</RepositoryUrl>
<PackageProjectUrl Condition="'$(PackageProjectUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(RepositoryUrl)</PackageProjectUrl>

<RepositoryCommit Condition="'$(RepositoryCommit)' == ''">$(SourceRevisionId)</RepositoryCommit>
<RepositorySha Condition="'$(SourceRevisionId)' != ''">$(SourceRevisionId.Substring(0, 9))</RepositorySha>
</PropertyGroup>
</Target>

Expand Down

0 comments on commit 55e25d8

Please sign in to comment.