Skip to content

Commit 29991fa

Browse files
surayya-MSbaronfel
andauthored
[DO NOT MERGE] Restore ability for users to consume the containers package easily (#43794)
Co-authored-by: Chet Husk <[email protected]>
1 parent 7e822f0 commit 29991fa

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/Containers/Microsoft.NET.Build.Containers/KnownStrings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ public static class Items
4848

4949
public static class ErrorCodes
5050
{
51+
// current version doesn't support containerization
5152
public static readonly string CONTAINER002 = nameof(CONTAINER002);
53+
// containerimagename rename
5254
public static readonly string CONTAINER003 = nameof(CONTAINER003);
55+
// generic http error
56+
public static readonly string CONTAINER004 = nameof(CONTAINER004);
57+
// don't use the containers package
58+
public static readonly string CONTAINER005 = nameof(CONTAINER005);
5359
public static readonly string CONTAINER1011 = nameof(CONTAINER1011);
5460
public static readonly string CONTAINER1012 = nameof(CONTAINER1012);
5561
public static readonly string CONTAINER1013 = nameof(CONTAINER1013);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
($(_SdkCanPublishWorker) and $(_IsWorkerProject)) or
223223
($(_SdkCanPublishConsole) and '$(EnableSdkContainerSupport)' == 'true')
224224
)"
225+
Code="CONTAINER005"
225226
Text="The $(_ContainersPackageIdentity) NuGet package is explicitly referenced but the current SDK can natively publish the project as a container. Consider removing the package reference to $(_ContainersPackageIdentity) because it is no longer needed." />
226227

227228
<PropertyGroup>

src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ Copyright (c) .NET Foundation. All rights reserved.
5555

5656
<!-- Import targets from Microdoft.NET.Build.Container.targets -->
5757
<PropertyGroup>
58-
<_ContainersTargetsDir Condition=" '$(_ContainersTargetsDir)'=='' ">$(MSBuildThisFileDirectory)..\..\..\Containers\build\</_ContainersTargetsDir>
58+
<_IsNotSetContainersTargetsDir>false</_IsNotSetContainersTargetsDir>
59+
<_IsNotSetContainersTargetsDir Condition=" '$(_ContainersTargetsDir)'=='' ">true</_IsNotSetContainersTargetsDir>
60+
<_ContainersTargetsDir Condition="$(_IsNotSetContainersTargetsDir)">$(MSBuildThisFileDirectory)..\..\..\Containers\build\</_ContainersTargetsDir>
5961
</PropertyGroup>
6062

6163
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Containers\build\Microsoft.NET.Build.Containers.props"
6264
Condition="Exists('$(MSBuildThisFileDirectory)..\..\..\Containers\build\Microsoft.NET.Build.Containers.props')" />
6365

6466
<Import Project="$(_ContainersTargetsDir)Microsoft.NET.Build.Containers.targets"
65-
Condition="Exists('$(_ContainersTargetsDir)Microsoft.NET.Build.Containers.targets') AND '$(TargetFramework)' != ''" />
67+
Condition="$(_IsNotSetContainersTargetsDir) AND Exists('$(_ContainersTargetsDir)Microsoft.NET.Build.Containers.targets') AND '$(TargetFramework)' != ''" />
6668
</Project>

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackage
369369

370370
if (addPackageReference)
371371
{
372-
commandResult.Should().HaveStdOutContaining("warning : The Microsoft.NET.Build.Containers NuGet package is explicitly referenced but the current SDK can natively publish the project as a container. Consider removing the package reference to Microsoft.NET.Build.Containers because it is no longer needed.");
372+
commandResult.Should().HaveStdOutContaining("warning CONTAINER005: The Microsoft.NET.Build.Containers NuGet package is explicitly referenced but the current SDK can natively publish the project as a container. Consider removing the package reference to Microsoft.NET.Build.Containers because it is no longer needed.");
373373
}
374374
else
375375
{

0 commit comments

Comments
 (0)