Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

light up container publish for all Exe/WinExe projects by default #47064

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<_ContainerIsTargetingNet8TFM Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '8.0'))">true</_ContainerIsTargetingNet8TFM>
<_ContainerIsSelfContained>false</_ContainerIsSelfContained>
<_ContainerIsSelfContained Condition="'$(SelfContained)' == 'true' or '$(PublishSelfContained)' == 'true'">true</_ContainerIsSelfContained>

<EnableSdkContainerSupport Condition="'$(EnableSdkContainerSupport)' == '' and '$(OutputType)' != 'Library'" >true</EnableSdkContainerSupport>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -235,10 +237,6 @@
)"
Code="CONTAINER005"
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." />

<PropertyGroup>
<EnableSdkContainerSupport Condition="'@(ContainersPackage)' != ''">true</EnableSdkContainerSupport>
</PropertyGroup>
</Target>

<Target Name="_PublishSingleContainer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,10 @@ public async Task EndToEnd_MultiProjectSolution()
.Execute()
.Should().Pass();

// Add 'EnableSdkContainerSupport' property to the ConsoleApp and set TFM
// set TFM for the console app
using (FileStream stream = File.Open(Path.Join(newSolutionDir.FullName, "ConsoleApp", "ConsoleApp.csproj"), FileMode.Open, FileAccess.ReadWrite))
{
XDocument document = await XDocument.LoadAsync(stream, LoadOptions.None, CancellationToken.None);
document
.Descendants()
.First(e => e.Name.LocalName == "PropertyGroup")?
.Add(new XElement("EnableSdkContainerSupport", "true"));
document
.Descendants()
.First(e => e.Name.LocalName == "TargetFramework")
Expand Down Expand Up @@ -452,6 +448,8 @@ public async Task EndToEnd_MultiProjectSolution()
[InlineData("webapi", true)]
[InlineData("worker", false)]
[InlineData("worker", true)]
[InlineData("console", true)]
[InlineData("console", false)]
public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackageReference)
{
DirectoryInfo newProjectDir = new(Path.Combine(TestSettings.TestArtifactsDirectory, $"CreateNewImageTest_{projectType}_{addPackageReference}"));
Expand Down Expand Up @@ -503,7 +501,6 @@ public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackage
var project = XDocument.Load(projectPath);
var ns = project.Root?.Name.Namespace ?? throw new InvalidOperationException("Project file is empty");

project.Root?.Add(new XElement("PropertyGroup", new XElement("EnableSDKContainerSupport", "true")));
project.Save(projectPath);
}

Expand Down Expand Up @@ -677,8 +674,7 @@ public void EndToEnd_NoAPI_Console(string baseImage)
$"/p:ContainerBaseImage={baseImage}",
$"/p:ContainerRegistry={DockerRegistryManager.LocalRegistry}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={imageTag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={imageTag}")
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
.WithWorkingDirectory(newProjectDir.FullName)
.Execute()
Expand Down Expand Up @@ -718,8 +714,7 @@ public void EndToEnd_SingleArch_NoRid()
"/t:PublishContainer",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={imageTag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={imageTag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();
commandResult.Should().Pass();
Expand Down Expand Up @@ -754,8 +749,7 @@ public void EndToEndMultiArch_LocalRegistry(string imageName)
"/p:RuntimeIdentifiers=\"linux-x64;linux-arm64\"",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={tag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={tag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();

Expand Down Expand Up @@ -818,7 +812,6 @@ public void MultiArchStillAllowsSingleRID()
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={imageTag}",
"/p:EnableSdkContainerSupport=true",
"/bl")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();
Expand Down Expand Up @@ -868,7 +861,6 @@ public void MultiArchStillAllowsSingleRIDUsingJustRIDProperties()
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={imageTag}",
"/p:EnableSdkContainerSupport=true",
"/bl")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();
Expand Down Expand Up @@ -941,8 +933,7 @@ public void EndToEndMultiArch_ArchivePublishing(string imageName)
$"/p:ContainerArchiveOutputPath={archiveOutput}",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={tag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={tag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();

Expand Down Expand Up @@ -1012,8 +1003,7 @@ public void EndToEndMultiArch_RemoteRegistry()
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRegistry={registry}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={imageTag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={imageTag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();

Expand Down Expand Up @@ -1044,7 +1034,7 @@ public void EndToEndMultiArch_RemoteRegistry()
imageFromRegistry)
.Execute()
.Should().Pass();

// Run the containers
ContainerCli.RunCommand(
_testOutput,
Expand Down Expand Up @@ -1087,8 +1077,7 @@ public void EndToEndMultiArch_ContainerRuntimeIdentifiersOverridesRuntimeIdentif
"/p:ContainerRuntimeIdentifiers=linux-arm64",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={imageTag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={imageTag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute();

Expand Down Expand Up @@ -1138,8 +1127,7 @@ public void EndToEndMultiArch_EnvVariables()
"/p:RuntimeIdentifiers=\"linux-x64;linux-arm64\"",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={tag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={tag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute()
.Should().Pass();
Expand Down Expand Up @@ -1203,8 +1191,7 @@ public void EndToEndMultiArch_Ports()
"/p:RuntimeIdentifiers=\"linux-x64;linux-arm64\"",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={tag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={tag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute()
.Should().Pass();
Expand Down Expand Up @@ -1290,8 +1277,7 @@ public void EndToEndMultiArch_Labels()
"/p:RuntimeIdentifiers=\"linux-x64;linux-arm64\"",
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
$"/p:ContainerRepository={imageName}",
$"/p:ContainerImageTag={tag}",
"/p:EnableSdkContainerSupport=true")
$"/p:ContainerImageTag={tag}")
.WithWorkingDirectory(newProjectDir.FullName)
.Execute()
.Should().Pass();
Expand Down
Loading