diff --git a/src/Containers/Microsoft.NET.Build.Containers/KnownStrings.cs b/src/Containers/Microsoft.NET.Build.Containers/KnownStrings.cs index 7a6ddc08c7c4..075af0a3cec3 100644 --- a/src/Containers/Microsoft.NET.Build.Containers/KnownStrings.cs +++ b/src/Containers/Microsoft.NET.Build.Containers/KnownStrings.cs @@ -27,6 +27,7 @@ public static class Properties public static readonly string ComputeContainerBaseImage = nameof(ComputeContainerBaseImage); public static readonly string ComputeContainerConfig = nameof(ComputeContainerConfig); + public static readonly string _ComputeContainerExecutionArgs = nameof(_ComputeContainerExecutionArgs); public static readonly string AssemblyName = nameof(AssemblyName); public static readonly string ContainerBaseRegistry = nameof(ContainerBaseRegistry); public static readonly string ContainerBaseName = nameof(ContainerBaseName); diff --git a/src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets b/src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets index 2ec6d1664af5..05a779abdb82 100644 --- a/src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets +++ b/src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets @@ -39,9 +39,6 @@ $(RuntimeIdentifier) $(RuntimeIdentifiers) linux-$(NETCoreSdkPortableRuntimeIdentifier.Split('-')[1]) - - <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' == ''">true - <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' != ''">false @@ -97,27 +94,6 @@ latest $([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss')) - - - <_ContainerIsTargetingWindows>false - <_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true - - - /app/ - C:\app\ - - - - - - - - - - - - ContainerUser + In addition, the 'nice' property names are currently set by NuGet Pack targets and so we have to use the private/generic names here. --> <_TrimmedRepositoryUrl Condition="'$(RepositoryType)' == 'git' and '$(PrivateRepositoryUrl)' != '' and $(PrivateRepositoryUrl.EndsWith('.git'))">$(PrivateRepositoryUrl.Substring(0, $(PrivateRepositoryUrl.LastIndexOf('.git')))) @@ -204,6 +180,36 @@ + + + + + <_ContainerIsTargetingWindows>false + <_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true + + + /app/ + C:\app\ + + <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' == ''">true + <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' != ''">false + + + + + ContainerUser + + + + + + + + + + @@ -317,17 +323,9 @@ ContainerRegistry=$(ContainerRegistry); _ContainerImageTags=@(ContainerImageTags, ';'); ContainerRepository=$(ContainerRepository); - ContainerWorkingDirectory=$(ContainerWorkingDirectory); - _ContainerEntrypoint=@(ContainerEntrypoint, ';'); - _ContainerEntrypointArgs=@(ContainerEntrypointArgs, ';'); - _ContainerAppCommand=@(ContainerAppCommand, ';'); - _ContainerAppCommandArgs=@(ContainerAppCommandArgs, ';'); - ContainerAppCommandInstruction=$(ContainerAppCommandInstruction); - _ContainerDefaultArgs=@(ContainerDefaultArgs, ';'); _ContainerLabel=@(ContainerLabel->'%(Identity):%(Value)'); _ContainerPort=@(ContainerPort->'%(Identity):%(Type)'); _ContainerEnvironmentVariables=@(ContainerEnvironmentVariable->'%(Identity):%(Value)'); - ContainerUser=$(ContainerUser); ContainerGenerateLabels=$(ContainerGenerateLabels); ContainerGenerateLabelsImageBaseDigest=$(ContainerGenerateLabelsImageBaseDigest) "/> @@ -359,11 +357,6 @@ - - - - - <_ParsedContainerLabel Condition="'$(_ContainerLabel)' != ':'" @@ -417,5 +410,4 @@ - diff --git a/test/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs b/test/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs index 88518f779397..d796184aa29c 100644 --- a/test/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs +++ b/test/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs @@ -26,8 +26,7 @@ public void CanDeferContainerAppCommand( }, projectName: $"{nameof(CanDeferContainerAppCommand)}_{prop}_{value}_{string.Join("_", expectedAppCommandArgs)}"); using var _ = d; var instance = project.CreateProjectInstance(ProjectInstanceSettings.None); - //Assert.True(instance.Build([ ComputeContainerConfig ], [])); - instance.Build([ ComputeContainerConfig ], []); + instance.Build([ _ComputeContainerExecutionArgs ], []); var computedAppCommand = instance.GetItems(ContainerAppCommand).Select(i => i.EvaluatedInclude); // The test was not testing anything previously, as the list returned was zero length, @@ -36,7 +35,6 @@ public void CanDeferContainerAppCommand( computedAppCommand.Should().BeEquivalentTo(expectedAppCommandArgs); } - public static TheoryData ContainerAppCommands() { char s = Path.DirectorySeparatorChar; @@ -316,7 +314,7 @@ public void CanComputeContainerUser(string tfm, string rid, string? expectedUser }, projectName: $"{nameof(CanComputeContainerUser)}_{tfm}_{rid}_{expectedUser}"); using var _ = d; var instance = project.CreateProjectInstance(ProjectInstanceSettings.None); - instance.Build(new[] { ComputeContainerConfig }, new[] { logger }, null, out var outputs).Should().BeTrue(String.Join(Environment.NewLine, logger.Errors)); + instance.Build(new[] { _ComputeContainerExecutionArgs }, new[] { logger }, null, out var outputs).Should().BeTrue(String.Join(Environment.NewLine, logger.Errors)); var computedTag = instance.GetProperty("ContainerUser")?.EvaluatedValue; computedTag.Should().Be(expectedUser); }