Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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 @@ -70,6 +70,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<_DefaultUserProfileRuntimeStorePath Condition="$([MSBuild]::IsOSPlatform(`Windows`))">$(USERPROFILE)</_DefaultUserProfileRuntimeStorePath>
<_DefaultUserProfileRuntimeStorePath>$([System.IO.Path]::Combine($(_DefaultUserProfileRuntimeStorePath), '.dotnet', 'store'))</_DefaultUserProfileRuntimeStorePath>
<UserProfileRuntimeStorePath Condition="'$(UserProfileRuntimeStorePath)' == ''">$(_DefaultUserProfileRuntimeStorePath)</UserProfileRuntimeStorePath>
<!-- Prevent including the PredefinedCulturesOnly in the runtime config file in .NET 5.0 and below even if it is defined -->
<PredefinedCulturesOnly Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp' Or $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '6.0'))"></PredefinedCulturesOnly>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))">
<PredefinedCulturesOnly Condition="'$(PredefinedCulturesOnly)' == '' and '$(InvariantGlobalization)' == 'true'">true</PredefinedCulturesOnly>
</PropertyGroup>

<!-- Opt into .NET Core resource-serialization strategy by default when targeting frameworks
Expand Down Expand Up @@ -394,6 +400,11 @@ Copyright (c) .NET Foundation. All rights reserved.
Value="$(InvariantGlobalization)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Globalization.PredefinedCulturesOnly"
Condition="'$(PredefinedCulturesOnly)' != ''"
Value="$(PredefinedCulturesOnly)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Net.Http.EnableActivityPropagation"
Condition="'$(HttpActivityPropagationSupport)' != ''"
Value="$(HttpActivityPropagationSupport)"
Expand Down Expand Up @@ -961,7 +972,7 @@ Copyright (c) .NET Foundation. All rights reserved.
============================================================
-->

<UsingTask TaskName="CheckForUnsupportedWinMDReferences" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="CheckForUnsupportedWinMDReferences" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />

<Target Name="_BlockWinMDsOnUnsupportedTFMs"
AfterTargets="PreBuildEvent"
Expand All @@ -972,7 +983,7 @@ Copyright (c) .NET Foundation. All rights reserved.
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
ReferencePaths="@(ReferencePath)"
/>

<NETSdkError Condition="'$(OutputType)' == 'winmdobj'"
ResourceName="WinMDObjNotSupportedOnTargetFramework"
FormatArguments="$(TargetFrameworkMoniker)" />
Expand Down Expand Up @@ -1052,7 +1063,7 @@ Copyright (c) .NET Foundation. All rights reserved.
IsExecutable="$(_IsExecutable)"
ReferencedProjects="@(_MSBuildProjectReferenceExistent)"
/>

</Target>

<!--
Expand Down Expand Up @@ -1105,7 +1116,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup Condition=" '$(ImportWindowsDesktopTargets)' == 'true'">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)../../Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>

<!-- Note: Once WindowsDesktop is a workload this will be moved to WorkloadManifest.targets -->
<ItemGroup Condition="'$(MicrosoftNETWindowsWorkloadInstalled)' == 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ internal static List<string> GetValuesFromTestLibrary(
ITestOutputHelper log,
TestAssetsManager testAssetsManager,
string itemTypeOrPropertyName,
Action<GetValuesCommand> setup = null,
Action<GetValuesCommand> setup = null,
string[] msbuildArgs = null,
GetValuesCommand.ValueType valueType = GetValuesCommand.ValueType.Item,
[CallerMemberName] string callingMethod = "",
GetValuesCommand.ValueType valueType = GetValuesCommand.ValueType.Item,
[CallerMemberName] string callingMethod = "",
Action<XDocument> projectChanges = null,
string identifier = null)
{
Expand Down Expand Up @@ -316,14 +316,14 @@ public void It_implicitly_defines_compilation_constants_for_the_configuration(st
[InlineData("netstandard1.6", new[] { "NETSTANDARD", "NETSTANDARD1_6", "NETSTANDARD1_0_OR_GREATER", "NETSTANDARD1_1_OR_GREATER", "NETSTANDARD1_2_OR_GREATER",
"NETSTANDARD1_3_OR_GREATER", "NETSTANDARD1_4_OR_GREATER", "NETSTANDARD1_5_OR_GREATER", "NETSTANDARD1_6_OR_GREATER" })]
[InlineData("net45", new[] { "NETFRAMEWORK", "NET45", "NET20_OR_GREATER", "NET30_OR_GREATER", "NET35_OR_GREATER", "NET40_OR_GREATER", "NET45_OR_GREATER" })]
[InlineData("net461", new[] { "NETFRAMEWORK", "NET461", "NET20_OR_GREATER", "NET30_OR_GREATER", "NET35_OR_GREATER", "NET40_OR_GREATER", "NET45_OR_GREATER",
[InlineData("net461", new[] { "NETFRAMEWORK", "NET461", "NET20_OR_GREATER", "NET30_OR_GREATER", "NET35_OR_GREATER", "NET40_OR_GREATER", "NET45_OR_GREATER",
"NET451_OR_GREATER", "NET452_OR_GREATER", "NET46_OR_GREATER", "NET461_OR_GREATER" })]
[InlineData("net48", new[] { "NETFRAMEWORK", "NET48", "NET20_OR_GREATER", "NET30_OR_GREATER", "NET35_OR_GREATER", "NET40_OR_GREATER", "NET45_OR_GREATER",
[InlineData("net48", new[] { "NETFRAMEWORK", "NET48", "NET20_OR_GREATER", "NET30_OR_GREATER", "NET35_OR_GREATER", "NET40_OR_GREATER", "NET45_OR_GREATER",
"NET451_OR_GREATER", "NET452_OR_GREATER", "NET46_OR_GREATER", "NET461_OR_GREATER", "NET462_OR_GREATER", "NET47_OR_GREATER", "NET471_OR_GREATER", "NET472_OR_GREATER", "NET48_OR_GREATER" })]
[InlineData("netcoreapp1.0", new[] { "NETCOREAPP", "NETCOREAPP1_0", "NETCOREAPP1_0_OR_GREATER" })]
[InlineData("netcoreapp3.0", new[] { "NETCOREAPP", "NETCOREAPP3_0", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER",
[InlineData("netcoreapp3.0", new[] { "NETCOREAPP", "NETCOREAPP3_0", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER",
"NETCOREAPP2_1_OR_GREATER", "NETCOREAPP2_2_OR_GREATER", "NETCOREAPP3_0_OR_GREATER" })]
[InlineData("net5.0", new[] { "NETCOREAPP", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER", "NETCOREAPP2_1_OR_GREATER",
[InlineData("net5.0", new[] { "NETCOREAPP", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER", "NETCOREAPP2_1_OR_GREATER",
"NETCOREAPP2_2_OR_GREATER", "NETCOREAPP3_0_OR_GREATER", "NETCOREAPP3_1_OR_GREATER", "NET", "NET5_0", "NET5_0_OR_GREATER" })]
[InlineData(".NETPortable,Version=v4.5,Profile=Profile78", new string[] { })]
[InlineData(".NETFramework,Version=v4.0,Profile=Client", new string[] { "NETFRAMEWORK", "NET40", "NET20_OR_GREATER", "NET30_OR_GREATER", "NET35_OR_GREATER", "NET40_OR_GREATER" })]
Expand Down Expand Up @@ -366,7 +366,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_framework
targetFrameworkProperties.Single().SetValue(targetFramework);
}
});

var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, "TestLibrary");

var getValuesCommand = new GetValuesCommand(Log, libraryProjectDirectory,
Expand Down Expand Up @@ -423,7 +423,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform(
}
});

AssertDefinedConstantsOutput(testAsset, targetFramework,
AssertDefinedConstantsOutput(testAsset, targetFramework,
new[] { "NETCOREAPP", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER", "NETCOREAPP2_1_OR_GREATER", "NETCOREAPP2_2_OR_GREATER", "NETCOREAPP3_0_OR_GREATER", "NETCOREAPP3_1_OR_GREATER", "NET", "NET5_0", "NET5_0_OR_GREATER" }
.Concat(expectedDefines).ToArray());
}
Expand Down Expand Up @@ -841,6 +841,59 @@ public void It_marks_package_references_as_externally_resolved(bool? markAsExter
}
}

[Theory]
[InlineData("net5.0", false, false, false, null)] // Pre .NET 6.0 predefinedCulturesOnly not supported.
[InlineData("net5.0", true, false, false, null)] // Pre .NET 6.0 predefinedCulturesOnly not supported.
[InlineData("net5.0", false, true, true, null)] // Pre .NET 6.0 predefinedCulturesOnly not supported.
[InlineData("net5.0", true, true, true, null)] // Pre .NET 6.0 predefinedCulturesOnly not supported.
[InlineData("net6.0", false, false, false, null)] // predefinedCulturesOnly will not be included in the runtime config file if invariant is not defined.
[InlineData("net6.0", false, false, true, "False")] // predefinedCulturesOnly explicitly defined as false.
[InlineData("net6.0", false, true, true, "True")] // predefinedCulturesOnly explicitly defined as true.
[InlineData("net6.0", true, false, false, "True")] // predefinedCulturesOnly default value is true when Invariant is true.
[InlineData("net6.0", true, false, true, "False")] // predefinedCulturesOnly explicitly defined as false.
[InlineData("net6.0", true, true, true, "True")] // predefinedCulturesOnly explicitly defined as true.
public void It_can_implicitly_define_predefined_Cultures_only(string targetFramework, bool invariantValue, bool predefinedCulturesOnlyValue, bool definePredefinedCulturesOnly, string expectedPredefinedValue)
{
var testProj = new TestProject()
{
Name = "CheckPredefineCulturesOnly",
TargetFrameworks = targetFramework,
IsExe = true,
};

testProj.AdditionalProperties["InvariantGlobalization"] = invariantValue ? "true" : "false";

if (definePredefinedCulturesOnly)
{
testProj.AdditionalProperties["PredefinedCulturesOnly"] = predefinedCulturesOnlyValue ? "true" : "false";
}

var testAsset = _testAssetsManager.CreateTestProject(testProj, identifier: $"{targetFramework}{invariantValue}{predefinedCulturesOnlyValue}{definePredefinedCulturesOnly}");
var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
.Should()
.Pass();

string runtimeConfigName = $"{testProj.Name}.runtimeconfig.json";
var outputDirectory = buildCommand.GetOutputDirectory(testProj.TargetFrameworks);
outputDirectory.Should().HaveFile(runtimeConfigName);

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, runtimeConfigName);
string runtimeConfigContents = File.ReadAllText(runtimeConfigFile);
JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
JToken predefinedCulturesOnly = runtimeConfig["runtimeOptions"]["configProperties"]["System.Globalization.PredefinedCulturesOnly"];

if (expectedPredefinedValue is null)
{
predefinedCulturesOnly.Should().BeNull();
}
else
{
predefinedCulturesOnly.Value<string>().Should().Be(expectedPredefinedValue);
}
}

[Theory]
[InlineData("netcoreapp2.2", null, false, null, false)]
[InlineData("netcoreapp3.0", null, true, null, true)]
Expand Down Expand Up @@ -905,8 +958,6 @@ public void It_can_build_with_dynamic_loading_enabled(string targetFramework, st
{
rollForward.Should().BeNull();
}


}

[Theory]
Expand Down