-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectory.Build.targets
39 lines (34 loc) · 1.91 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<Project>
<ItemGroup>
<None Include="$(MSBuildProjectDirectory)/../README.md" Exclude="@(None)" Pack="true" PackagePath="/" Condition="$(IsPackable)" />
<Content Include="$(MSBuildProjectDirectory)/Build/**" Exclude="@(Content)" Pack="true" PackagePath="build/%(RecursiveDir)" Condition="$(IsPackable)" />
<Content Include="$(MSBuildProjectDirectory)/Sdk/**" Exclude="@(Content)" Pack="true" PackagePath="sdk/%(RecursiveDir)" Condition="$(IsPackable)" />
</ItemGroup>
<Target Name="GetPackage"
DependsOnTargets="$(PackDependsOn)"
Returns="@(_GetPackageOutput)"
Condition="'$(IsPackable)' == 'true'">
<ItemGroup>
<_GetPackageOutput Include="@(NuGetPackOutput->WithMetadataValue('Extension', '.nupkg'))">
<PackageId>$(PackageId)</PackageId>
<PackageVersion>$(PackageVersion)</PackageVersion>
</_GetPackageOutput>
</ItemGroup>
</Target>
<Target Name="_ValidatePackageForRelease"
Condition="'$(IsPackable)' == 'true'">
<Error Condition="$(Configuration) != 'Release'" Text="Cannot push package when Configuration is not 'Release'" />
<Error Condition="!$(PackageId.StartsWith('Linkoid.Build.'))" Text="PackageId does not start with 'Linkoid.Build.'" />
<Error Condition="!Exists(@(None->WithMetadataValue('Filename', 'README')))" Text="Missing the README" />
<Error Condition="'$(Description)' == ''" Text="Missing Description" />
</Target>
<Target Name="NuGetPush"
DependsOnTargets="_ValidatePackageForRelease;GetPackage"
Condition="'$(IsPackable)' == 'true'">
<PropertyGroup>
<NuGetPushSource Condition="'$(NuGetPushSource)' == ''">$(DefaultPushSource)</NuGetPushSource>
<NuGetPushSource Condition="'$(NuGetPushSource)' == ''">nuget.org</NuGetPushSource>
</PropertyGroup>
<Exec Command="dotnet nuget push @(_GetPackageOutput) -s $(NuGetPushSource) --skip-duplicate" />
</Target>
</Project>