Skip to content

Commit 11dc555

Browse files
authored
Merge pull request #135 from dotnet/sdk-version-warning
Add a build error if building on an unsupported SDK
2 parents 0da9eb1 + 7363854 commit 11dc555

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<Project>
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. -->
9+
<PropertyGroup>
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>
12+
</PropertyGroup>
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." />
14+
</Target>
15+
216
<Target Name="ComputeContainerConfig">
317
<!-- Reference data about this project -->
418
<PropertyGroup>
@@ -58,6 +72,7 @@
5872

5973
<PropertyGroup>
6074
<PublishContainerDependsOn>
75+
_ContainerVerifySDKVersion;
6176
ComputeContainerConfig
6277
</PublishContainerDependsOn>
6378
</PropertyGroup>

0 commit comments

Comments
 (0)