|
1 | 1 | <Project>
|
2 | 2 | <!-- To extend/change the defaults, create a Directory.targets alongside this file -->
|
3 | 3 |
|
4 |
| - <PropertyGroup> |
| 4 | + <PropertyGroup Condition="'$(IsPackable)' == ''"> |
5 | 5 | <!-- The Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets unconditionally sets
|
6 | 6 | PackageId=AssemblyName if no PackageId is provided, and then defaults IsPackable=true if
|
7 | 7 | a PackageId is set (?!), meaning that by default everything is packable in Sdk-style
|
|
13 | 13 | IsPackable a more sensible default, making it false if no PackageId was provided at this
|
14 | 14 | point. -->
|
15 | 15 | <IsPackable Condition="'$(PackageId)' == ''">false</IsPackable>
|
| 16 | + <IsPackable Condition="'$(PackageId)' != ''">true</IsPackable> |
16 | 17 | </PropertyGroup>
|
17 | 18 |
|
18 | 19 | <!-- Microsoft.NET.Sdk\targets\Microsoft.NET.DefaultAssemblyInfo.targets does this and is imported
|
|
57 | 58 | <ProjectProperty Include="RepositoryCommit" />
|
58 | 59 | </ItemGroup>
|
59 | 60 |
|
| 61 | + <!-- Make sure the source control info is available before calling source generators --> |
| 62 | + <Target Name="EnsureProjectInformation" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" DependsOnTargets="InitializeSourceControlInformation" /> |
| 63 | + |
| 64 | + <Target Name="_InitializeRepositoryProperties" |
| 65 | + DependsOnTargets="InitializeSourceControlInformation" |
| 66 | + Condition="'$(SourceControlInformationFeatureSupported)' == 'true'"> |
| 67 | + <PropertyGroup> |
| 68 | + </PropertyGroup> |
| 69 | + </Target> |
| 70 | + |
60 | 71 | <!-- Always append the link to the direct source tree for the current build -->
|
61 | 72 | <Target Name="UpdatePackageMetadata"
|
62 |
| - BeforeTargets="PrepareForBuild;GetAssemblyVersion;GetPackageMetadata;GenerateNuspec;Pack" |
| 73 | + BeforeTargets="PrepareForBuild;GenerateMSBuildEditorConfigFileShouldRun;GetAssemblyVersion;GetPackageMetadata;GenerateNuspec;Pack" |
63 | 74 | DependsOnTargets="InitializeSourceControlInformation"
|
64 | 75 | Condition="'$(SourceControlInformationFeatureSupported)' == 'true' And
|
65 |
| - '$(IsPackable)' == 'true' And |
66 |
| - '$(RepositoryUrl)' != '' And |
67 |
| - '$(SourceRevisionId)' != ''"> |
| 76 | + '$(IsPackable)' == 'true'"> |
68 | 77 | <PropertyGroup>
|
69 |
| - <Description>$(Description) |
| 78 | + <Description Condition="'$(SourceRevisionId)' != ''">$(Description) |
70 | 79 |
|
71 |
| -Built from $(RepositoryUrl)/tree/$(SourceRevisionId.Substring(0, 9))</Description> |
| 80 | +Built from $(RepositoryUrl)/tree/$(SourceRevisionId.Substring(0, 9)) |
| 81 | + </Description> |
72 | 82 | <PackageDescription>$(Description)</PackageDescription>
|
| 83 | + |
| 84 | + <!-- The project must specify PublishRepositoryUrl=true in order to publish the URL, in order to prevent inadvertent leak of internal URL. --> |
| 85 | + <RepositoryUrl Condition="'$(RepositoryUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(PrivateRepositoryUrl)</RepositoryUrl> |
| 86 | + <PackageProjectUrl Condition="'$(PackageProjectUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(RepositoryUrl)</PackageProjectUrl> |
| 87 | + |
| 88 | + <RepositoryCommit Condition="'$(RepositoryCommit)' == ''">$(SourceRevisionId)</RepositoryCommit> |
| 89 | + <RepositorySha Condition="'$(SourceRevisionId)' != ''">$(SourceRevisionId.Substring(0, 9))</RepositorySha> |
73 | 90 | </PropertyGroup>
|
74 | 91 | </Target>
|
75 | 92 |
|
|
0 commit comments