From 8bfbe46009aec72aa0d380c6a241eb50bea1c3a7 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Fri, 21 Apr 2023 17:01:36 -0400 Subject: [PATCH 1/2] Drop dot from default artifacts path --- src/Tasks/Common/Resources/Strings.resx | 4 + src/Tasks/Common/Resources/xlf/Strings.cs.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.de.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.es.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.fr.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.it.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.ja.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.ko.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.pl.xlf | 5 + .../Common/Resources/xlf/Strings.pt-BR.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.ru.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.tr.xlf | 5 + .../Common/Resources/xlf/Strings.zh-Hans.xlf | 5 + .../Common/Resources/xlf/Strings.zh-Hant.xlf | 5 + .../Microsoft.NET.Build.Tasks/sdk/Sdk.props | 6 + .../Microsoft.NET.DefaultArtifactsPath.props | 4 +- .../Microsoft.NET.DefaultOutputPaths.targets | 16 ++ .../ArtifactsOutputPathTests.cs | 221 ++++++++---------- .../OutputPathCalculator.cs | 8 +- 19 files changed, 192 insertions(+), 132 deletions(-) diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index 1c6838b31493..d13b3787c6e2 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -896,4 +896,8 @@ You may need to build the project on another operating system or architecture, o NETSDK1198: A publish profile with the name '{0}' was not found in the project. Set the PublishProfile property to a valid file name. {StrBegin="NETSDK1198: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index 511716afc8fb..6aadbef26104 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -52,6 +52,11 @@ NETSDK1177: Nepovedlo se podepsat hostitele aplikace s kódem chyby {1}: {0}. {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: Když se cílí na .NET Core 3.0 nebo vyšší, balíček Microsoft.AspNetCore.All se nepodporuje. Místo něj by se měl použít odkaz FrameworkReference na Microsoft.AspNetCore.App, který se implicitně zahrne pomocí Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index 5ae8ab4b9c39..4014297667ae 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -52,6 +52,11 @@ NETSDK1177: Fehler beim Signieren von apphost mit Fehlercode {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: Das Paket "Microsoft.AspNetCore.All" wird für .NET Core 3.0 oder höher nicht unterstützt. Verwenden Sie stattdessen eine FrameworkReference auf Microsoft.AspNetCore.App, die daraufhin implizit von Microsoft.NET.Sdk.Web eingeschlossen wird. diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 0642e08f9536..5f22b078e823 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -52,6 +52,11 @@ NETSDK1177: No se pudo firmar apphost con el código de error {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: El paquete Microsoft.AspNetCore.All no se admite cuando el destino es .NET Core 3.0 o posterior. En su lugar, se debe usar un valor de FrameworkReference para Microsoft.AspNetCore.App, y se incluirá implícitamente en Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index ecff09098ba7..bf6b62b0435c 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -52,6 +52,11 @@ NETSDK1177: échec de la signature de apphost avec le code d’erreur {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: le package Microsoft.AspNetCore.All n'est pas pris en charge pour le ciblage de .NET Core 3.0 ou une version ultérieure. Vous devez utiliser à la place un FrameworkReference pour Microsoft.AspNetCore.App. Il est inclus implicitement par Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index defea5964071..42d0c33251de 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -52,6 +52,11 @@ NETSDK1177: impossibile firmare apphost con codice di errore {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: il pacchetto Microsoft.AspNetCore.All non è supportato quando la destinazione è .NET Core 3.0 o versione successiva. È necessario un elemento FrameworkReference per Microsoft.AspNetCore.App, che verrà incluso in modo implicito da Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index f5012b03ba06..49cd74b2827f 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -52,6 +52,11 @@ NETSDK1177: エラー コード {1} が発生して AppHost に署名できませんでした: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: .NET Core 3.0 以上がターゲットの場合、Microsoft.AspNetCore.All パッケージはサポートされていません。代わりに Microsoft.AspNetCore.App への FrameworkReference を使用する必要があり、これは Microsoft.NET.Sdk.Web によって暗黙的に含まれます。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index 3273e9c58118..b7afd45eeb5d 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -52,6 +52,11 @@ NETSDK1177: apphost에 서명하지 못했습니다(오류 코드 {1}: {0}) {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: .NET Core 3.0 이상을 대상으로 할 경우 Microsoft.AspNetCore.All 패키지가 지원되지 않습니다. Microsoft.AspNetCore.App에 대한 FrameworkReference가 대신 사용되어야 하며, Microsoft.NET.Sdk.Web에 의해 암시적으로 포함됩니다. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index b099bc1aca2b..afe037cdb75a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -52,6 +52,11 @@ NETSDK1177: Nie można podpisać hosta aplikacji z kodem błędu {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: Pakiet Microsoft.AspNetCore.All nie jest obsługiwany w przypadku ukierunkowania na program .NET Core w wersji 3.0 lub wyższej. Zamiast tego powinien zostać użyty element FrameworkReference dla pakietu Microsoft.AspNetCore.App, który zostanie niejawnie uwzględniony przez pakiet Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index a1ac39af303e..6100c18bb098 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -52,6 +52,11 @@ NETSDK1177: falha ao assinar appHost com o código de erro {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: o pacote Microsoft.AspNetCore.All não tem suporte quando direcionado ao .NET Core 3.0 ou superior. Um FrameworkReference para Microsoft.AspNetCore.App deve ser usado e será incluído implicitamente pelo Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index 023c1f9c5dd0..59e3d93c2871 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -52,6 +52,11 @@ NETSDK1177: не удалось подписать APPHOST с кодом ошибки {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: пакет Microsoft.AspNetCore.All не поддерживается при ориентации на .NET Core 3.0 или более поздней версии. Вместо этого нужно использовать ссылку FrameworkReference на Microsoft.AspNetCore.App, которая будет неявно включена пакетом Microsoft.NET.Sdk.Web. diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index 3737ea3fc7b6..d54104b9ff04 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -52,6 +52,11 @@ NETSDK1177: apphost şu hata koduyla imzalanamadı: {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: Microsoft.AspNetCore.All paketi .NET Core 3.0 veya üzeri hedeflenirken desteklenmez. Bunun yerine Microsoft.AspNetCore.App için bir FrameworkReference kullanılmalıdır. Bu, Microsoft.NET.Sdk.Web tarafından örtük olarak eklenecektir. diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index 3fa8ef13c2ef..b2998fef27fe 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -52,6 +52,11 @@ NETSDK1177: 无法对 Apphost 进行签名,错误代码为 {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: 当面向 .NET Core 3.0 或更高版本时,不支持 Microsoft.AspNetCore.All 包。应改为使用 Microsoft.AspNetCore.App 的 FrameworkReference,并且 Microsoft.NET.Sdk.Web 将隐式包含它。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 45ca0008bb5f..192544894557 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -52,6 +52,11 @@ NETSDK1177: 無法簽署 AppHost,錯誤碼 {1}: {0} {StrBegin="NETSDK1177: "} + + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. + {StrBegin="NETSDK1199: "} + NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. NETSDK1079: 目標為 .NET Core 3.0 或更新的版本時,不支援 Microsoft.AspNetCore.All 套件。應改用 Microsoft.AspNetCore.App 的 FrameworkReference,且會由 Microsoft.NET.Sdk.Web 隱含包含。 diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props index 4cd08400dd84..404a3d71f4d2 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props @@ -74,6 +74,12 @@ Copyright (c) .NET Foundation. All rights reserved. $(ArtifactsPath)\obj\ + + + <_ArtifactsPathSetEarly>true + + $(ProjectExtensionsPathForSpecifiedProject) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultArtifactsPath.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultArtifactsPath.props index 16a668ecf11c..9c9f90e14cfb 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultArtifactsPath.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultArtifactsPath.props @@ -30,14 +30,14 @@ Copyright (c) .NET Foundation. All rights reserved. - $(_DirectoryBuildPropsBasePath)\.artifacts + $(_DirectoryBuildPropsBasePath)\artifacts true <_ArtifactsPathLocationType>DirectoryBuildPropsFolder - $(MSBuildProjectDirectory)\.artifacts + $(MSBuildProjectDirectory)\artifacts <_ArtifactsPathLocationType>ProjectFolder diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets index 2779cdeed4d4..801636b06834 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets @@ -140,4 +140,20 @@ Copyright (c) .NET Foundation. All rights reserved. '$(AppendTargetFrameworkToOutputPath)' == 'true' and '$(TargetFramework)' != '' and '$(_UnsupportedTargetFrameworkError)' != 'true'"> $(IntermediateOutputPath)$(TargetFramework.ToLowerInvariant())\ + + + + + + + + + diff --git a/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs b/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs index a90a67f82a99..b89c153587a2 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs @@ -76,21 +76,18 @@ public ArtifactsOutputPathTests(ITestOutputHelper log) : base(log) return (testProjects, testAsset); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ItUsesArtifactsOutputPathForBuild(bool useDirectoryBuildProps) + [Fact] + public void ItUsesArtifactsOutputPathForBuild() { - var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps); + var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps: true); new DotnetCommand(Log, "build") .WithWorkingDirectory(testAsset.Path) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps); + ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps: true); foreach (var testProject in testProjects) { @@ -101,21 +98,18 @@ public void ItUsesArtifactsOutputPathForBuild(bool useDirectoryBuildProps) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ItUsesArtifactsOutputPathForPublish(bool useDirectoryBuildProps) + [Fact] + public void ItUsesArtifactsOutputPathForPublish() { - var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps); + var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps: true); new DotnetCommand(Log, "publish") .WithWorkingDirectory(testAsset.Path) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps, "release"); + ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps: true, "release"); foreach (var testProject in testProjects) { @@ -129,21 +123,18 @@ public void ItUsesArtifactsOutputPathForPublish(bool useDirectoryBuildProps) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ItUseArtifactstOutputPathForPack(bool useDirectoryBuildProps) + [Fact] + public void ItUseArtifactsOutputPathForPack() { - var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps); + var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps: true); new DotnetCommand(Log, "pack") .WithWorkingDirectory(testAsset.Path) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps, "release"); + ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps: true, "release"); foreach (var testProject in testProjects) { @@ -181,7 +172,7 @@ void ValidateIntermediatePaths(TestAsset testAsset, IEnumerable tes .Should() .NotHaveSubDirectories(); - new DirectoryInfo(Path.Combine(testAsset.TestRoot, ".artifacts", "obj", testProject.Name, configuration)) + new DirectoryInfo(Path.Combine(testAsset.TestRoot, "artifacts", "obj", testProject.Name, configuration)) .Should() .Exist(); }; @@ -208,16 +199,6 @@ public void ProjectsCanSwitchOutputFormats() .Should() .Exist(); - // Now build as if UseArtifactsOutput was set in project file - new BuildCommand(testAsset) - .Execute("/p:UseArtifactsOutput=true", "/p:ImportDirectoryBuildProps=false") - .Should() - .Pass(); - - new DirectoryInfo(Path.Combine(testAsset.Path, testProject.Name, ".artifacts", "bin", "debug")) - .Should() - .Exist(); - // Now add a Directory.Build.props file setting UseArtifactsOutput to true File.WriteAllText(Path.Combine(testAsset.Path, "Directory.Build.props"), """ @@ -279,19 +260,19 @@ public void ProjectsCanCustomizeOutputPathBasedOnTargetFramework() .Should() .Pass(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "bin", testProject.Name, "NET8_Debug")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "bin", testProject.Name, "NET7_Debug")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "bin", testProject.Name, "debug_netstandard2.0")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "bin", testProject.Name, "NET8_Debug")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "bin", testProject.Name, "NET7_Debug")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "bin", testProject.Name, "debug_netstandard2.0")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "bin", testProject.Name, "debug_net8.0")).Should().NotExist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "bin", testProject.Name, "debug_net7.0")).Should().NotExist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "bin", testProject.Name, "debug_net8.0")).Should().NotExist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "bin", testProject.Name, "debug_net7.0")).Should().NotExist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "obj", testProject.Name, "NET8_Debug")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "obj", testProject.Name, "NET7_Debug")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "obj", testProject.Name, "debug_netstandard2.0")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "obj", testProject.Name, "NET8_Debug")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "obj", testProject.Name, "NET7_Debug")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "obj", testProject.Name, "debug_netstandard2.0")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "obj", testProject.Name, "debug_net8.0")).Should().NotExist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "obj", testProject.Name, "debug_net7.0")).Should().NotExist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "obj", testProject.Name, "debug_net8.0")).Should().NotExist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "obj", testProject.Name, "debug_net7.0")).Should().NotExist(); foreach (var targetFramework in testProject.TargetFrameworks.Split(';')) { @@ -303,9 +284,9 @@ public void ProjectsCanCustomizeOutputPathBasedOnTargetFramework() } // Note that publish defaults to release configuration for .NET 8 but not prior TargetFrameworks - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "publish", testProject.Name, "NET8_Release")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "publish", testProject.Name, "NET7_Debug")).Should().Exist(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "publish", testProject.Name, "debug_netstandard2.0")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "publish", testProject.Name, "NET8_Release")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "publish", testProject.Name, "NET7_Debug")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "publish", testProject.Name, "debug_netstandard2.0")).Should().Exist(); new DotnetPackCommand(Log) .WithWorkingDirectory(Path.Combine(testAsset.Path, testProject.Name)) @@ -313,8 +294,8 @@ public void ProjectsCanCustomizeOutputPathBasedOnTargetFramework() .Should() .Pass(); - new DirectoryInfo(Path.Combine(testAsset.Path, ".artifacts", "package", "release")).Should().Exist(); - new FileInfo(Path.Combine(testAsset.Path, ".artifacts", "package", "release", testProject.Name + ".1.0.0.nupkg")).Should().Exist(); + new DirectoryInfo(Path.Combine(testAsset.Path, "artifacts", "package", "release")).Should().Exist(); + new FileInfo(Path.Combine(testAsset.Path, "artifacts", "package", "release", testProject.Name + ".1.0.0.nupkg")).Should().Exist(); } TestAsset CreateCustomizedTestProject(bool useDirectoryBuildProps, string propertyName, string propertyValue, [CallerMemberName] string callingMethod = "") @@ -350,17 +331,14 @@ TestAsset CreateCustomizedTestProject(bool useDirectoryBuildProps, string proper return testAsset; } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ArtifactsPathCanBeSet(bool useDirectoryBuildProps) + [Fact] + public void ArtifactsPathCanBeSet() { var artifactsFolder = _testAssetsManager.CreateTestDirectory(identifier: "ArtifactsPath").Path; - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps, "ArtifactsPath", artifactsFolder); + var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsPath", artifactsFolder); new DotnetBuildCommand(testAsset) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); @@ -372,116 +350,67 @@ public void ArtifactsPathCanBeSet(bool useDirectoryBuildProps) .Exist(); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void BinOutputNameCanBeSet(bool useDirectoryBuildProps) + [Fact] + public void BinOutputNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps, "ArtifactsBinOutputName", "binaries"); + var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsBinOutputName", "binaries"); new DotnetBuildCommand(testAsset) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - if (useDirectoryBuildProps) - { - new FileInfo(Path.Combine(testAsset.Path, ".artifacts", "binaries", "App", "debug", "App.dll")) - .Should() - .Exist(); - } - else - { - new FileInfo(Path.Combine(testAsset.Path, "App", ".artifacts", "binaries", "debug", "App.dll")) - .Should() - .Exist(); - } + new FileInfo(Path.Combine(testAsset.Path, "artifacts", "binaries", "App", "debug", "App.dll")) + .Should() + .Exist(); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PublishOutputNameCanBeSet(bool useDirectoryBuildProps) + [Fact] + public void PublishOutputNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps, "ArtifactsPublishOutputName", "published_app"); + var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsPublishOutputName", "published_app"); new DotnetPublishCommand(Log) .WithWorkingDirectory(testAsset.Path) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - if (useDirectoryBuildProps) - { - new FileInfo(Path.Combine(testAsset.Path, ".artifacts", "published_app", "App", "release", "App.dll")) - .Should() - .Exist(); - } - else - { - new FileInfo(Path.Combine(testAsset.Path, "App", ".artifacts", "published_app", "release", "App.dll")) - .Should() - .Exist(); - } + new FileInfo(Path.Combine(testAsset.Path, "artifacts", "published_app", "App", "release", "App.dll")) + .Should() + .Exist(); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PackageOutputNameCanBeSet(bool useDirectoryBuildProps) + [Fact] + public void PackageOutputNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps, "ArtifactsPackageOutputName", "package_output"); + var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsPackageOutputName", "package_output"); new DotnetPackCommand(Log) .WithWorkingDirectory(testAsset.Path) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - if (useDirectoryBuildProps) - { - new FileInfo(Path.Combine(testAsset.Path, ".artifacts", "package_output", "release", "App.1.0.0.nupkg")) - .Should() - .Exist(); - } - else - { - new FileInfo(Path.Combine(testAsset.Path, "App", ".artifacts", "package_output", "release", "App.1.0.0.nupkg")) - .Should() - .Exist(); - } + new FileInfo(Path.Combine(testAsset.Path, "artifacts", "package_output", "release", "App.1.0.0.nupkg")) + .Should() + .Exist(); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ProjectNameCanBeSet(bool useDirectoryBuildProps) + [Fact] + public void ProjectNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps, "ArtifactsProjectName", "Apps\\MyApp"); + var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsProjectName", "Apps\\MyApp"); new DotnetBuildCommand(Log) .WithWorkingDirectory(testAsset.Path) - .SetEnvironmentVariables(useDirectoryBuildProps) .Execute() .Should() .Pass(); - if (useDirectoryBuildProps) - { - new FileInfo(Path.Combine(testAsset.Path, ".artifacts", "bin", "Apps", "MyApp", "debug", "App.dll")) - .Should() - .Exist(); - } - else - { - // Note that customized ArtifactsProjectName doesn't have an impact here when the artifacts folder is already inside the project folder - new FileInfo(Path.Combine(testAsset.Path, "App", ".artifacts", "bin", "debug", "App.dll")) - .Should() - .Exist(); - } + new FileInfo(Path.Combine(testAsset.Path, "artifacts", "bin", "Apps", "MyApp", "debug", "App.dll")) + .Should() + .Exist(); } [Fact] @@ -514,6 +443,46 @@ public void PackageValidationSucceeds() .Should() .Pass(); } + + [Fact] + public void ItErrorsIfArtifactsPathIsSetInProject() + { + var testProject = new TestProject(); + testProject.AdditionalProperties["ArtifactsPath"] = "$(MSBuildThisFileDirectory)\\..\\artifacts"; + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + new BuildCommand(testAsset) + .Execute() + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1199"); + + new DirectoryInfo(Path.Combine(testAsset.TestRoot, "artifacts")) + .Should() + .NotExist(); + } + + [Fact] + public void ItErrorsIfUseArtifactsOutputIsSetInProject() + { + var testProject = new TestProject(); + testProject.AdditionalProperties["UseArtifactsOutput"] = "true"; + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + new BuildCommand(testAsset) + .Execute() + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1199"); + + new DirectoryInfo(Path.Combine(testAsset.TestRoot, testProject.Name, "artifacts")) + .Should() + .NotExist(); + } } namespace ArtifactsTestExtensions diff --git a/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs b/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs index f9407be3dc87..e397f27bbd1b 100644 --- a/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs +++ b/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs @@ -88,11 +88,11 @@ public static OutputPathCalculator FromProject(string projectPath, TestProject t { throw new InvalidOperationException("Couldn't find Directory.Build.props for test project " + projectPath); } - calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(directoryBuildPropsFile), ".artifacts"); + calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(directoryBuildPropsFile), "artifacts"); } else { - calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(projectPath), ".artifacts"); + calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(projectPath), "artifacts"); } } else @@ -107,7 +107,7 @@ public static OutputPathCalculator FromProject(string projectPath, TestProject t if (calculator.UseArtifactsOutput) { calculator.IncludeProjectNameInArtifactsPaths = false; - calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(projectPath), ".artifacts"); + calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(projectPath), "artifacts"); } } @@ -143,7 +143,7 @@ public static OutputPathCalculator FromProject(string projectPath, TestProject t if (calculator.UseArtifactsOutput) { calculator.IncludeProjectNameInArtifactsPaths = true; - calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(directoryBuildPropsFile), ".artifacts"); + calculator.ArtifactsPath = Path.Combine(Path.GetDirectoryName(directoryBuildPropsFile), "artifacts"); } } } From d9a005b9442dd90e7bd292b0dc48114c245f2316 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 25 Apr 2023 13:26:11 -0400 Subject: [PATCH 2/2] Add error if Directory.Build.props file isn't found when setting artifacts output path --- src/Tasks/Common/Resources/Strings.resx | 5 + src/Tasks/Common/Resources/xlf/Strings.cs.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.de.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.es.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.fr.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.it.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.ja.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.ko.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.pl.xlf | 5 + .../Common/Resources/xlf/Strings.pt-BR.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.ru.xlf | 5 + src/Tasks/Common/Resources/xlf/Strings.tr.xlf | 5 + .../Common/Resources/xlf/Strings.zh-Hans.xlf | 5 + .../Common/Resources/xlf/Strings.zh-Hant.xlf | 5 + .../Microsoft.NET.DefaultOutputPaths.targets | 4 + .../ArtifactsOutputPathTests.cs | 152 ++++++++++-------- .../OutputPathCalculator.cs | 16 +- .../ProjectConstruction/TestProject.cs | 7 - 18 files changed, 172 insertions(+), 77 deletions(-) diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index d13b3787c6e2..b151926e63c4 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -900,4 +900,9 @@ You may need to build the project on another operating system or architecture, o NETSDK1199: The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information. {StrBegin="NETSDK1199: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + + diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index 6aadbef26104..3c928ef4ce46 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: Identifikátor cílové platformy {0} se nerozpoznal. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: K sestavování desktopových aplikací pro Windows se vyžaduje Microsoft.NET.Sdk.WindowsDesktop. Aktuální verze sady SDK nepodporuje hodnoty UseWpf a UseWindowsForms. diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index 4014297667ae..4e6ac8cd84fb 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: Der Zielplattformbezeichner "{0}" wurde nicht erkannt. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Für das Erstellen von Windows-Desktopanwendungen ist Microsoft.NET.Sdk.WindowsDesktop erforderlich. "UseWpf" und "UseWindowsForms" werden vom aktuellen SDK nicht unterstützt. diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 5f22b078e823..1ffdbaa9460a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: No se reconoció el identificador de la plataforma de destino {0}. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Se requiere Microsoft.NET.Sdk.WindowsDesktop para compilar las aplicaciones de escritorio de Windows. El SDK actual no admite "UseWpf" ni "UseWindowsForms". diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index bf6b62b0435c..27c82bdd4790 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: L'identificateur de la plateforme cible {0} n'a pas été reconnu. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: vous devez disposer de Microsoft.NET.Sdk.WindowsDesktop pour générer des applications de bureau Windows. 'UseWpf' et 'UseWindowsForms' ne sont pas pris en charge par le kit SDK actuel. diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index 42d0c33251de..2260dab37567 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: l'identificatore di piattaforma di destinazione {0} non è stato riconosciuto. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: per compilare applicazioni desktop di Windows, è necessario Microsoft.NET.Sdk.WindowsDesktop. 'UseWpf' e 'UseWindowsForms' non sono supportati dall'SDK corrente. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index 49cd74b2827f..a8fcb592f2cb 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: ターゲット プラットフォーム識別子 {0} は認識されませんでした。 {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Windows デスクトップ アプリケーションを作成するには、Microsoft.NET.Sdk.WindowsDesktop が必要です。現在の SDK では、'UseWpf' と 'UseWindowsForms' はサポートされていません。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index b7afd45eeb5d..71dbf1f8cf58 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: 대상 플랫폼 식별자 {0}을(를) 인식할 수 없습니다. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop을 사용하려면 Windows 데스크톱 애플리케이션을 빌드해야 합니다. 'UseWpf' 및 'UseWindowsForms'는 현재 SDK에서 지원하지 않습니다. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index afe037cdb75a..67f8c423f54a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: nie rozpoznano identyfikatora platformy docelowej {0}. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Do kompilowania aplikacji klasycznych systemu Windows konieczny jest zestaw Microsoft.NET.Sdk.WindowsDesktop. Właściwości „UseWpf” i „UseWindowsForms” nie są obsługiwane przez bieżący zestaw SDK. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index 6100c18bb098..1b64a8695650 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: o identificador de plataforma de destino {0} não foi reconhecido. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop é necessário para compilar aplicativos da área de trabalho do Windows. Não há suporte para 'UseWpf' e 'UseWindowsForms' no SDK atual. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index 59e3d93c2871..ee05f9babdf4 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: не удалось распознать идентификатор целевой платформы {0}. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: для сборки классических приложений для Windows требуется Microsoft.NET.Sdk.WindowsDesktop. "UseWpf" и "UseWindowsForms" не поддерживаются текущим пакетом SDK. diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index d54104b9ff04..5833a45ffda7 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: {0} hedef platform tanımlayıcısı tanınmadı. {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: Windows Masaüstü uygulamalarını derlemek için Microsoft.NET.Sdk.WindowsDesktop gereklidir. 'UseWpf' ve 'UseWindowsForms' geçerli SDK tarafından desteklenmiyor. diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index b2998fef27fe..73c577e73e3a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: 无法识别目标平台标识符 {0}。 {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: 要构建 Windows 桌面应用程序,需使用 Microsoft.NET.Sdk.WindowsDesktop。当前 SDK 不支持 "UseWpf" 和 "UseWindowsForms"。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 192544894557..7068a86bd494 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -937,6 +937,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1139: 無法辨識目標平台識別碼 {0}。 {StrBegin="NETSDK1139: "} + + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + NETSDK1200: If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located. + {StrBegin="NETSDK1200: "} + NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. NETSDK1107: 需有 Microsoft.NET.Sdk.WindowsDesktop 才能建置 Windows 傳統型應用程式。目前的 SDK 不支援 'UseWpf' 和 'UseWindowsForms'。 diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets index 801636b06834..4eca73686f0b 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets @@ -154,6 +154,10 @@ Copyright (c) .NET Foundation. All rights reserved. + + + diff --git a/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs b/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs index b89c153587a2..4a3757e5aa81 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs @@ -29,7 +29,7 @@ public ArtifactsOutputPathTests(ITestOutputHelper log) : base(log) { } - (List testProjects, TestAsset testAsset) GetTestProjects(bool useDirectoryBuildProps, [CallerMemberName] string callingMethod = "") + (List testProjects, TestAsset testAsset) GetTestProjects(bool putArtifactsInProjectFolder = false, [CallerMemberName] string callingMethod = "") { var testProject1 = new TestProject() { @@ -56,15 +56,26 @@ public ArtifactsOutputPathTests(ITestOutputHelper log) : base(log) foreach (var testProject in testProjects) { testProject.UseArtifactsOutput = true; - testProject.UseDirectoryBuildPropsForArtifactsOutput = useDirectoryBuildProps; } - var testAsset = _testAssetsManager.CreateTestProjects(testProjects, callingMethod: callingMethod, identifier: useDirectoryBuildProps.ToString()); + var testAsset = _testAssetsManager.CreateTestProjects(testProjects, callingMethod: callingMethod, identifier: putArtifactsInProjectFolder.ToString()); - if (useDirectoryBuildProps) + if (putArtifactsInProjectFolder) { File.WriteAllText(Path.Combine(testAsset.Path, "Directory.Build.props"), - """ + """ + + + $(MSBuildProjectDirectory)\artifacts + false + + + """); + } + else + { + File.WriteAllText(Path.Combine(testAsset.Path, "Directory.Build.props"), + """ true @@ -79,7 +90,7 @@ public ArtifactsOutputPathTests(ITestOutputHelper log) : base(log) [Fact] public void ItUsesArtifactsOutputPathForBuild() { - var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps: true); + var (testProjects, testAsset) = GetTestProjects(); new DotnetCommand(Log, "build") .WithWorkingDirectory(testAsset.Path) @@ -87,7 +98,7 @@ public void ItUsesArtifactsOutputPathForBuild() .Should() .Pass(); - ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps: true); + ValidateIntermediatePaths(testAsset, testProjects); foreach (var testProject in testProjects) { @@ -101,7 +112,7 @@ public void ItUsesArtifactsOutputPathForBuild() [Fact] public void ItUsesArtifactsOutputPathForPublish() { - var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps: true); + var (testProjects, testAsset) = GetTestProjects(); new DotnetCommand(Log, "publish") .WithWorkingDirectory(testAsset.Path) @@ -109,7 +120,7 @@ public void ItUsesArtifactsOutputPathForPublish() .Should() .Pass(); - ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps: true, "release"); + ValidateIntermediatePaths(testAsset, testProjects, "release"); foreach (var testProject in testProjects) { @@ -126,7 +137,7 @@ public void ItUsesArtifactsOutputPathForPublish() [Fact] public void ItUseArtifactsOutputPathForPack() { - var (testProjects, testAsset) = GetTestProjects(useDirectoryBuildProps: true); + var (testProjects, testAsset) = GetTestProjects(); new DotnetCommand(Log, "pack") .WithWorkingDirectory(testAsset.Path) @@ -134,7 +145,7 @@ public void ItUseArtifactsOutputPathForPack() .Should() .Pass(); - ValidateIntermediatePaths(testAsset, testProjects, useDirectoryBuildProps: true, "release"); + ValidateIntermediatePaths(testAsset, testProjects, "release"); foreach (var testProject in testProjects) { @@ -148,34 +159,44 @@ public void ItUseArtifactsOutputPathForPack() } } - void ValidateIntermediatePaths(TestAsset testAsset, IEnumerable testProjects, bool useDirectoryBuildProps, string configuration = "debug") + void ValidateIntermediatePaths(TestAsset testAsset, IEnumerable testProjects, string configuration = "debug") { foreach (var testProject in testProjects) { - if (!useDirectoryBuildProps) - { - new DirectoryInfo(Path.Combine(testAsset.TestRoot, testProject.Name)) - .Should() - .HaveDirectory("obj"); + new DirectoryInfo(Path.Combine(testAsset.TestRoot, testProject.Name)) + .Should() + .NotHaveSubDirectories(); - new DirectoryInfo(Path.Combine(testAsset.TestRoot, testProject.Name, "bin")) - .Should() - .NotExist(); + new DirectoryInfo(Path.Combine(testAsset.TestRoot, "artifacts", "obj", testProject.Name, configuration)) + .Should() + .Exist(); + } + } - new DirectoryInfo(Path.Combine(testAsset.TestRoot, "artifacts", "obj")) - .Should() - .NotExist(); - } - else - { - new DirectoryInfo(Path.Combine(testAsset.TestRoot, testProject.Name)) - .Should() - .NotHaveSubDirectories(); + [Fact] + public void ArtifactsPathCanBeInProjectFolder() + { + var (testProjects, testAsset) = GetTestProjects(putArtifactsInProjectFolder: true); - new DirectoryInfo(Path.Combine(testAsset.TestRoot, "artifacts", "obj", testProject.Name, configuration)) + new DotnetCommand(Log, "build") + .WithWorkingDirectory(testAsset.Path) + .Execute() + .Should() + .Pass(); + + foreach (var testProject in testProjects) + { + var outputPathCalculator = OutputPathCalculator.FromProject(testAsset.Path, testProject); + outputPathCalculator.IncludeProjectNameInArtifactsPaths = false; + outputPathCalculator.ArtifactsPath = Path.Combine(testAsset.Path, testProject.Name, "artifacts"); + + new DirectoryInfo(outputPathCalculator.GetIntermediateDirectory()) .Should() .Exist(); - }; + + new FileInfo(Path.Combine(outputPathCalculator.GetOutputDirectory(), testProject.Name + ".dll")) + .Should() + .Exist(); } } @@ -298,7 +319,7 @@ public void ProjectsCanCustomizeOutputPathBasedOnTargetFramework() new FileInfo(Path.Combine(testAsset.Path, "artifacts", "package", "release", testProject.Name + ".1.0.0.nupkg")).Should().Exist(); } - TestAsset CreateCustomizedTestProject(bool useDirectoryBuildProps, string propertyName, string propertyValue, [CallerMemberName] string callingMethod = "") + TestAsset CreateCustomizedTestProject(string propertyName, string propertyValue, [CallerMemberName] string callingMethod = "") { var testProject = new TestProject("App") { @@ -306,27 +327,18 @@ TestAsset CreateCustomizedTestProject(bool useDirectoryBuildProps, string proper }; testProject.UseArtifactsOutput = true; - testProject.UseDirectoryBuildPropsForArtifactsOutput = useDirectoryBuildProps; - - if (!useDirectoryBuildProps) - { - testProject.AdditionalProperties[propertyName] = propertyValue; - } - var testAsset = _testAssetsManager.CreateTestProjects(new[] { testProject }, callingMethod: callingMethod, identifier: useDirectoryBuildProps.ToString()); + var testAsset = _testAssetsManager.CreateTestProjects(new[] { testProject }, callingMethod: callingMethod); - if (useDirectoryBuildProps) - { - File.WriteAllText(Path.Combine(testAsset.Path, "Directory.Build.props"), - $""" - - - true - <{propertyName}>{propertyValue} - - - """); - } + File.WriteAllText(Path.Combine(testAsset.Path, "Directory.Build.props"), + $""" + + + true + <{propertyName}>{propertyValue} + + + """); return testAsset; } @@ -336,7 +348,7 @@ public void ArtifactsPathCanBeSet() { var artifactsFolder = _testAssetsManager.CreateTestDirectory(identifier: "ArtifactsPath").Path; - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsPath", artifactsFolder); + var testAsset = CreateCustomizedTestProject("ArtifactsPath", artifactsFolder); new DotnetBuildCommand(testAsset) .Execute() @@ -353,7 +365,7 @@ public void ArtifactsPathCanBeSet() [Fact] public void BinOutputNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsBinOutputName", "binaries"); + var testAsset = CreateCustomizedTestProject("ArtifactsBinOutputName", "binaries"); new DotnetBuildCommand(testAsset) .Execute() @@ -368,7 +380,7 @@ public void BinOutputNameCanBeSet() [Fact] public void PublishOutputNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsPublishOutputName", "published_app"); + var testAsset = CreateCustomizedTestProject("ArtifactsPublishOutputName", "published_app"); new DotnetPublishCommand(Log) .WithWorkingDirectory(testAsset.Path) @@ -384,7 +396,7 @@ public void PublishOutputNameCanBeSet() [Fact] public void PackageOutputNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsPackageOutputName", "package_output"); + var testAsset = CreateCustomizedTestProject("ArtifactsPackageOutputName", "package_output"); new DotnetPackCommand(Log) .WithWorkingDirectory(testAsset.Path) @@ -400,7 +412,7 @@ public void PackageOutputNameCanBeSet() [Fact] public void ProjectNameCanBeSet() { - var testAsset = CreateCustomizedTestProject(useDirectoryBuildProps: true, "ArtifactsProjectName", "Apps\\MyApp"); + var testAsset = CreateCustomizedTestProject("ArtifactsProjectName", "Apps\\MyApp"); new DotnetBuildCommand(Log) .WithWorkingDirectory(testAsset.Path) @@ -424,7 +436,6 @@ public void PackageValidationSucceeds() testProject.AdditionalProperties["EnablePackageValidation"] = "True"; testProject.UseArtifactsOutput = true; - testProject.UseDirectoryBuildPropsForArtifactsOutput = true; var testAsset = _testAssetsManager.CreateTestProject(testProject); @@ -483,26 +494,35 @@ public void ItErrorsIfUseArtifactsOutputIsSetInProject() .Should() .NotExist(); } + + [Fact] + public void ItErrorsIfUseArtifactsOutputIsSetAndThereIsNoDirectoryBuildProps() + { + var testProject = new TestProject(); + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + new BuildCommand(testAsset) + .DisableDirectoryBuildProps() + .Execute("/p:UseArtifactsOutput=true") + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1200"); + } } namespace ArtifactsTestExtensions { static class Extensions { - public static TestCommand SetEnvironmentVariables(this TestCommand command, bool useDirectoryBuildProps) + public static TestCommand DisableDirectoryBuildProps(this TestCommand command) { // There is an empty Directory.Build.props file in the test execution root, to stop other files further up in the repo from // impacting the tests. So if a project set UseArtifactsOutput to true, the logic would find that file and put the output // in that folder. To simulate the situation where there is no Directory.Build.props, we turn it off via an environment // variable. - if (!useDirectoryBuildProps) - { - return command.WithEnvironmentVariable("ImportDirectoryBuildProps", "false"); - } - else - { - return command; - } + return command.WithEnvironmentVariable("ImportDirectoryBuildProps", "false"); } } } diff --git a/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs b/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs index e397f27bbd1b..323d5c95be6d 100644 --- a/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs +++ b/src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs @@ -68,7 +68,7 @@ public static OutputPathCalculator FromProject(string projectPath, TestProject t { calculator.UseArtifactsOutput = testProject.UseArtifactsOutput; calculator.IsSdkProject = testProject.IsSdkProject; - calculator.IncludeProjectNameInArtifactsPaths = testProject.UseDirectoryBuildPropsForArtifactsOutput; + calculator.IncludeProjectNameInArtifactsPaths = true; if (testProject.TargetFrameworks.Contains(';')) { @@ -258,8 +258,7 @@ public string GetPublishDirectory(string targetFramework = null, string configur public string GetIntermediateDirectory(string targetFramework = null, string configuration = "Debug", string runtimeIdentifier = "") { - // IncludeProjectNameInArtifactsPath is likely to be true if UseArtifactsOutput was set in Directory.Build.props, and hence the intermediate folder should be in the artifacts path - if (UseArtifactsOutput && IncludeProjectNameInArtifactsPaths) + if (UseArtifactsOutput) { string pivot = configuration.ToLowerInvariant(); if (IsMultiTargeted()) @@ -274,7 +273,16 @@ public string GetIntermediateDirectory(string targetFramework = null, string con { pivot += "_" + runtimeIdentifier; } - return Path.Combine(ArtifactsPath, "obj", Path.GetFileNameWithoutExtension(ProjectPath), pivot); + + if (IncludeProjectNameInArtifactsPaths) + { + return Path.Combine(ArtifactsPath, "obj", Path.GetFileNameWithoutExtension(ProjectPath), pivot); + } + else + { + return Path.Combine(ArtifactsPath, "obj", pivot); + } + } targetFramework = targetFramework ?? TargetFramework ?? string.Empty; diff --git a/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs b/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs index 8ae1bb1994cb..f135512867c6 100644 --- a/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs +++ b/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs @@ -54,8 +54,6 @@ public TestProject([CallerMemberName] string name = null) public bool UseArtifactsOutput { get; set; } - public bool UseDirectoryBuildPropsForArtifactsOutput { get; set; } - public List ReferencedProjects { get; } = new List(); public List References { get; } = new List(); @@ -251,11 +249,6 @@ internal void Create(TestAsset targetTestAsset, string testProjectsSourceFolder, propertyGroup.Add(new XElement(ns + additionalProperty.Key, additionalProperty.Value)); } - if (UseArtifactsOutput && !UseDirectoryBuildPropsForArtifactsOutput) - { - propertyGroup.Add(new XElement(ns + "UseArtifactsOutput", "true")); - } - if (AdditionalItems.Any()) { foreach (var additionalItem in AdditionalItems)