Skip to content

Allow Implicit RID Opt Out + Don't Infer RID for non EXE Type Projects #28628

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
merged 11 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -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 @@ -65,6 +65,8 @@ Copyright (c) .NET Foundation. All rights reserved.
(
'$(RuntimeIdentifier)' == '' and
'$(RuntimeIdentifiers)' == '' and
'$(_IsExecutable)' == 'true' and
'$(DisableImplicitRuntimeIdentifier)' == '' and
(
'$(SelfContained)' == 'true' or
'$(PublishReadyToRun)' == 'true' or
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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 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)
{
}

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

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

}

}
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 @@ -193,6 +193,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["DisableImplicitRuntimeIdentifier"] = "true";

var testAsset = _testAssetsManager.CreateTestProject(testProject);

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

[Fact]
public void DuplicateRuntimeIdentifiers()
{
Expand Down