Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -11,10 +11,23 @@ Copyright (c) .NET Foundation. All rights reserved.
-->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>

<!-- Analysis level is a single property that can be used to control both the compiler warning waves
and enable .NET analyzers -->
<AnalysisLevel Condition="'$(AnalysisLevel)' == '' And
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0'))">5.0</AnalysisLevel>

<!-- EnableNETAnalyzers Allows analyzes to be disabled in bulk via msbuild if the user wants to -->
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers )' == '' And
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0'))">true</EnableNETAnalyzers>
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0')) And
$([MSBuild]::VersionGreaterThanOrEquals($(AnalysisLevel), '5.0'))">true</EnableNETAnalyzers>
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers )' == ''">false</EnableNETAnalyzers>

<!-- Compiler warning level, defaulted to 4. We promote it to 5 if the user has set analysis level to 5 or higher -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the user has set analysis level to 5 or higher

It's not necessarily that the user has explicitly set the analysis level, right? It could also be implicit based on the TargetFramework, right?

Copy link
Contributor Author

@jmarolf jmarolf Jul 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. If the TFM is .NET 5 we set if automatically

<WarningLevel Condition="'$(AnalysisLevel)' != '' And
$([MSBuild]::VersionGreaterThanOrEquals($(AnalysisLevel), '5.0'))">5</WarningLevel>
</PropertyGroup>
<Import Project="..\analyzers\build\Microsoft.CodeAnalysis.NetAnalyzers.targets"
Condition="$(EnableNETAnalyzers)" />
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/EndToEnd.Tests/GivenDotNetUsesMSBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public GivenDotNetUsesMSBuild(ITestOutputHelper log) : base(log)
{
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
{
string projectDirectory = _testAssetsManager.CreateTestDirectory().Path;
Expand Down Expand Up @@ -52,7 +52,7 @@ public void ItCanNewRestoreBuildRunCleanMSBuildProject()
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void ItCanRunToolsInACSProj()
{
var testInstance = _testAssetsManager.CopyTestAsset("MSBuildTestApp")
Expand Down Expand Up @@ -87,7 +87,7 @@ public void ItCanRunToolsInACSProj()
.HaveStdOutContaining("Hello Portable World!");;
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresADifferentRuntime()
{
var testInstance = _testAssetsManager.CopyTestAsset("MSBuildTestApp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GivenThatWeHaveAPackageReferenceWithAliases : SdkTest
public GivenThatWeHaveAPackageReferenceWithAliases(ITestOutputHelper log) : base(log)
{ }

[RequiresMSBuildVersionFact("16.7.0")]
[RequiresMSBuildVersionFact("16.8.0")]
public void CanBuildProjectWithPackageReferencesWithConflictingTypes()
{
var targetFramework = "net5.0";
Expand Down Expand Up @@ -59,7 +59,7 @@ public void CanBuildProjectWithPackageReferencesWithConflictingTypes()
.Pass();
}

[RequiresMSBuildVersionFact("16.7.0")]
[RequiresMSBuildVersionFact("16.8.0")]
public void CanBuildProjectWithMultiplePackageReferencesWithAliases()
{
var targetFramework = "net5.0";
Expand Down Expand Up @@ -104,7 +104,7 @@ public void CanBuildProjectWithMultiplePackageReferencesWithAliases()
.Pass();
}

[RequiresMSBuildVersionFact("16.7.0")]
[RequiresMSBuildVersionFact("16.8.0")]
public void CanBuildProjectWithAPackageReferenceWithMultipleAliases()
{
var targetFramework = "net5.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ private void AssertDefinedConstantsOutput(TestAsset testAsset, string targetFram
definedConstants.Should().BeEquivalentTo(new[] { "DEBUG", "TRACE" }.Concat(expectedDefines).ToArray());
}

[WindowsOnlyTheory]
[WindowsOnlyRequiresMSBuildVersionTheory("16.8.0")]
[InlineData("netcoreapp3.1", new[] { "NETCOREAPP", "NETCOREAPP3_1" })]
[InlineData("net5.0", new[] { "NETCOREAPP", "NETCOREAPP3_1", "NET", "NET5_0", "WINDOWS", "WINDOWS7_0" }, "windows", "7.0")]
public void It_can_use_implicitly_defined_compilation_constants(string targetFramework, string[] expectedOutput, string targetPlatformIdentifier = null, string targetPlatformVersion = null)
Expand Down Expand Up @@ -639,7 +639,7 @@ public void It_defines_target_platform_defaults_correctly(string targetFramework
}
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("net5.0")]
[InlineData("netcoreapp3.1")]
public void It_defines_windows_version_default_correctly(string targetFramework)
Expand Down Expand Up @@ -956,7 +956,7 @@ public void It_can_build_with_dynamic_loading_enabled(string targetFramework, st

}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("netcoreapp3.1")]
[InlineData("netcoreapp5.0")]
public void It_makes_RootNamespace_safe_when_project_name_has_spaces(string targetFramework)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void It_errors_when_missing_transitive_windows_target_platform(string pro
.HaveStdOutContaining("NETSDK1136");
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_warns_when_specifying_windows_desktop_sdk()
{
var targetFramework = "net5.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void AddProjectChanges(XDocument project, string childPath = null)
}
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void It_copies_content_transitively()
{
var targetFramework = "net5.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void It_errors_on_nonwindows_with_a_framework_reference(string desktopFra
.HaveStdOutContaining(Strings.WindowsDesktopFrameworkRequiresWindows);
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void It_does_not_download_desktop_targeting_packs_on_unix()
{
const string ProjectName = "NoDownloadTargetingPackTest";
Expand Down Expand Up @@ -154,7 +154,7 @@ public void It_does_not_download_desktop_runtime_packs_on_unix()
.NotHaveSubDirectories($"runtime.{Rid}.microsoft.windowsdesktop.app");
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("net5.0", "TargetPlatformIdentifier", "Windows", "Exe")]
[InlineData("netcoreapp3.1", "UseWindowsForms", "true", "WinExe")]
[InlineData("netcoreapp3.1", "UseWPF", "true", "WinExe")]
Expand Down Expand Up @@ -183,7 +183,7 @@ public void It_infers_WinExe_output_type(string targetFramework, string propName
values.First().Should().Be(expectedOutputType);
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_with_ProjectSdk_set()
{
const string ProjectName = "WindowsDesktopSdkTest_50";
Expand Down Expand Up @@ -212,7 +212,7 @@ public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_with_ProjectSd
.Pass();
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_without_ProjectSdk_set()
{
const string ProjectName = "WindowsDesktopSdkTest_without_ProjectSdk_set";
Expand Down Expand Up @@ -241,7 +241,7 @@ public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_without_Projec
.Pass();
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void When_TargetPlatformVersion_is_set_higher_than_10_It_can_reference_cswinrt_api()
{
const string ProjectName = "WindowsDesktopSdkTest_without_ProjectSdk_set";
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/Microsoft.NET.Build.Tests/KnownRuntimePackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public KnownRuntimePackTests(ITestOutputHelper log) : base(log)
{
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void BuildSucceedsWithRuntimePackWithDifferentLabel()
{
var testProject = new TestProject()
Expand Down Expand Up @@ -137,7 +137,7 @@ private void AddItem(TestAsset testAsset, XElement item)
});
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void ItCanPublishArm64Winforms()
{
var testDirectory = _testAssetsManager.CreateTestDirectory().Path;
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Microsoft.NET.Build.Tests/Net50Targeting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Net50Targeting(ITestOutputHelper log) : base(log)
{
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void Net50TargetFrameworkParsesAsNetCoreAppTargetFrameworkIdentifier()
{
var testProject = new TestProject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void It_errors_when_targetting_netcoreapp_2_x()
.HaveStdOutContaining(Strings.PublishSingleFileRequiresVersion30);
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_for_framework_dependent_apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -193,7 +193,7 @@ public void It_generates_a_single_file_for_framework_dependent_apps()
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_for_self_contained_apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -212,7 +212,7 @@ public void It_generates_a_single_file_for_self_contained_apps()
.NotHaveFiles(unexpectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_with_native_binaries_for_framework_dependent_apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -227,7 +227,7 @@ public void It_generates_a_single_file_with_native_binaries_for_framework_depend
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_with_native_binaries_for_self_contained_apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -242,7 +242,7 @@ public void It_generates_a_single_file_with_native_binaries_for_self_contained_a
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_with_all_content_for_framework_dependent_apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -257,7 +257,7 @@ public void It_generates_a_single_file_with_all_content_for_framework_dependent_
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_with_all_content_for_self_contained_apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -272,7 +272,7 @@ public void It_generates_a_single_file_with_all_content_for_self_contained_apps(
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_including_pdbs()
{
var publishCommand = GetPublishCommand();
Expand All @@ -287,7 +287,7 @@ public void It_generates_a_single_file_including_pdbs()
.OnlyHaveFiles(expectedFiles);
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_excludes_ni_pdbs_from_single_file()
{
var publishCommand = GetPublishCommand();
Expand All @@ -302,7 +302,7 @@ public void It_excludes_ni_pdbs_from_single_file()
.OnlyHaveFiles(expectedFiles);
}

[WindowsOnlyFact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_can_include_ni_pdbs_in_single_file()
{
var publishCommand = GetPublishCommand();
Expand All @@ -317,7 +317,7 @@ public void It_can_include_ni_pdbs_in_single_file()
.OnlyHaveFiles(expectedFiles);
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData(ExcludeNewest, NewestContent)]
[InlineData(ExcludeAlways, AlwaysContent)]
public void It_generates_a_single_file_excluding_content(string exclusion, string content)
Expand All @@ -334,7 +334,7 @@ public void It_generates_a_single_file_excluding_content(string exclusion, strin
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_generates_a_single_file_for_R2R_compiled_Apps()
{
var publishCommand = GetPublishCommand();
Expand All @@ -349,7 +349,7 @@ public void It_generates_a_single_file_for_R2R_compiled_Apps()
.OnlyHaveFiles(expectedFiles);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_does_not_rewrite_the_single_file_unnecessarily()
{
var publishCommand = GetPublishCommand();
Expand All @@ -372,7 +372,7 @@ public void It_does_not_rewrite_the_single_file_unnecessarily()
fileWriteTimeAfterSecondRun.Should().Be(fileWriteTimeAfterFirstRun);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_rewrites_the_apphost_for_single_file_publish()
{
var publishCommand = GetPublishCommand();
Expand All @@ -396,7 +396,7 @@ public void It_rewrites_the_apphost_for_single_file_publish()
singleFileSize.Should().BeGreaterThan(appHostSize);
}

[Fact]
[WindowsOnlyRequiresMSBuildVersionFact("16.8.0")]
public void It_rewrites_the_apphost_for_non_single_file_publish()
{
var publishCommand = GetPublishCommand();
Expand All @@ -420,7 +420,7 @@ public void It_rewrites_the_apphost_for_non_single_file_publish()
appHostSize.Should().BeLessThan(singleFileSize);
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("netcoreapp3.0", false, IncludeDefault)]
[InlineData("netcoreapp3.0", true, IncludeDefault)]
[InlineData("netcoreapp3.1", false, IncludeDefault)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void It_cleans_before_trimmed_single_file_publish()
CheckPublishOutput(publishDir, expectedSingleExeFiles.Append("UserData.txt"), expectedNonSingleExeFiles);
}

[Fact]
[RequiresMSBuildVersionFact("16.8.0")]
public void It_cleans_for_mvc_projects()
{
// Create new mvc app from template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void It_can_publish_readytorun_for_selfcontained_library_projects(string
TestProjectPublishing_Internal("LibraryProject2", targetFramework, isSelfContained:true, makeExeProject: false);
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("net5.0")]
void It_can_publish_readytorun_using_crossgen2(string targetFramework)
{
Expand All @@ -205,7 +205,7 @@ void It_can_publish_readytorun_using_crossgen2(string targetFramework)
TestProjectPublishing_Internal("Crossgen2TestApp", targetFramework, isSelfContained: true, emitNativeSymbols: true, useCrossgen2: true, composite: false);
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("net5.0")]
void It_can_publish_readytorun_using_crossgen2_composite_mode(string targetFramework)
{
Expand All @@ -216,7 +216,7 @@ void It_can_publish_readytorun_using_crossgen2_composite_mode(string targetFrame
TestProjectPublishing_Internal("Crossgen2TestApp", targetFramework, isSelfContained: true, emitNativeSymbols: false, useCrossgen2: true, composite: true);
}

[Theory]
[RequiresMSBuildVersionTheory("16.8.0")]
[InlineData("net5.0")]
public void It_only_supports_selfcontained_when_using_crossgen2(string targetFramework)
{
Expand Down
Loading