Skip to content

Commit

Permalink
Merge pull request #135 from dotnet/sdk-version-warning
Browse files Browse the repository at this point in the history
Add a build error if building on an unsupported SDK
  • Loading branch information
baronfel committed Aug 26, 2022
2 parents 0da9eb1 + 7363854 commit 11dc555
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<Project>
<Target Name="_ContainerVerifySDKVersion"
Condition="'$(WebPublishMethod)' == 'Container' or '$(PublishProfile)' == 'DefaultContainer'"
BeforeTargets="AfterPublish">
<!-- If the user has opted into container publishing via their own profile (WebPublishMethod = Container) or
via the default Profile (PublishProfile = DefaultContainer), make sure they're on a supported SDK version.
We do the explicit profile name check here because for preview6 for example the profile didn't exist, so we
can't rely only on the WebPublishMethod. -->
<PropertyGroup>
<!-- Allow preview 7, any RC, or any stable version of 7 -->
<_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>
</PropertyGroup>
<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." />
</Target>

<Target Name="ComputeContainerConfig">
<!-- Reference data about this project -->
<PropertyGroup>
Expand Down Expand Up @@ -58,6 +72,7 @@

<PropertyGroup>
<PublishContainerDependsOn>
_ContainerVerifySDKVersion;
ComputeContainerConfig
</PublishContainerDependsOn>
</PropertyGroup>
Expand Down

0 comments on commit 11dc555

Please sign in to comment.