Skip to content

Commit 7363854

Browse files
committed
add an error that prevents usage on unsupported SDKs
1 parent 3cb6722 commit 7363854

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Microsoft.NET.Build.Containers/build/Microsoft.NET.Build.Containers.targets

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
<Project>
2-
<Target Name="_ContainerVerifySDKVersion">
2+
<Target Name="_ContainerVerifySDKVersion"
3+
Condition="'$(WebPublishMethod)' == 'Container' or '$(PublishProfile)' == 'DefaultContainer'"
4+
BeforeTargets="AfterPublish">
5+
<!-- If the user has opted into container publishing via their own profile (WebPublishMethod = Container) or
6+
via the default Profile (PublishProfile = DefaultContainer), make sure they're on a supported SDK version.
7+
We do the explicit profile name check here because for preview6 for example the profile didn't exist, so we
8+
can't rely only on the WebPublishMethod. -->
39
<PropertyGroup>
4-
<_IsAllowedVersion Condition="$(NETCoreSdkVersion.StartsWith('7.0.100-preview.7')) or $(NETCoreSdkVersion.StartsWith('7.0.100-rc')) or $(NETCoreSdkVersion.StartsWith('7.0.100'))">true</_IsAllowedVersion>
10+
<!-- Allow preview 7, any RC, or any stable version of 7 -->
11+
<_IsAllowedVersion Condition="$(NETCoreSdkVersion.StartsWith('7.0.100-preview.7')) or $(NETCoreSdkVersion.StartsWith('7.0.100-rc')) or ($(NETCoreSdkVersion.StartsWith('7.0.10')) and $(NETCoreSdkVersion.Contains('-')) == false)">true</_IsAllowedVersion>
512
</PropertyGroup>
6-
<Error Code="CONTAINER002" Text="The current .NET SDK \($(NETCoreSdkVersion)\) doesn't support containerization. Please use version 7.0.100-preview.7 or higher." />
13+
<Error Condition="'$(_IsAllowedVersion)' != 'true'" Code="CONTAINER002" Text="The current .NET SDK ($(NETCoreSdkVersion)) doesn't support containerization. Please use version 7.0.100-preview.7 or higher." />
714
</Target>
815

916
<Target Name="ComputeContainerConfig">

0 commit comments

Comments
 (0)