Skip to content

[automated] Merge branch 'release/7.0.1xx' => 'release/7.0.2xx' #28668

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5548480
Return workload manifests in defined, controllable order
dsplaisted Oct 17, 2022
bcaed25
Don't infer rid on non exe project type
nagilson Oct 17, 2022
a80d6b5
Add opt out feature and tests
nagilson Oct 18, 2022
10c3bc5
Update src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Runt…
nagilson Oct 18, 2022
47c024b
Make it a win only fact
nagilson Oct 18, 2022
0f654d6
Merge branch 'nagilson-exe-rids' of https://github.com/nagilson/sdk i…
nagilson Oct 18, 2022
fb14de3
make the test fail in the old scenario
nagilson Oct 18, 2022
d3ed325
Consider that TestProjects May be Exe Projects without Being Tagged a…
nagilson Oct 18, 2022
d97c27e
Update dependencies from https://github.com/dotnet/fsharp build 20221…
dotnet-maestro[bot] Oct 19, 2022
9299986
Update dependencies from https://github.com/microsoft/vstest build 20…
dotnet-maestro[bot] Oct 19, 2022
b256814
Remove opt out feature and put it into UCR
nagilson Oct 19, 2022
d1c8744
Fix tests. Only thing remaining is to improve test quality
nagilson Oct 19, 2022
141ab83
Merge pull request #28655 from dotnet/darc-release/7.0.1xx-a8bfada8-e…
marcpopMSFT Oct 19, 2022
63b3654
Merge pull request #28627 from dsplaisted/workload-manifest-targets-i…
dsplaisted Oct 19, 2022
a00b2cf
Fix whitespace
nagilson Oct 19, 2022
d3173a2
Fix tests
nagilson Oct 19, 2022
6942fe7
Merge pull request #28628 from nagilson/nagilson-exe-rids
nagilson Oct 20, 2022
24f5a85
Merge branch 'release/7.0.1xx' into release/7.0.2xx
v-wuzhai Oct 20, 2022
f88e36e
Merge remote-tracking branch 'upstream/release/7.0.2xx' into merge/re…
nagilson Oct 31, 2022
2939b90
Account for changes in 7.0.2xx not in 7.0.1xx
nagilson Oct 31, 2022
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
@@ -0,0 +1,8 @@
namespace newc;

static class Program
{
static void Main()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace lib;
public class Class1
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="lib\lib.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using Microsoft.DotNet.Cli;
Expand All @@ -17,7 +18,7 @@ public class SdkDirectoryWorkloadManifestProvider : IWorkloadManifestProvider
private readonly string [] _manifestDirectories;
private static HashSet<string> _outdatedManifestIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "microsoft.net.workload.android", "microsoft.net.workload.blazorwebassembly", "microsoft.net.workload.ios",
"microsoft.net.workload.maccatalyst", "microsoft.net.workload.macos", "microsoft.net.workload.tvos" };
private readonly HashSet<string>? _knownManifestIds;
private readonly Dictionary<string, int>? _knownManifestIdsAndOrder;

public SdkDirectoryWorkloadManifestProvider(string sdkRootPath, string sdkVersion, string? userProfileDir)
: this(sdkRootPath, sdkVersion, Environment.GetEnvironmentVariable, userProfileDir)
Expand All @@ -44,7 +45,12 @@ internal SdkDirectoryWorkloadManifestProvider(string sdkRootPath, string sdkVers
var knownManifestIdsFilePath = Path.Combine(_sdkRootPath, "sdk", sdkVersion, "IncludedWorkloadManifests.txt");
if (File.Exists(knownManifestIdsFilePath))
{
_knownManifestIds = File.ReadAllLines(knownManifestIdsFilePath).Where(l => !string.IsNullOrEmpty(l)).ToHashSet();
_knownManifestIdsAndOrder = new Dictionary<string, int>();
int lineNumber = 0;
foreach (var manifestId in File.ReadAllLines(knownManifestIdsFilePath).Where(l => !string.IsNullOrEmpty(l)))
{
_knownManifestIdsAndOrder[manifestId] = lineNumber++;
}
}

string? userManifestsDir = userProfileDir is null ? null : Path.Combine(userProfileDir, "sdk-manifests", _sdkVersionBand.ToString());
Expand Down Expand Up @@ -126,9 +132,9 @@ public IEnumerable<string> GetManifestDirectories()
}
}

if (_knownManifestIds != null && _knownManifestIds.Any(id => !manifestIdsToDirectories.ContainsKey(id)))
if (_knownManifestIdsAndOrder != null && _knownManifestIdsAndOrder.Keys.Any(id => !manifestIdsToDirectories.ContainsKey(id)))
{
var missingManifestIds = _knownManifestIds.Where(id => !manifestIdsToDirectories.ContainsKey(id));
var missingManifestIds = _knownManifestIdsAndOrder.Keys.Where(id => !manifestIdsToDirectories.ContainsKey(id));
foreach (var missingManifestId in missingManifestIds)
{
var manifestDir = FallbackForMissingManifest(missingManifestId);
Expand All @@ -139,7 +145,21 @@ public IEnumerable<string> GetManifestDirectories()
}
}

return manifestIdsToDirectories.Values;
// Return manifests in a stable order. Manifests in the IncludedWorkloadManifests.txt file will be first, and in the same order they appear in that file.
// Then the rest of the manifests (if any) will be returned in (ordinal case-insensitive) alphabetical order.
return manifestIdsToDirectories
.OrderBy(kvp =>
{
if (_knownManifestIdsAndOrder != null &&
_knownManifestIdsAndOrder.TryGetValue(kvp.Key, out var order))
{
return order;
}
return int.MaxValue;
})
.ThenBy(kvp => kvp.Key, StringComparer.OrdinalIgnoreCase)
.Select(kvp => kvp.Value)
.ToList();
}

private string FallbackForMissingManifest(string manifestId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,20 @@ Copyright (c) .NET Foundation. All rights reserved.
<RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x86' or '$(PlatformTarget)' == ''">win7-x86</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == 'true' or
(
<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == ''">
<UseCurrentRuntimeIdentifier Condition="
'$(RuntimeIdentifier)' == '' and
(
'$(SelfContained)' == 'true' or
'$(PublishReadyToRun)' == 'true' or
'$(PublishSingleFile)' == 'true' or
'$(PublishAot)' == 'true'
)
)">
'$(_IsExecutable)' == 'true' and '$(IsTestProject)' != 'true' and
'$(IsRidAgnostic)' != 'true' and
(
'$(SelfContained)' == 'true' or
'$(PublishReadyToRun)' == 'true' or
'$(PublishSingleFile)' == 'true' or
'$(PublishAot)' == 'true'
)">true</UseCurrentRuntimeIdentifier>
</PropertyGroup>

<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == 'true'">
<RuntimeIdentifier>$(NETCoreSdkPortableRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

Expand Down Expand Up @@ -221,7 +225,7 @@ Copyright (c) .NET Foundation. All rights reserved.
ResourceName="Prefer32BitIgnoredForNetCoreApp" />

<PropertyGroup>
<Prefer32Bit>false</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>

</Target>
Expand All @@ -233,7 +237,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<NETSdkError Condition="'$(PlatformTarget)' != 'AnyCPU' and !$(RuntimeIdentifier.ToUpperInvariant().Contains($(PlatformTarget.ToUpperInvariant())))"
ResourceName="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget"
FormatArguments="$(RuntimeIdentifier);$(PlatformTarget)" />

</Target>

<Target Name="_CheckForLanguageAndFeatureCombinationSupport"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.IO;
using FluentAssertions;
using Microsoft.NET.TestFramework;
using Microsoft.NET.TestFramework.Assertions;
using Microsoft.NET.TestFramework.Commands;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.NET.Publish.Tests
{
public class GivenThatWeWantToPublishASingleFileLibrary : SdkTest
{
public GivenThatWeWantToPublishASingleFileLibrary(ITestOutputHelper log) : base(log)
{
}

[WindowsOnlyFact]
// Tests regression on https://github.com/dotnet/sdk/pull/28484
public void ItPublishesSuccessfullyWithRIDAndPublishSingleFileLibrary()
{
var targetFramework = ToolsetInfo.CurrentTargetFramework;
var testAsset = _testAssetsManager
.CopyTestAsset("AppWithLibrarySDKStyleThatPublishesSingleFile")
.WithTargetFramework(targetFramework)
.WithSource();

var publishCommand = new PublishCommand(testAsset);
publishCommand.Execute()
.Should()
.Pass();

// It would be better if we could somehow check the library binlog or something for a RID instead.
var exeFolder = publishCommand.GetOutputDirectory(targetFramework: targetFramework);
// Parent: RID, then TFM, then Debug, then bin, then the test folder
var ridlessLibraryDllPath = Path.Combine(exeFolder.Parent.Parent.Parent.Parent.FullName, "lib", "bin", "Debug", targetFramework, "lib.dll");
Assert.True(File.Exists(ridlessLibraryDllPath));
}

}

}
24 changes: 24 additions & 0 deletions src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,30 @@ public void PublishWithRuntimeIdentifier(bool publishNoBuild)
}
}

[Fact]
public void ImplicitRuntimeIdentifierOptOutCorrecltyOptsOut()
{
var targetFramework = ToolsetInfo.CurrentTargetFramework;
var runtimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
var testProject = new TestProject()
{
IsExe = true,
TargetFrameworks = targetFramework
};
testProject.AdditionalProperties["SelfContained"] = "true";
testProject.AdditionalProperties["UseCurrentRuntimeIdentifier"] = "false";

var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute()
.Should()
.Fail()
.And
.HaveStdOutContaining("NETSDK1191");
}

[Fact]
public void DuplicateRuntimeIdentifiers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,43 @@ var sdkDirectoryWorkloadManifestProvider
.BeEquivalentTo("6.0.100-preview.4/iOS", "6.0.100/Android");
}

[Fact]
public void ItReturnsManifestsInOrderFromIncludedWorkloadManifestsFile()
{
var testDirectory = _testAssetsManager.CreateTestDirectory().Path;
var fakeDotnetRootDirectory = Path.Combine(testDirectory, "dotnet");

// microsoft.net.workload.mono.toolchain.net6, microsoft.net.workload.mono.toolchain.net7, microsoft.net.workload.emscripten.net6, microsoft.net.workload.emscripten.net7

var currentSdkVersion = "7.0.100";
var fallbackWorkloadBand = "7.0.100-rc.2";

CreateMockManifest(fakeDotnetRootDirectory, currentSdkVersion, "NotInIncudedWorkloadsFile");
CreateMockManifest(fakeDotnetRootDirectory, currentSdkVersion, "Microsoft.Net.Workload.Mono.Toolchain.net6");
CreateMockManifest(fakeDotnetRootDirectory, fallbackWorkloadBand, "Microsoft.Net.Workload.Mono.Toolchain.net7");
CreateMockManifest(fakeDotnetRootDirectory, fallbackWorkloadBand, "Microsoft.Net.Workload.Emscripten.net6");
CreateMockManifest(fakeDotnetRootDirectory, currentSdkVersion, "Microsoft.Net.Workload.Emscripten.net7");

var knownWorkloadsFilePath = Path.Combine(fakeDotnetRootDirectory, "sdk", currentSdkVersion, "IncludedWorkloadManifests.txt");
Directory.CreateDirectory(Path.GetDirectoryName(knownWorkloadsFilePath)!);
File.WriteAllText(knownWorkloadsFilePath, @"
Microsoft.Net.Workload.Mono.Toolchain.net6
Microsoft.Net.Workload.Mono.Toolchain.net7
Microsoft.Net.Workload.Emscripten.net6
Microsoft.Net.Workload.Emscripten.net7"
.Trim());

var sdkDirectoryWorkloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(sdkRootPath: fakeDotnetRootDirectory, sdkVersion: currentSdkVersion, userProfileDir: null);

GetManifestContents(sdkDirectoryWorkloadManifestProvider)
.Should()
.Equal($"{currentSdkVersion}/Microsoft.Net.Workload.Mono.Toolchain.net6",
$"{fallbackWorkloadBand}/Microsoft.Net.Workload.Mono.Toolchain.net7",
$"{fallbackWorkloadBand}/Microsoft.Net.Workload.Emscripten.net6",
$"{currentSdkVersion}/Microsoft.Net.Workload.Emscripten.net7",
$"{currentSdkVersion}/NotInIncudedWorkloadsFile");
}

private void CreateMockManifest(string rootDir, string version, string manifestId)
{
var manifestDirectory = Path.Combine(rootDir, "sdk-manifests", version);
Expand Down