-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
22 lines (19 loc) · 974 Bytes
/
Directory.Build.targets
File metadata and controls
22 lines (19 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildWarningsAsErrors>$(MSBuildWarningsAsErrors);PO1001</MSBuildWarningsAsErrors>
</PropertyGroup>
<Target Name="BlockUnwantedDependencies" BeforeTargets="PrepareForBuild">
<ItemGroup>
<UnwantedPackages Include="@(PackageReference)"
Condition="'%(PackageReference.Version)' != '' and
$([System.Text.RegularExpressions.Regex]::IsMatch('%(PackageReference.Version)', '^(0\.\d+\.\d+.*|.*-.*)'))" />
</ItemGroup>
<PropertyGroup>
<_WarningMessage>Build blocked: Prerelease or unstable NuGet package</_WarningMessage>
</PropertyGroup>
<Warning File="$(MSBuildProjectFullPath)"
Code="PO1001"
Text="$(_WarningMessage): %(UnwantedPackages.Identity) (%(UnwantedPackages.Version))"
Condition="'@(UnwantedPackages)' != ''" />
</Target>
</Project>