Skip to content

Commit 80b22bb

Browse files
authored
Merge pull request #396 from dotnet/v0.4
2 parents 1628927 + fd37e94 commit 80b22bb

File tree

7 files changed

+91
-25
lines changed

7 files changed

+91
-25
lines changed

Microsoft.NET.Build.Containers/Microsoft.NET.Build.Containers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<Compile Include="Tasks/ParseContainerProperties.cs" />
3737
<Compile Include="Tasks/CreateNewImage.Interface.cs" />
3838
<Compile Include="Tasks/CreateNewImageToolTask.cs" />
39+
<Compile Include="Tasks/ComputeDotnetBaseImageTag.cs" />
3940
<Compile Include="ContainerHelpers.cs" />
4041
<Compile Include="net472Definitions.cs" />
4142
<Compile Include="VSHostObject.cs" />

Microsoft.NET.Build.Containers/PublicAPI/net472/PublicAPI.Unshipped.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Microsoft.NET.Build.Containers.Port.Type.set -> void
1414
Microsoft.NET.Build.Containers.PortType
1515
Microsoft.NET.Build.Containers.PortType.tcp = 0 -> Microsoft.NET.Build.Containers.PortType
1616
Microsoft.NET.Build.Containers.PortType.udp = 1 -> Microsoft.NET.Build.Containers.PortType
17+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag
18+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.ComputedBaseImageTag.get -> string?
19+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.ComputeDotnetBaseImageTag() -> void
20+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.SdkVersion.get -> string!
21+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.SdkVersion.set -> void
22+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.TargetFrameworkVersion.get -> string!
23+
Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.TargetFrameworkVersion.set -> void
1724
Microsoft.NET.Build.Containers.Tasks.CreateNewImage
1825
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.BaseImageName.get -> string!
1926
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.BaseImageName.set -> void
@@ -56,6 +63,7 @@ Microsoft.NET.Build.Containers.Tasks.CreateNewImage.RuntimeIdentifierGraphPath.g
5663
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.RuntimeIdentifierGraphPath.set -> void
5764
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.WorkingDirectory.get -> string!
5865
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.WorkingDirectory.set -> void
66+
override Microsoft.NET.Build.Containers.Tasks.ComputeDotnetBaseImageTag.Execute() -> bool
5967
override Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ToolName.get -> string!
6068
override Microsoft.NET.Build.Containers.Tasks.CreateNewImage.GenerateCommandLineCommands() -> string!
6169
override Microsoft.NET.Build.Containers.Tasks.CreateNewImage.GenerateFullPathToTool() -> string!

Microsoft.NET.Build.Containers/Registry.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ internal sealed class Registry
2020
private const string DockerContainerV1 = "application/vnd.docker.container.image.v1+json";
2121

2222
/// <summary>
23-
/// Whether we should upload blobs via chunked upload (disabled by default).
23+
/// Whether we should upload blobs via chunked upload (enabled by default, but disabled for certain registries in conjunction with the explicit support check below).
2424
/// </summary>
2525
/// <remarks>
2626
/// Relates to https://github.com/dotnet/sdk-container-builds/pull/383#issuecomment-1466408853
2727
/// </remarks>
2828
private static readonly bool s_chunkedUploadEnabled = bool.TrueString.Equals(
29-
Environment.GetEnvironmentVariable(ContainerHelpers.ChunkedUploadEnabled), StringComparison.OrdinalIgnoreCase);
29+
Environment.GetEnvironmentVariable(ContainerHelpers.ChunkedUploadEnabled) ?? "true", // we want to default this to 'on'
30+
StringComparison.OrdinalIgnoreCase);
3031

3132
/// <summary>
3233
/// The name of the registry, which is the host name, optionally followed by a colon and the port number.
@@ -92,6 +93,16 @@ public bool IsAmazonECRRegistry
9293
}
9394
}
9495

96+
/// <summary>
97+
/// Check to see if the registry is GitHub Packages, which always uses ghcr.io.
98+
/// </summary>
99+
public bool IsGithubPackageRegistry => RegistryName.StartsWith("ghcr.io", StringComparison.Ordinal);
100+
101+
/// <summary>
102+
/// Check to see if the registry is Docker Hub, which uses two well-known domains.
103+
/// </summary>
104+
public bool IsDockerHub => RegistryName.Equals("registry-1.docker.io", StringComparison.Ordinal) || RegistryName.Equals("registry.hub.docker.com", StringComparison.Ordinal);
105+
95106
/// <summary>
96107
/// Check to see if the registry is for Google Artifact Registry.
97108
/// </summary>
@@ -103,9 +114,9 @@ public bool IsGoogleArtifactRegistry {
103114
}
104115

105116
/// <summary>
106-
/// Google Artifact Registry doesn't support chunked upload, but we want the capability check to be agnostic to the target.
117+
/// Google Artifact Registry doesn't support chunked upload, but Amazon ECR, GitHub Packages, and DockerHub do. We want the capability check to be agnostic to the target.
107118
/// </summary>
108-
private bool SupportsChunkedUpload => !IsGoogleArtifactRegistry;
119+
private bool SupportsChunkedUpload => !IsGoogleArtifactRegistry || IsAmazonECRRegistry || IsGithubPackageRegistry || IsDockerHub;
109120

110121
/// <summary>
111122
/// Pushing to ECR uses a much larger chunk size. To avoid getting too many socket disconnects trying to do too many

Microsoft.NET.Build.Containers/Tasks/ComputeDotnetBaseImageTag.cs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
using Microsoft.Build.Framework;
55
using NuGet.Versioning;
6+
#if NETFRAMEWORK
7+
using System.Linq;
8+
#endif
69

710
namespace Microsoft.NET.Build.Containers.Tasks;
811

@@ -73,19 +76,32 @@ public override bool Execute()
7376
return baseImageTag;
7477
}
7578

76-
private string? DetermineLabelBasedOnChannel(int major, int minor, string[] releaseLabels) =>
77-
(releaseLabels) switch
79+
private string? DetermineLabelBasedOnChannel(int major, int minor, string[] releaseLabels) {
80+
// this would be a switch, but we have to support net47s where Range and Index aren't available
81+
if (releaseLabels.Length == 0)
7882
{
79-
[var channel, var bump, ..] when channel is ("rc" or "preview") => $"{major}.{minor}-{channel}.{bump}",
80-
[var channel, ..] => LogInvalidPrereleaseError(channel),
81-
[] => $"{major}.{minor}"
82-
};
83-
84-
private string? LogInvalidPrereleaseError(string channel)
85-
{
86-
Log.LogError(Resources.Strings.InvalidSdkPrereleaseVersion, channel);
87-
return null;
88-
}
89-
90-
83+
return $"{major}.{minor}";
84+
}
85+
else
86+
{
87+
var channel = releaseLabels[0];
88+
if (channel == "rc" || channel == "preview")
89+
{
90+
if (releaseLabels.Length > 1)
91+
{
92+
return $"{major}.{minor}-{channel}.{releaseLabels[1]}";
93+
}
94+
else
95+
{
96+
Log.LogError(Resources.Strings.InvalidSdkPrereleaseVersion, channel);
97+
return null;
98+
}
99+
}
100+
else
101+
{
102+
Log.LogError(Resources.Strings.InvalidSdkPrereleaseVersion, channel);
103+
return null;
104+
}
105+
}
106+
}
91107
}

docs/ReleaseNotes/v0.4.0.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
# Microsoft.NET.Build.Containers v0.4.0
1+
# Microsoft.NET.Build.Containers v0.4.x
22

3-
This is the fourth public release of the .NET SDK containerization feature. This version brings support for
3+
This is the fourth public release of the .NET SDK containerization feature. This version brings the following new features and enhancements:
44

55
* [Improved support for loading images into the local daemon](https://github.com/dotnet/sdk-container-builds/pull/323)
66
* [Predefine Conventional Labels from project metadata](https://github.com/dotnet/sdk-container-builds/pull/307)
77
* [Better error messages when the local daemon isn't available](https://github.com/dotnet/sdk-container-builds/pull/319)
88
* [Defined `NetSdkOCIImageBuild` project capability for projects building the image](https://github.com/dotnet/sdk-container-builds/issues/320)
99
* [Labels and Ports are now read from the underlying config correctly](https://github.com/dotnet/sdk-container-builds/issues/332)
10+
* [Consistent error messages across the .NET CLI and IDE experiences](https://github.com/dotnet/sdk-container-builds/pull/347)
11+
* [Support layer history in created images](https://github.com/dotnet/sdk-container-builds/pull/358)
12+
* [Allow setting the `User` metadata for created images](https://github.com/dotnet/sdk-container-builds/pull/374)
13+
* [Support creating Windows Containers](https://github.com/dotnet/sdk-container-builds/pull/343)
14+
* [Support for .NET 8 conventions around image tags](https://github.com/dotnet/sdk-container-builds/pull/384)
15+
* [Default to rootless execution for .NET 8 and beyond](https://github.com/dotnet/sdk-container-builds/pull/393)
16+
* [Added support for JFrog Artifactory repositories](https://github.com/dotnet/sdk-container-builds/pull/383)
1017

1118
### Special thanks
1219

13-
A big shout-out to [Daniel Kuschny](@danielku15) for his contributions to this release! Daniel investigated and solved some fundamental issues around to how we create archives to send to a local container daemon.
20+
A big shout-out to [Daniel Kuschny](@danielku15) for his contributions to this release! Daniel investigated and solved some fundamental issues around to how we create archives to send to a local container daemon. He also diagnosed and added support for Artifactory JFrog container registries, as well as implemented support for Windows Containers.
1421

1522
To start containerizing your projects, see our [Getting Started](http://github.com/dotnet/sdk-container-builds/blob/main/docs/GettingStarted.md) docs.

packaging/package.csproj

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@
4242
</Target>
4343

4444
<Target Name="AddItemsForPackaging" AfterTargets="Build">
45+
<MSBuild Projects="../Microsoft.NET.Build.Containers/Microsoft.NET.Build.Containers.csproj" Properties="TargetFramework=$(VSCompatTargetFramework)" Targets="ResolveAssemblyReferences">
46+
<Output TaskParameter="TargetOutputs" ItemName="_AllNet472ContainerTaskDependencies" />
47+
</MSBuild>
48+
<ItemGroup>
49+
<NecessaryNet472ContainerTaskDependencies
50+
Include="@(_AllNet472ContainerTaskDependencies)"
51+
Condition="(
52+
$([MSBuild]::ValueOrDefault('%(_AllNet472ContainerTaskDependencies.NuGetPackageId)', '').Contains('NuGet')) or
53+
$([MSBuild]::ValueOrDefault('%(_AllNet472ContainerTaskDependencies.NuGetPackageId)', '').Contains('Newtonsoft'))
54+
) and
55+
%(_AllNet472ContainerTaskDependencies.NuGetIsFrameworkReference) != true" />
56+
</ItemGroup>
4557
<ItemGroup>
4658
<!-- root folder -->
4759
<Content Include="README.md" Pack="true" PackagePath="" />
@@ -56,11 +68,22 @@
5668
<Content Include="@(ContainerLibraryOutput)" Pack="true" PackagePath="containerize/" />
5769

5870
<!-- tasks folder -->
71+
<!-- net7.0 tasks -->
72+
<!-- dependencies -->
73+
<Content Include="$(OutDir)Valleysoft.DockerCredsProvider.dll" Pack="true" PackagePath="tasks/$(TargetFramework)" />
74+
<Content Include="$(OutDir)NuGet.*.dll" Pack="true" PackagePath="tasks/$(TargetFramework)" />
75+
<Content Include="$(OutDir)Newtonsoft.Json.dll" Pack="true" PackagePath="tasks/$(TargetFramework)" />
76+
<!-- runtime deps json -->
77+
<Content Include="../Microsoft.NET.Build.Containers/bin/$(Configuration)/$(TargetFramework)/Microsoft.NET.Build.Containers.deps.json" Pack="true" PackagePath="tasks/$(TargetFramework)" />
78+
<!-- actual DLL -->
5979
<Content Include="@(ContainerLibraryOutput)" Pack="true" PackagePath="tasks/$(TargetFramework)/" />
80+
81+
<!-- net472 tasks -->
82+
<!-- dependencies -->
83+
<Content Include="@(NecessaryNet472ContainerTaskDependencies)" Pack="true" PackagePath="tasks/$(VSCompatTargetFramework)/"/>
84+
<!-- runtime deps json isn't valid for netfx -->
85+
<!-- actual DLL -->
6086
<Content Include="@(ContainerLibraryOutputNet472)" Pack="true" PackagePath="tasks/$(VSCompatTargetFramework)/" />
61-
<Content Include="../Microsoft.NET.Build.Containers/bin/$(Configuration)/$(TargetFramework)/Microsoft.NET.Build.Containers.deps.json" Pack="true" PackagePath="tasks/$(TargetFramework)" />
62-
<Content Include="$(OutDir)Valleysoft.DockerCredsProvider.dll" Pack="true" PackagePath="tasks/$(TargetFramework)" />
63-
<Content Include="../Microsoft.NET.Build.Containers/bin/$(Configuration)/$(VSCompatTargetFramework)/Microsoft.NET.Build.Containers.deps.json" Pack="true" PackagePath="tasks/$(VSCompatTargetFramework)" />
6487

6588
<!-- build folder -->
6689
<Content Include="build/**" Pack="true" PackagePath="build/" />

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "0.4-alpha.{height}",
3+
"version": "0.4",
44
"versionHeightOffset": -1,
55
"nugetPackageVersion": {
66
"semVer": 2

0 commit comments

Comments
 (0)