From c0f65b1374a5b4e2703366141b176dd277887c8b Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Fri, 17 Jul 2020 13:53:36 -0700 Subject: [PATCH 1/7] Error on unsupported Windows TargetPlatformVersion --- 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.Sdk.BeforeCommon.targets | 1 + .../targets/Microsoft.NET.Sdk.props | 3 + ...crosoft.NET.SupportedTargetPlatforms.props | 26 ++++ .../targets/Microsoft.NET.Windows.targets | 12 ++ .../GivenThatWeWantToBuildALibrary.cs | 4 +- ...ThatWeWantToBuildAWindowsDesktopProject.cs | 126 ++++++++++++++++++ 20 files changed, 239 insertions(+), 2 deletions(-) create mode 100644 src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.SupportedTargetPlatforms.props create mode 100644 src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index 781d470c54bf..2c33875ebef0 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -649,4 +649,8 @@ The following are names of parameters or literal values and should not be transl NETSDK1136: The target platform identifier {0} was not recognized. {StrBegin="NETSDK1136: "} + + NETSDK1137: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1137: "} + diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index 969179b064ab..648dfb44a17a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: Hodnota RollForward {0} je neplatná. Povolené jsou tyto hodnoty: {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: Projekt byl obnoven pomocí aplikace {0} verze {1}, ale s aktuálním nastavením by se místo toho použít verze {2}. Tento problém vyřešíte tak, že zkontrolujete, že se pro obnovení a následné operace, například sestavení nebo publikování, používá stejné nastavení. Obvykle k tomuto problému může dojít, pokud je vlastnost RuntimeIdentifier nastavena při sestavování nebo publikování, ale ne při obnovování. Další informace najdete na stránce https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index 2bb5b725a4f7..9f92d2496bc0 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: Der RollForward-Wert "{0}" ist ungültig. Zulässige Werte: {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: Das Projekt wurde mit {0}, Version {1} wiederhergestellt, aber mit den aktuellen Einstellungen würde stattdessen Version {2} verwendet werden. Um dieses Problem zu beheben, müssen Sie sicherstellen, dass für die Wiederherstellung und für nachfolgende Vorgänge wie das Kompilieren oder Veröffentlichen dieselben Einstellungen verwendet werden. Dieses Problem tritt typischerweise auf, wenn die RuntimeIdentifier-Eigenschaft bei der Kompilierung oder Veröffentlichung, aber nicht bei der Wiederherstellung festgelegt wird. Weitere Informationen finden Sie unter https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 73a9ede99c45..e85177f35447 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: El valor "{0}" de RollForward no es válido. Los valores permitidos son: {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: El proyecto fue restaurado utilizando la versión {0} {1}, pero con la configuración actual, la versión {2} se utilizaría en su lugar. Para resolver este problema, asegúrese de que la misma configuración se utiliza para restaurar y para operaciones posteriores como compilar o publicar. Normalmente, este problema puede producirse si la `propiedad RuntimeIdentifier se establece durante la compilación o la publicación pero no durante la restauración. Para obtener más información, consulte https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index c931edf111eb..7524f84d3872 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: la valeur RollForward '{0}' est non valide. Les valeurs autorisées sont {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: Le projet a été restauré avec la version {0} {1}, mais avec les paramètres actuels, la version {2} serait utilisée à la place. Pour résoudre ce problème, assurez-vous que les mêmes paramètres sont utilisés pour la restauration et pour les opérations ultérieures telles que la génération et la publication. Généralement, ce problème peut se produire si la propriété RuntimeIdentifier est définie au cours de la génération ou de la publication, mais pas pendant la restauration. Pour plus d’informations, consultez https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index dbba9f121586..c60511ed9c7b 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: il valore '{0}' di RollForward non è valido. I valori consentiti sono {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: per il ripristino del progetto è stato usato {0} versione {1}, ma con le impostazioni correnti viene usata la versione {2}. Per risolvere il problema, assicurarsi di usare le stesse impostazioni per il ripristino e per le operazioni successive, quali compilazione o pubblicazione. In genere questo problema può verificarsi se la proprietà RuntimeIdentifier viene impostata durante la compilazione o la pubblicazione, ma non durante il ripristino. Per altre informazioni, vedere https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index 4a101ac116d9..aae6418181c8 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: ロールフォワード値 '{0}' が無効です。許可されている値は {1} です。 {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: プロジェクトは {0} バージョン {1} を使用して復元されましたが、現在の設定では、バージョン {2} が代わりに使用されます。この問題を解決するには、復元およびこれ以降の操作 (ビルドや公開など) で同じ設定を使用していることをご確認ください。通常この問題は、ビルドや公開の実行時に RuntimeIdentifier プロパティを設定したが、復元時には設定していない場合に発生することがあります。詳しくは、https://aka.ms/dotnet-runtime-patch-selection を参照してください。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index fef722efb5ec..b4fd185c5ba5 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: RollForward 값 '{0}'이(가) 잘못되었습니다. 허용되는 값은 {1}입니다. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: {0} 버전 {1}을(를) 사용하여 프로젝트가 복원되었지만, 현재 설정에서는 버전 {2}을(를) 대신 사용합니다. 이 문제를 해결하려면 복원 및 후속 작업(예: 빌드 또는 게시)에 동일한 설정을 사용해야 합니다. 일반적으로 이 문제는 RuntimeIdentifier 속성이 빌드 또는 게시 중에 설정되었지만, 복원 중에는 설정되지 않은 경우에 발생할 수 있습니다. 자세한 내용은 https://aka.ms/dotnet-runtime-patch-selection을 참조하세요. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index 4ec935337000..abfadda491bd 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: Wartość RollForward „{0}” jest nieprawidłowa. Dozwolone wartości to {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: Projekt został przywrócony przy użyciu pakietu {0} w wersji {1}, ale w przypadku bieżących ustawień zamiast niej zostałaby użyta wersja {2}. Aby rozwiązać ten problem, upewnij się, że te same ustawienia są używane do przywracania i dla kolejnych operacji, takich jak kompilacja lub publikowanie. Ten problem zazwyczaj występuje, gdy właściwość RuntimeIdentifier jest ustawiona podczas kompilacji lub publikowania, ale nie podczas przywracania. Aby uzyskać więcej informacji, zobacz https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index 0ffbf625fa54..068abfff0eba 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: o valor de RollForward '{0}' é inválido. Os valores permitidos são {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: o projeto foi restaurado usando o {0} versão {1}, mas, com as configurações atuais, a versão {2} seria usada. Para resolver esse problema, verifique se as mesmas configurações são usadas para restauração e para operações subsequentes, como compilação ou publicação. Normalmente, esse problema poderá ocorrer se a propriedade RuntimeIdentifier for definida durante a compilação ou a publicação, mas não durante a restauração. Para obter mais informações, consulte https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index a44802c3bcb1..5127d20031ba 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: недопустимое значение RollForward "{0}". Разрешенные значения — {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: Проект был восстановлен с использованием {0} версии {1}, но с текущими параметрами вместо этой версии будет использована версия {2}. Чтобы устранить эту проблему, убедитесь, что для восстановления и последующих операций (таких как сборка или публикация) используются одинаковые параметры. Обычно эта проблема возникает, когда свойство RuntimeIdentifier устанавливается во время сборки или публикации, но не во время восстановления. Дополнительные сведения см. на странице https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index 858cfe54f888..1c8f6e125271 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: '{0}' RollForward değeri geçersiz. İzin verilen değerler {1}. {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: Proje, {0} sürüm {1} kullanılarak geri yüklendi, ancak geçerli ayarlarla, bunun yerine sürüm {2} kullanılması gerekiyordu. Bu sorunu çözmek amacıyla, geri yükleme için ve derleme veya yayımlama gibi sonraki işlemler için aynı ayarların kullanıldığından emin olun. Bu sorun genellikle RuntimeIdentifier özelliği derleme veya yayımlama sırasında ayarlandığında ancak geri yükleme sırasında ayarlanmadığında oluşur. Daha fazla bilgi için bkz. https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index fdb27871687c..b54de278b082 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: RollForward 值“{0}”无效。允许的值为 {1}。 {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: 项目是使用 {0} 版本 {1} 还原的, 但使用当前设置, 将改用版本 {2}。要解决此问题, 请确保将相同的设置用于还原和后续操作 (如生成或发布)。通常, 如果 RuntimeIdentifier 属性是在生成或发布过程中设置的, 而不是在还原过程中进行的, 则会发生此问题。有关详细信息, 请参阅 https://aka.ms/dotnet-runtime-patch-selection。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 5b2271fb1b1a..ebc5e6f3056e 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -395,6 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: RollForward 值 '{0}' 無效。允許的值為 {1}。 {StrBegin="NETSDK1104: "} + + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + {StrBegin="NETSDK1138: "} + NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. NETSDK1061: 專案是使用 {0} 版本 {1} 還原的,但依照目前設定,使用的版本會是 {2}。若要解決此問題,請確認用於還原與後續作業 (例如建置或發佈) 的設定相同。一般而言,若在建置或發佈期間設定了 RuntimeIdentifier,但在還原期間未加以設定,就可能發生這個問題。如需詳細資訊,請參閱 https://aka.ms/dotnet-runtime-patch-selection。 diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets index 3703921cac95..ad4e68e5d284 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets @@ -16,6 +16,7 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.SupportedTargetPlatforms.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.SupportedTargetPlatforms.props new file mode 100644 index 000000000000..5b76d8d337ce --- /dev/null +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.SupportedTargetPlatforms.props @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets index b86bf20d17e2..bc9cfa2784b9 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets @@ -27,4 +27,16 @@ Copyright (c) .NET Foundation. All rights reserved. Windows,Version=7.0 Windows 7.0 + + + + + + + + diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs index bdf393ff87a3..3cdc72165b7a 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs @@ -423,7 +423,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_framework [Theory] [InlineData("ios", "1.1", new[] { "IOS", "IOS1_1" })] [InlineData("android", "2.2", new[] { "ANDROID", "ANDROID2_2" })] - [InlineData("windows", "10.1", new[] { "WINDOWS", "WINDOWS10_1" })] + [InlineData("windows", "7.0", new[] { "WINDOWS", "WINDOWS7_0" })] public void It_implicitly_defines_compilation_constants_for_the_target_platform(string targetPlatformIdentifier, string targetPlatformVersion, string[] expectedDefines) { var targetFramework = "net5.0"; @@ -454,7 +454,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform( [Theory] [InlineData(new[] { "1.0", "1.1" }, "ios", "1.1", new[] { "IOS", "IOS1_1", "IOS1_0" })] [InlineData(new[] { "11.11", "12.12", "13.13" }, "android", "12.12", new[] { "ANDROID", "ANDROID11_11", "ANDROID12_12" })] - [InlineData(new[] { "7.0", "8.0", "10.0.19041", "11.0.0" }, "windows", "11.0.0", new[] { "WINDOWS", "WINDOWS7_0", "WINDOWS8_0", "WINDOWS10_0_19041", "WINDOWS11_0_0" })] + [InlineData(new string[] { /* Use the built in SupportedTargetPlatform items */}, "windows", "10.0.19041", new[] { "WINDOWS", "WINDOWS7_0", "WINDOWS8_0", "WINDOWS10_0_17763", "WINDOWS10_0_18362", "WINDOWS10_0_19041" })] public void It_implicitly_defines_compilation_constants_for_the_target_platform_with_backwards_compatibility(string[] supportedTargetPlatform, string targetPlatformIdentifier, string targetPlatformVersion, string[] expectedDefines) { var targetFramework = "net5.0"; diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs new file mode 100644 index 000000000000..2a8e091af7be --- /dev/null +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs @@ -0,0 +1,126 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using FluentAssertions; +using Microsoft.NET.TestFramework; +using Microsoft.NET.TestFramework.Commands; +using Xunit; +using Xunit.Abstractions; +using Microsoft.NET.TestFramework.Assertions; +using Microsoft.NET.TestFramework.ProjectConstruction; + +namespace Microsoft.NET.Build.Tests +{ + public class GivenThatWeWantToBuildAWindowsDesktopProject : SdkTest + { + public GivenThatWeWantToBuildAWindowsDesktopProject(ITestOutputHelper log) : base(log) + {} + + [WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")] + [InlineData("UseWindowsForms")] + [InlineData("UseWPF")] + public void It_errors_when_missing_windows_target_platform(string propertyName) + { + var targetFramework = "net5.0"; + TestProject testProject = new TestProject() + { + Name = "MissingTargetPlatform", + IsSdkProject = true, + TargetFrameworks = targetFramework + }; + testProject.AdditionalProperties[propertyName] = "true"; + testProject.AdditionalProperties["TargetPlatformIdentifier"] = "custom"; // Make sure we don't get windows implicitly set as the TPI + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: propertyName); + + var buildCommand = new BuildCommand(testAsset); + buildCommand.Execute() + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1136"); + } + + [WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")] + [InlineData("UseWindowsForms")] + [InlineData("UseWPF")] + public void It_errors_when_missing_transitive_windows_target_platform(string propertyName) + { + TestProject testProjectA = new TestProject() + { + Name = "A", + IsSdkProject = true, + ProjectSdk = "Microsoft.NET.Sdk.WindowsDesktop", + TargetFrameworks = "netcoreapp3.1" + }; + testProjectA.AdditionalProperties[propertyName] = "true"; + + TestProject testProjectB = new TestProject() + { + Name = "B", + IsSdkProject = true, + TargetFrameworks = "net5.0" + }; + testProjectB.ReferencedProjects.Add(testProjectA); + + TestProject testProjectC = new TestProject() + { + Name = "C", + IsSdkProject = true, + TargetFrameworks = "net5.0" + }; + testProjectC.ReferencedProjects.Add(testProjectB); + + var testAsset = _testAssetsManager.CreateTestProject(testProjectC); + + var buildCommand = new BuildCommand(testAsset); + buildCommand.Execute() + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1136"); + } + + [WindowsOnlyFact] + public void It_warns_when_specifying_windows_desktop_sdk() + { + var targetFramework = "net5.0"; + TestProject testProject = new TestProject() + { + Name = "windowsDesktopSdk", + IsSdkProject = true, + ProjectSdk = "Microsoft.NET.Sdk.WindowsDesktop", + TargetFrameworks = targetFramework + }; + testProject.AdditionalProperties["UseWPF"] = "true"; + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var buildCommand = new BuildCommand(testAsset); + buildCommand.Execute() + .Should() + .Pass() + .And + .HaveStdOutContaining("NETSDK1137"); + } + + [WindowsOnlyFact] + public void It_fails_if_windows_target_platform_version_is_invalid() + { + var testProject = new TestProject() + { + Name = "InvalidWindowsVersion", + IsSdkProject = true, + TargetFrameworks = "net5.0" + }; + testProject.AdditionalProperties["TargetPlatformIdentifier"] = "Windows"; + testProject.AdditionalProperties["TargetPlatformVersion"] = "1.0"; + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var buildCommand = new BuildCommand(testAsset); + buildCommand.Execute() + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1138"); + } + } +} From 108416dc1ce4d105c0b857824f3eb7456c74b10f Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Tue, 21 Jul 2020 08:48:38 -0700 Subject: [PATCH 2/7] PR feedback --- src/Tasks/Common/Resources/Strings.resx | 5 +++-- src/Tasks/Common/Resources/xlf/Strings.cs.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.de.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.es.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.fr.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.it.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.ja.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.ko.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.pl.xlf | 8 +++++--- .../Common/Resources/xlf/Strings.pt-BR.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.ru.xlf | 8 +++++--- src/Tasks/Common/Resources/xlf/Strings.tr.xlf | 8 +++++--- .../Common/Resources/xlf/Strings.zh-Hans.xlf | 8 +++++--- .../Common/Resources/xlf/Strings.zh-Hant.xlf | 8 +++++--- .../Microsoft.NET.Sdk.BeforeCommon.targets | 2 +- .../targets/Microsoft.NET.Sdk.props | 4 ++-- ...rosoft.NET.TargetFrameworkInference.targets | 18 ++++++++++++++++++ .../targets/Microsoft.NET.Windows.targets | 12 ------------ ....NET.WindowsSupportedTargetPlatforms.props} | 4 ++-- 19 files changed, 91 insertions(+), 58 deletions(-) rename src/Tasks/Microsoft.NET.Build.Tasks/targets/{Microsoft.NET.SupportedTargetPlatforms.props => Microsoft.NET.WindowsSupportedTargetPlatforms.props} (86%) diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index 2c33875ebef0..9d7f30556d26 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -649,8 +649,9 @@ The following are names of parameters or literal values and should not be transl NETSDK1136: The target platform identifier {0} was not recognized. {StrBegin="NETSDK1136: "} - - NETSDK1137: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1137: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index 648dfb44a17a..a134d215d0b1 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: Hodnota RollForward {0} je neplatná. Povolené jsou tyto hodnoty: {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index 9f92d2496bc0..d487cb593bef 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: Der RollForward-Wert "{0}" ist ungültig. Zulässige Werte: {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index e85177f35447..292a444c6706 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: El valor "{0}" de RollForward no es válido. Los valores permitidos son: {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index 7524f84d3872..0473480fe253 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: la valeur RollForward '{0}' est non valide. Les valeurs autorisées sont {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index c60511ed9c7b..2758c2118de4 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: il valore '{0}' di RollForward non è valido. I valori consentiti sono {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index aae6418181c8..c584233a2206 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: ロールフォワード値 '{0}' が無効です。許可されている値は {1} です。 {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index b4fd185c5ba5..a700b210d3cb 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: RollForward 값 '{0}'이(가) 잘못되었습니다. 허용되는 값은 {1}입니다. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index abfadda491bd..5f9253426a47 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: Wartość RollForward „{0}” jest nieprawidłowa. Dozwolone wartości to {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index 068abfff0eba..0e7457c5b555 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: o valor de RollForward '{0}' é inválido. Os valores permitidos são {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index 5127d20031ba..fe83375a86ff 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: недопустимое значение RollForward "{0}". Разрешенные значения — {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index 1c8f6e125271..0a18203749b3 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: '{0}' RollForward değeri geçersiz. İzin verilen değerler {1}. {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index b54de278b082..ec65c8b2a30a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: RollForward 值“{0}”无效。允许的值为 {1}。 {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index ebc5e6f3056e..4e13577ea6d4 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -395,9 +395,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1104: RollForward 值 '{0}' 無效。允許的值為 {1}。 {StrBegin="NETSDK1104: "} - - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. - NETSDK1138: {0} is not a valid Windows TargetPlatformVersion. + + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} + NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: +{2} {StrBegin="NETSDK1138: "} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets index ad4e68e5d284..09b0d7bd5b68 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets @@ -16,7 +16,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + - - + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets index 6ff7dd8f445e..ddd0bf04d462 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets @@ -188,6 +188,24 @@ Copyright (c) .NET Foundation. All rights reserved. FormatArguments="$(MinimumOSPlatform);$(TargetPlatformVersion)"/> + + + + + + + true + @(SupportedTargetPlatform, ', ') + None + + + + + - + From fcad556f5943ef77744e8b880a2aea6cbe129ebe Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Wed, 8 Jul 2020 12:19:29 -0700 Subject: [PATCH 3/7] Add WindowsOnlyRequiresMSBuildVersion fact and theory test attributes --- .../PublishWpfApp.cs | 2 +- ...OnlyRequiresMSBuildVersionFactAttribute.cs | 38 +++++++++++++++++++ ...lyRequiresMSBuildVersionTheoryAttribute.cs | 38 +++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs create mode 100644 src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs diff --git a/src/Tests/Microsoft.NET.Publish.Tests/PublishWpfApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishWpfApp.cs index fa8bf4ee719c..2b2a2f8b282b 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/PublishWpfApp.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishWpfApp.cs @@ -51,7 +51,7 @@ public void It_publishes_and_runs_self_contained_wpf_app() var publishCommand = new PublishCommand(Log, testDir.Path); - publishCommand.Execute($"/p:RuntimeIdentifier={rid}") + publishCommand.Execute($"/p:RuntimeIdentifier={rid}", "/p:TargetPlatformIdentifier=Windows", "/p:TargetPlatformVersion=7.0") .Should() .Pass(); diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs new file mode 100644 index 000000000000..505de584dd25 --- /dev/null +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Runtime.InteropServices; +using Xunit; + +namespace Microsoft.NET.TestFramework +{ + public class WindowsOnlyRequiresMSBuildVersionFactAttribute : FactAttribute + { + public WindowsOnlyRequiresMSBuildVersionFactAttribute(string version) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + this.Skip = "This test requires Windows to run"; + } + + if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) + { + if (!Version.TryParse(TestContext.Current.ToolsetUnderTest.MSBuildVersion, out Version msbuildVersion)) + { + this.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; + return; + } + if (!Version.TryParse(version, out Version requiredVersion)) + { + this.Skip = $"Failed to determine the version required by this test ({ version })."; + return; + } + if (requiredVersion > msbuildVersion) + { + this.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; + } + } + } + } +} diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs new file mode 100644 index 000000000000..f09485d839d8 --- /dev/null +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Runtime.InteropServices; +using Xunit; + +namespace Microsoft.NET.TestFramework +{ + public class WindowsOnlyRequiresMSBuildVersionTheoryAttribute : TheoryAttribute + { + public WindowsOnlyRequiresMSBuildVersionTheoryAttribute(string version) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + this.Skip = "This test requires Windows to run"; + } + + if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) + { + if (!Version.TryParse(TestContext.Current.ToolsetUnderTest.MSBuildVersion, out Version msbuildVersion)) + { + this.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; + return; + } + if (!Version.TryParse(version, out Version requiredVersion)) + { + this.Skip = $"Failed to determine the version required by this test ({ version })."; + return; + } + if (requiredVersion > msbuildVersion) + { + this.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; + } + } + } + } +} From ac85508c91667c0ce08ebe65f8ccc2d650d11e19 Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 23 Jul 2020 11:26:09 -0700 Subject: [PATCH 4/7] Fix merge issues --- ...ThatWeWantToBuildAWindowsDesktopProject.cs | 88 +------------------ .../RequiresMSBuildVersionFactAttribute.cs | 18 +--- .../RequiresMSBuildVersionTheoryAttribute.cs | 11 ++- ...OnlyRequiresMSBuildVersionFactAttribute.cs | 19 +--- ...lyRequiresMSBuildVersionTheoryAttribute.cs | 18 +--- 5 files changed, 12 insertions(+), 142 deletions(-) diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs index 2a8e091af7be..b8b1d07ef875 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs @@ -16,92 +16,6 @@ public class GivenThatWeWantToBuildAWindowsDesktopProject : SdkTest public GivenThatWeWantToBuildAWindowsDesktopProject(ITestOutputHelper log) : base(log) {} - [WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")] - [InlineData("UseWindowsForms")] - [InlineData("UseWPF")] - public void It_errors_when_missing_windows_target_platform(string propertyName) - { - var targetFramework = "net5.0"; - TestProject testProject = new TestProject() - { - Name = "MissingTargetPlatform", - IsSdkProject = true, - TargetFrameworks = targetFramework - }; - testProject.AdditionalProperties[propertyName] = "true"; - testProject.AdditionalProperties["TargetPlatformIdentifier"] = "custom"; // Make sure we don't get windows implicitly set as the TPI - var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: propertyName); - - var buildCommand = new BuildCommand(testAsset); - buildCommand.Execute() - .Should() - .Fail() - .And - .HaveStdOutContaining("NETSDK1136"); - } - - [WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")] - [InlineData("UseWindowsForms")] - [InlineData("UseWPF")] - public void It_errors_when_missing_transitive_windows_target_platform(string propertyName) - { - TestProject testProjectA = new TestProject() - { - Name = "A", - IsSdkProject = true, - ProjectSdk = "Microsoft.NET.Sdk.WindowsDesktop", - TargetFrameworks = "netcoreapp3.1" - }; - testProjectA.AdditionalProperties[propertyName] = "true"; - - TestProject testProjectB = new TestProject() - { - Name = "B", - IsSdkProject = true, - TargetFrameworks = "net5.0" - }; - testProjectB.ReferencedProjects.Add(testProjectA); - - TestProject testProjectC = new TestProject() - { - Name = "C", - IsSdkProject = true, - TargetFrameworks = "net5.0" - }; - testProjectC.ReferencedProjects.Add(testProjectB); - - var testAsset = _testAssetsManager.CreateTestProject(testProjectC); - - var buildCommand = new BuildCommand(testAsset); - buildCommand.Execute() - .Should() - .Fail() - .And - .HaveStdOutContaining("NETSDK1136"); - } - - [WindowsOnlyFact] - public void It_warns_when_specifying_windows_desktop_sdk() - { - var targetFramework = "net5.0"; - TestProject testProject = new TestProject() - { - Name = "windowsDesktopSdk", - IsSdkProject = true, - ProjectSdk = "Microsoft.NET.Sdk.WindowsDesktop", - TargetFrameworks = targetFramework - }; - testProject.AdditionalProperties["UseWPF"] = "true"; - var testAsset = _testAssetsManager.CreateTestProject(testProject); - - var buildCommand = new BuildCommand(testAsset); - buildCommand.Execute() - .Should() - .Pass() - .And - .HaveStdOutContaining("NETSDK1137"); - } - [WindowsOnlyFact] public void It_fails_if_windows_target_platform_version_is_invalid() { @@ -120,7 +34,7 @@ public void It_fails_if_windows_target_platform_version_is_invalid() .Should() .Fail() .And - .HaveStdOutContaining("NETSDK1138"); + .HaveStdOutContaining("NETSDK1137"); } } } diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionFactAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionFactAttribute.cs index b07de809567c..86f9ede5be93 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionFactAttribute.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionFactAttribute.cs @@ -10,23 +10,7 @@ public class RequiresMSBuildVersionFactAttribute : FactAttribute { public RequiresMSBuildVersionFactAttribute(string version) { - if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) - { - if (!Version.TryParse(TestContext.Current.ToolsetUnderTest.MSBuildVersion, out Version msbuildVersion)) - { - this.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; - return; - } - if (!Version.TryParse(version, out Version requiredVersion)) - { - this.Skip = $"Failed to determine the version required by this test ({ version })."; - return; - } - if (requiredVersion > msbuildVersion) - { - this.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; - } - } + RequiresMSBuildVersionTheoryAttribute.CheckForRequiredMSBuildVersion(this, version); } } } diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionTheoryAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionTheoryAttribute.cs index 09bca5f17035..86a7178144d4 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionTheoryAttribute.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresMSBuildVersionTheoryAttribute.cs @@ -9,22 +9,27 @@ namespace Microsoft.NET.TestFramework public class RequiresMSBuildVersionTheoryAttribute : TheoryAttribute { public RequiresMSBuildVersionTheoryAttribute(string version) + { + CheckForRequiredMSBuildVersion(this, version); + } + + public static void CheckForRequiredMSBuildVersion(FactAttribute attribute, string version) { if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) { if (!Version.TryParse(TestContext.Current.ToolsetUnderTest.MSBuildVersion, out Version msbuildVersion)) { - this.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; + attribute.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; return; } if (!Version.TryParse(version, out Version requiredVersion)) { - this.Skip = $"Failed to determine the version required by this test ({ version })."; + attribute.Skip = $"Failed to determine the version required by this test ({ version })."; return; } if (requiredVersion > msbuildVersion) { - this.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; + attribute.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; } } } diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs index 505de584dd25..c4fde2edb6c0 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionFactAttribute.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Runtime.InteropServices; using Xunit; @@ -16,23 +15,7 @@ public WindowsOnlyRequiresMSBuildVersionFactAttribute(string version) this.Skip = "This test requires Windows to run"; } - if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) - { - if (!Version.TryParse(TestContext.Current.ToolsetUnderTest.MSBuildVersion, out Version msbuildVersion)) - { - this.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; - return; - } - if (!Version.TryParse(version, out Version requiredVersion)) - { - this.Skip = $"Failed to determine the version required by this test ({ version })."; - return; - } - if (requiredVersion > msbuildVersion) - { - this.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; - } - } + RequiresMSBuildVersionTheoryAttribute.CheckForRequiredMSBuildVersion(this, version); } } } diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs index f09485d839d8..7b8f54ea0bdb 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/WindowsOnlyRequiresMSBuildVersionTheoryAttribute.cs @@ -16,23 +16,7 @@ public WindowsOnlyRequiresMSBuildVersionTheoryAttribute(string version) this.Skip = "This test requires Windows to run"; } - if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) - { - if (!Version.TryParse(TestContext.Current.ToolsetUnderTest.MSBuildVersion, out Version msbuildVersion)) - { - this.Skip = $"Failed to determine the version of MSBuild ({ TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; - return; - } - if (!Version.TryParse(version, out Version requiredVersion)) - { - this.Skip = $"Failed to determine the version required by this test ({ version })."; - return; - } - if (requiredVersion > msbuildVersion) - { - this.Skip = $"This test requires MSBuild version { version } to run (using { TestContext.Current.ToolsetUnderTest.MSBuildVersion })."; - } - } + RequiresMSBuildVersionTheoryAttribute.CheckForRequiredMSBuildVersion(this, version); } } } From ce24326278484529e962a5ff1a3c0fa98216e8ee Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 23 Jul 2020 11:33:37 -0700 Subject: [PATCH 5/7] PR feedback --- src/Tasks/Common/Resources/xlf/Strings.cs.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.de.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.es.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.fr.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.it.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.ja.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.ko.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.pl.xlf | 6 ++--- .../Common/Resources/xlf/Strings.pt-BR.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.ru.xlf | 6 ++--- src/Tasks/Common/Resources/xlf/Strings.tr.xlf | 6 ++--- .../Common/Resources/xlf/Strings.zh-Hans.xlf | 6 ++--- .../Common/Resources/xlf/Strings.zh-Hant.xlf | 6 ++--- ...osoft.NET.TargetFrameworkInference.targets | 2 +- ...ThatWeWantToBuildAWindowsDesktopProject.cs | 25 ++++++++++++++++--- 15 files changed, 62 insertions(+), 43 deletions(-) diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index a134d215d0b1..d421c0bf9cd1 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index d487cb593bef..416f89b041ad 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 292a444c6706..3b5bb3d0c23c 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index 0473480fe253..360ed8b4e65b 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index 2758c2118de4..2978b60f4709 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index c584233a2206..1250374f3d33 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index a700b210d3cb..e3b1a7550045 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index 5f9253426a47..7d7f027224ca 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index 0e7457c5b555..bef81f297da0 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index fe83375a86ff..8197f2d0c813 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index 0a18203749b3..06133c83bf5f 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index ec65c8b2a30a..e75184ce19eb 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 4e13577ea6d4..feb4d9439ff0 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -396,11 +396,11 @@ The following are names of parameters or literal values and should not be transl {StrBegin="NETSDK1104: "} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - NETSDK1138: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: + NETSDK1137: {0} is not a valid TargetPlatformVersion for {1}. Valid versions include: {2} - {StrBegin="NETSDK1138: "} + {StrBegin="NETSDK1137: "} NETSDK1061: The project was restored using {0} version {1}, but with current settings, version {2} would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets index ddd0bf04d462..07648482b186 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets @@ -197,7 +197,7 @@ Copyright (c) .NET Foundation. All rights reserved. true - @(SupportedTargetPlatform, ', ') + @(SupportedTargetPlatform, '%0a') None diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs index b8b1d07ef875..c367a4cb8f74 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs @@ -23,10 +23,8 @@ public void It_fails_if_windows_target_platform_version_is_invalid() { Name = "InvalidWindowsVersion", IsSdkProject = true, - TargetFrameworks = "net5.0" + TargetFrameworks = "net5.0-windows1.0" }; - testProject.AdditionalProperties["TargetPlatformIdentifier"] = "Windows"; - testProject.AdditionalProperties["TargetPlatformVersion"] = "1.0"; var testAsset = _testAssetsManager.CreateTestProject(testProject); var buildCommand = new BuildCommand(testAsset); @@ -36,5 +34,26 @@ public void It_fails_if_windows_target_platform_version_is_invalid() .And .HaveStdOutContaining("NETSDK1137"); } + + [Fact] + public void It_fails_if_target_platform_identifier_and_version_are_invalid() + { + var testProject = new TestProject() + { + Name = "InvalidTargetPlatform", + IsSdkProject = true, + TargetFrameworks = "net5.0-custom1.0" + }; + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var buildCommand = new BuildCommand(testAsset); + buildCommand.Execute() + .Should() + .Fail() + .And + .HaveStdOutContaining("NETSDK1136") + .And + .NotHaveStdOutContaining("NETSDK1137"); + } } } From f2832693679cf750b089c3c065302d7bced21e5c Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Fri, 17 Jul 2020 08:36:22 -0700 Subject: [PATCH 6/7] Clean up from merge --- .../targets/Microsoft.NET.TargetFrameworkInference.targets | 6 +++--- .../GivenThatWeWantToBuildALibrary.cs | 1 - .../GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs | 3 +++ .../GivenThatWeWantToBuildWithATargetPlatform.cs | 7 ++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets index 07648482b186..00e0c9e878d2 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets @@ -60,7 +60,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 3)) @@ -108,7 +108,7 @@ Copyright (c) .NET Foundation. All rights reserved. + Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0))" > true @@ -116,7 +116,7 @@ Copyright (c) .NET Foundation. All rights reserved. + FormatArguments="$(TargetPlatformIdentifier)" /> diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs index 3cdc72165b7a..796096daabf0 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs @@ -790,7 +790,6 @@ public void It_passes_ridless_target_to_compiler() .Pass(); } - // TODO: need to set TargetPlatformSupported in MSBuild.SDK.Extras for this to pass [Fact] public void It_can_target_uwp_using_sdk_extras() { diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs index 2b5375744620..de03a97b2a33 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs @@ -38,6 +38,7 @@ public void WhenPropertiesAreSetItCanGenerateMinimumOSPlatformAttribute() var targetPlatformIdentifier = "iOS"; testProject.AdditionalProperties["TargetPlatformIdentifier"] = targetPlatformIdentifier; + testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; testProject.AdditionalProperties["MinimumOSPlatform"] = "13.2"; testProject.AdditionalProperties["TargetPlatformVersion"] = "14.0"; testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; @@ -58,6 +59,7 @@ public void WhenMinimumOSPlatformISNotSetTargetPlatformVersionIsSetItCanGenerate var targetPlatformIdentifier = "iOS"; testProject.AdditionalProperties["TargetPlatformIdentifier"] = targetPlatformIdentifier; + testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; testProject.AdditionalProperties["TargetPlatformVersion"] = "13.2"; testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; @@ -77,6 +79,7 @@ public void WhenMinimumOSPlatformIsHigherThanTargetPlatformVersionItShouldError( var targetPlatformIdentifier = "iOS"; testProject.AdditionalProperties["TargetPlatformIdentifier"] = targetPlatformIdentifier; + testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; testProject.AdditionalProperties["TargetPlatformVersion"] = "13.2"; testProject.AdditionalProperties["MinimumOSPlatform"] = "14.0"; testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs index e2fc4ad6971d..9f35771dd8bc 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs @@ -19,7 +19,7 @@ public GivenThatWeWantToBuildWithATargetPlatform(ITestOutputHelper log) : base(l { } - [Theory] + [WindowsOnlyTheory] [InlineData("netcoreapp3.1", ".NETCoreApp", "v3.1", "Windows", "7.0")] // Default values pre-5.0 [InlineData("net5.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] [InlineData("net5.0-Windows7.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] @@ -38,10 +38,7 @@ public void It_defines_target_platform_from_target_framework(string targetFramew Action assertValue = (string valueName, string expected) => { - var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.Path, testProj.Name), targetFramework, valueName) - { - DependsOnTargets = "BeforeBuild" - }; + var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.Path, testProj.Name), targetFramework, valueName); getValuesCommand .Execute() .Should() From b2048933fb17b2642eae1a3f0b5ef18dacdd5e3d Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 23 Jul 2020 15:02:48 -0700 Subject: [PATCH 7/7] Only set Windows as target platform when UseWPF or UseWindowsForms --- ...osoft.NET.TargetFrameworkInference.targets | 10 +++++ .../GivenThatWeWantToBuildALibrary.cs | 39 ++++++++++++++++++- ...WantToBuildALibraryWithOSMinimumVersion.cs | 4 +- .../GivenThatWeWantToBuildALibraryWithVB.cs | 2 +- ...venThatWeWantToBuildWithATargetPlatform.cs | 2 +- 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets index 00e0c9e878d2..632dcbc931a6 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets @@ -160,6 +160,16 @@ Copyright (c) .NET Foundation. All rights reserved. ResourceName="CppRequiresTFMVersion31" /> + + + <_EnableDefaultWindowsPlatform>false + false + + + + + Windows + 2.1 diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs index 796096daabf0..510a1120169f 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs @@ -417,7 +417,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_framework itemGroup.Add(supportedFramework); }); - AssertDefinedConstantsOutput(testAsset, targetFramework, new[] { "NETCOREAPP", "NET", "WINDOWS", "WINDOWS7_0" }.Concat(expectedDefines).ToArray()); + AssertDefinedConstantsOutput(testAsset, targetFramework, new[] { "NETCOREAPP", "NET"}.Concat(expectedDefines).ToArray()); } [Theory] @@ -605,6 +605,43 @@ public void It_fails_gracefully_if_targetframework_should_be_targetframeworks(bo $"The TargetFramework value '{targetFramework}' is not valid. To multi-target, use the 'TargetFrameworks' property instead"); } + [WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")] + [InlineData("net5.0", "", false)] + [InlineData("net5.0", "UseWPF", true)] + [InlineData("net5.0", "UseWindowsForms", true)] + [InlineData("netcoreapp3.1", "", true)] + public void It_defines_target_platform_defaults_correctly(string targetFramework, string propertyName, bool defaultsDefined) + { + TestProject testProject = new TestProject() + { + Name = "TargetPlatformDefaults", + IsSdkProject = true, + TargetFrameworks = targetFramework + }; + + if (!propertyName.Equals(string.Empty)) + { + testProject.AdditionalProperties[propertyName] = "true"; + } + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name), targetFramework, "TargetPlatformIdentifier"); + getValuesCommand + .Execute() + .Should() + .Pass(); + var values = getValuesCommand.GetValues(); + if (defaultsDefined) + { + values.Count().Should().Be(1); + values.FirstOrDefault().Should().Be("Windows"); + } + else + { + values.Count().Should().Be(0); + } + } + [Theory] [InlineData("net5.0")] [InlineData("netcoreapp3.1")] diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs index de03a97b2a33..c2c033013ba4 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSMinimumVersion.cs @@ -39,9 +39,9 @@ public void WhenPropertiesAreSetItCanGenerateMinimumOSPlatformAttribute() var targetPlatformIdentifier = "iOS"; testProject.AdditionalProperties["TargetPlatformIdentifier"] = targetPlatformIdentifier; testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; + testProject.AdditionalProperties["TargetPlatformVersionSupported"] = "true"; testProject.AdditionalProperties["MinimumOSPlatform"] = "13.2"; testProject.AdditionalProperties["TargetPlatformVersion"] = "14.0"; - testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; var testAsset = _testAssetsManager.CreateTestProject(testProject); @@ -60,8 +60,8 @@ public void WhenMinimumOSPlatformISNotSetTargetPlatformVersionIsSetItCanGenerate var targetPlatformIdentifier = "iOS"; testProject.AdditionalProperties["TargetPlatformIdentifier"] = targetPlatformIdentifier; testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; + testProject.AdditionalProperties["TargetPlatformVersionSupported"] = "true"; testProject.AdditionalProperties["TargetPlatformVersion"] = "13.2"; - testProject.AdditionalProperties["TargetPlatformSupported"] = "true"; var testAsset = _testAssetsManager.CreateTestProject(testProject); diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs index 0afbfeaa3d39..def9568c0323 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs @@ -195,7 +195,7 @@ public void It_implicitly_defines_compilation_constants_for_the_configuration(st [InlineData("net45", new[] { "NETFRAMEWORK=-1", "NET45=-1" }, true)] [InlineData("net461", new[] { "NETFRAMEWORK=-1", "NET461=-1" }, true)] [InlineData("netcoreapp1.0", new[] { "NETCOREAPP=-1", "NETCOREAPP1_0=-1", "_MyType=\"Empty\"" }, false)] - [InlineData("net5.0", new[] { "NET=-1", "NET5_0=-1", "NETCOREAPP=-1", "NETCOREAPP3_1=-1", "WINDOWS=-1", "WINDOWS7_0=-1", "_MyType=\"Empty\"" }, false)] + [InlineData("net5.0", new[] { "NET=-1", "NET5_0=-1", "NETCOREAPP=-1", "NETCOREAPP3_1=-1", "_MyType=\"Empty\"" }, false)] [InlineData(".NETPortable,Version=v4.5,Profile=Profile78", new string[] { "_MyType=\"Empty\"" }, false)] [InlineData(".NETFramework,Version=v4.0,Profile=Client", new string[] { "NETFRAMEWORK=-1", "NET40=-1" }, false)] [InlineData("Xamarin.iOS,Version=v1.0", new string[] { "XAMARINIOS=-1", "XAMARINIOS1_0=-1", "_MyType=\"Empty\"" }, false)] diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs index 9f35771dd8bc..1e980ec3caee 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs @@ -21,7 +21,7 @@ public GivenThatWeWantToBuildWithATargetPlatform(ITestOutputHelper log) : base(l [WindowsOnlyTheory] [InlineData("netcoreapp3.1", ".NETCoreApp", "v3.1", "Windows", "7.0")] // Default values pre-5.0 - [InlineData("net5.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] + [InlineData("net5.0", ".NETCoreApp", "v5.0", "", "")] [InlineData("net5.0-Windows7.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] [InlineData("net5.0-WINDOWS7.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] [InlineData("net5.0-windows", ".NETCoreApp", "v5.0", "Windows", "7.0")]