From 35af8b020c62af49624ea0493b9e76932d3987e4 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 18 Jan 2018 10:56:08 -0800 Subject: [PATCH] Move validation for .NET Core RID in-box Previously, Microsoft.NETCore.App package would do this in a custom target with the PackageDependency items that we no longer raise by default. Also, use repo-toolset to generate designer code for resx during build. There was a project system bug preventing it from getting generated in VS. --- sdk.sln | 1 - .../Common/Resources/Strings.Designer.cs | 462 ------------------ 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 + ...icrosoft.NET.Build.Extensions.Tasks.csproj | 22 +- .../Microsoft.NET.Build.Tasks.csproj | 24 +- .../ResolvePackageAssets.cs | 53 ++ ...rosoft.PackageDependencyResolution.targets | 7 +- ...enThatWeWantToPublishAHelloWorldProject.cs | 30 ++ 21 files changed, 167 insertions(+), 502 deletions(-) delete mode 100644 src/Tasks/Common/Resources/Strings.Designer.cs diff --git a/sdk.sln b/sdk.sln index 134f67350fa6..c8258b5f09f0 100644 --- a/sdk.sln +++ b/sdk.sln @@ -59,7 +59,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{09AD2F EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resources", "Resources", "{7D6CD7B6-0237-40DD-9911-44FF22292131}" ProjectSection(SolutionItems) = preProject - src\Tasks\Common\Resources\Strings.Designer.cs = src\Tasks\Common\Resources\Strings.Designer.cs src\Tasks\Common\Resources\Strings.resx = src\Tasks\Common\Resources\Strings.resx EndProjectSection EndProject diff --git a/src/Tasks/Common/Resources/Strings.Designer.cs b/src/Tasks/Common/Resources/Strings.Designer.cs deleted file mode 100644 index b70b6860effb..000000000000 --- a/src/Tasks/Common/Resources/Strings.Designer.cs +++ /dev/null @@ -1,462 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.NET.Build.Tasks { - using System; - using System.Reflection; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static System.Resources.ResourceManager resourceMan; - - private static System.Globalization.CultureInfo resourceCulture; - - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager { - get { - if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Microsoft.NET.Build.Tasks.Resources.Strings", typeof(Strings).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - internal static string AtLeastOneTargetFrameworkMustBeSpecified { - get { - return ResourceManager.GetString("AtLeastOneTargetFrameworkMustBeSpecified", resourceCulture); - } - } - - internal static string NoCompatibleTargetFramework { - get { - return ResourceManager.GetString("NoCompatibleTargetFramework", resourceCulture); - } - } - - internal static string InvalidFrameworkName { - get { - return ResourceManager.GetString("InvalidFrameworkName", resourceCulture); - } - } - - internal static string AssetsFileNotFound { - get { - return ResourceManager.GetString("AssetsFileNotFound", resourceCulture); - } - } - - internal static string AssetsFileMissingTarget { - get { - return ResourceManager.GetString("AssetsFileMissingTarget", resourceCulture); - } - } - - internal static string AssetsFilePathNotRooted { - get { - return ResourceManager.GetString("AssetsFilePathNotRooted", resourceCulture); - } - } - - internal static string CannotFindProjectInfo { - get { - return ResourceManager.GetString("CannotFindProjectInfo", resourceCulture); - } - } - - internal static string ContentFileDoesNotContainExpectedParentPackageInformation { - get { - return ResourceManager.GetString("ContentFileDoesNotContainExpectedParentPackageInformation", resourceCulture); - } - } - - internal static string MissingItemMetadata { - get { - return ResourceManager.GetString("MissingItemMetadata", resourceCulture); - } - } - - internal static string UnrecognizedPreprocessorToken { - get { - return ResourceManager.GetString("UnrecognizedPreprocessorToken", resourceCulture); - } - } - - internal static string ContentPreproccessorParameterRequired { - get { - return ResourceManager.GetString("ContentPreproccessorParameterRequired", resourceCulture); - } - } - - internal static string ProjectAssetsConsumedWithoutMSBuildProjectPath { - get { - return ResourceManager.GetString("ProjectAssetsConsumedWithoutMSBuildProjectPath", resourceCulture); - } - } - - internal static string UnexpectedFileType { - get { - return ResourceManager.GetString("UnexpectedFileType", resourceCulture); - } - } - - internal static string CannotInferTargetFrameworkIdentiferAndVersion { - get { - return ResourceManager.GetString("CannotInferTargetFrameworkIdentiferAndVersion", resourceCulture); - } - } - - internal static string ContentItemDoesNotProvideOutputPath { - get { - return ResourceManager.GetString("ContentItemDoesNotProvideOutputPath", resourceCulture); - } - } - - internal static string DuplicatePreprocessorToken { - get { - return ResourceManager.GetString("DuplicatePreprocessorToken", resourceCulture); - } - } - - internal static string ErrorsOccurredWhenEmittingSatelliteAssembly { - get { - return ResourceManager.GetString("ErrorsOccurredWhenEmittingSatelliteAssembly", resourceCulture); - } - } - - internal static string UnableToFindResolvedPath { - get { - return ResourceManager.GetString("UnableToFindResolvedPath", resourceCulture); - } - } - - internal static string UnexpectedDependencyWithNoVersionNumber { - get { - return ResourceManager.GetString("UnexpectedDependencyWithNoVersionNumber", resourceCulture); - } - } - - internal static string AssetPreprocessorMustBeConfigured { - get { - return ResourceManager.GetString("AssetPreprocessorMustBeConfigured", resourceCulture); - } - } - - internal static string InvalidNuGetVersionString { - get { - return ResourceManager.GetString("InvalidNuGetVersionString", resourceCulture); - } - } - - internal static string DOTNET1011 { - get { - return ResourceManager.GetString("DOTNET1011", resourceCulture); - } - } - - internal static string DOTNET1012 { - get { - return ResourceManager.GetString("DOTNET1012", resourceCulture); - } - } - - internal static string DOTNET1013 { - get { - return ResourceManager.GetString("DOTNET1013", resourceCulture); - } - } - - internal static string DOTNET1014 { - get { - return ResourceManager.GetString("DOTNET1014", resourceCulture); - } - } - - internal static string DOTNET1017 { - get { - return ResourceManager.GetString("DOTNET1017", resourceCulture); - } - } - - internal static string NU1001 { - get { - return ResourceManager.GetString("NU1001", resourceCulture); - } - } - - internal static string NU1002 { - get { - return ResourceManager.GetString("NU1002", resourceCulture); - } - } - - internal static string NU1006 { - get { - return ResourceManager.GetString("NU1006", resourceCulture); - } - } - - internal static string NU1007 { - get { - return ResourceManager.GetString("NU1007", resourceCulture); - } - } - - internal static string NU1008 { - get { - return ResourceManager.GetString("NU1008", resourceCulture); - } - } - - internal static string NU1009 { - get { - return ResourceManager.GetString("NU1009", resourceCulture); - } - } - - internal static string NU1010 { - get { - return ResourceManager.GetString("NU1010", resourceCulture); - } - } - - internal static string NU1011 { - get { - return ResourceManager.GetString("NU1011", resourceCulture); - } - } - - internal static string NU1012 { - get { - return ResourceManager.GetString("NU1012", resourceCulture); - } - } - - internal static string IncorrectPackageRoot { - get { - return ResourceManager.GetString("IncorrectPackageRoot", resourceCulture); - } - } - - internal static string MultipleFilesResolved { - get { - return ResourceManager.GetString("MultipleFilesResolved", resourceCulture); - } - } - - internal static string DuplicateItemsError { - get { - return ResourceManager.GetString("DuplicateItemsError", resourceCulture); - } - } - - internal static string PackageReferenceOverrideWarning { - get { - return ResourceManager.GetString("PackageReferenceOverrideWarning", resourceCulture); - } - } - - internal static string FolderAlreadyExists { - get { - return ResourceManager.GetString("FolderAlreadyExists", resourceCulture); - } - } - - internal static string IncorrectTargetFormat { - get { - return ResourceManager.GetString("IncorrectTargetFormat", resourceCulture); - } - } - - internal static string ParsingFiles { - get { - return ResourceManager.GetString("ParsingFiles", resourceCulture); - } - } - - internal static string PackageInfoLog { - get { - return ResourceManager.GetString("PackageInfoLog", resourceCulture); - } - } - - internal static string RuntimeIdentifierWasNotSpecified { - get { - return ResourceManager.GetString("RuntimeIdentifierWasNotSpecified", resourceCulture); - } - } - - internal static string AppHostHasBeenModified { - get { - return ResourceManager.GetString("AppHostHasBeenModified", resourceCulture); - } - } - - internal static string FileNameIsTooLong { - get { - return ResourceManager.GetString("FileNameIsTooLong", resourceCulture); - } - } - - internal static string CannotHaveSelfContainedWithoutRuntimeIdentifier { - get { - return ResourceManager.GetString("CannotHaveSelfContainedWithoutRuntimeIdentifier", resourceCulture); - } - } - - internal static string CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget { - get { - return ResourceManager.GetString("CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget", resourceCulture); - } - } - - internal static string ChoosingAssemblyVersion { - get { - return ResourceManager.GetString("ChoosingAssemblyVersion", resourceCulture); - } - } - - internal static string ChoosingFileVersion { - get { - return ResourceManager.GetString("ChoosingFileVersion", resourceCulture); - } - } - - internal static string ChoosingPlatformItem { - get { - return ResourceManager.GetString("ChoosingPlatformItem", resourceCulture); - } - } - - internal static string ChoosingPreferredPackage { - get { - return ResourceManager.GetString("ChoosingPreferredPackage", resourceCulture); - } - } - - internal static string ConflictCouldNotDetermineWinner { - get { - return ResourceManager.GetString("ConflictCouldNotDetermineWinner", resourceCulture); - } - } - - internal static string CouldNotDetermineWinner_DoesntExist { - get { - return ResourceManager.GetString("CouldNotDetermineWinner_DoesntExist", resourceCulture); - } - } - - internal static string CouldNotDetermineWinner_FileVersion { - get { - return ResourceManager.GetString("CouldNotDetermineWinner_FileVersion", resourceCulture); - } - } - - internal static string CouldNotDetermineWinner_NotAnAssembly { - get { - return ResourceManager.GetString("CouldNotDetermineWinner_NotAnAssembly", resourceCulture); - } - } - - internal static string EncounteredConflict { - get { - return ResourceManager.GetString("EncounteredConflict", resourceCulture); - } - } - - internal static string CouldNotLoadPlatformManifest { - get { - return ResourceManager.GetString("CouldNotLoadPlatformManifest", resourceCulture); - } - } - - internal static string ErrorParsingFrameworkListInvalidValue - { - get - { - return ResourceManager.GetString("ErrorParsingFrameworkListInvalidValue", resourceCulture); - } - } - - internal static string ErrorParsingPlatformManifest { - get { - return ResourceManager.GetString("ErrorParsingPlatformManifest", resourceCulture); - } - } - - internal static string ErrorParsingPlatformManifestInvalidValue { - get { - return ResourceManager.GetString("ErrorParsingPlatformManifestInvalidValue", resourceCulture); - } - } - - internal static string UnsupportedTargetFrameworkVersion { - get { - return ResourceManager.GetString("UnsupportedTargetFrameworkVersion", resourceCulture); - } - } - - internal static string TargetFrameworkWithSemicolon { - get { - return ResourceManager.GetString("TargetFrameworkWithSemicolon", resourceCulture); - } - } - - internal static string AssetsFileMissingRuntimeIdentifier { - get { - return ResourceManager.GetString("AssetsFileMissingRuntimeIdentifier", resourceCulture); - } - } - - internal static string SkippingAdditionalProbingPaths { - get { - return ResourceManager.GetString("SkippingAdditionalProbingPaths", resourceCulture); - } - } - - internal static string GetDependsOnNETStandardFailedWithException { - get { - return ResourceManager.GetString("GetDependsOnNETStandardFailedWithException", resourceCulture); - } - } - - internal static string UnsupportedSDKVersionForNetStandard20 { - get { - return ResourceManager.GetString("UnsupportedSDKVersionForNetStandard20", resourceCulture); - } - } - - internal static string FrameworkListPathNotRooted - { - get - { - return ResourceManager.GetString("FrameworkListPathNotRooted", resourceCulture); - } - } - } -} diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index b823db3edafc..bd7e909f065b 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -324,4 +324,7 @@ Pack as tool does not support self contained. - + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index 2e377e66a678..d08a3c20291a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index cd87438d9209..aa34aa6aec37 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 80758cf66c49..7ad75bc8701b 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index c351c4b6b4f2..727c3efa27e2 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index fc425d76e08d..5a0c8bd48566 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index 25a8fedfbda9..2152d0173634 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index 888a7e1de773..4b5e25b2e0b6 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index 2394d18b2587..194f2122e28a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index e1dee634a0c4..fdadd25a0d01 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index 49fb0c69250c..a2de130d1f0f 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index f83859abf3fe..c150bcbe41f2 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index c4b21622653f..51d2fb1308e0 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index b685565818bd..a2d095b812ef 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -347,6 +347,11 @@ Pack as tool does not support self contained. + + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + Project is targeting runtime '{0}' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. + + \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/Microsoft.NET.Build.Extensions.Tasks.csproj b/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/Microsoft.NET.Build.Extensions.Tasks.csproj index 9e179faf972a..3eb47153f383 100644 --- a/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/Microsoft.NET.Build.Extensions.Tasks.csproj +++ b/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/Microsoft.NET.Build.Extensions.Tasks.csproj @@ -50,32 +50,18 @@ - + - - True - True - Strings.resx - - - - - - ResXFileCodeGenerator - Strings.Designer.cs - Microsoft.NET.Build.Tasks - + - - - msbuildExtensions\Microsoft\Microsoft.NET.Build.Extensions\%(FileName)%(Extension) - + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj index 6deee44d305a..8446b74b778f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj +++ b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj @@ -49,23 +49,11 @@ - + - - True - True - Strings.resx - - - - - - ResXFileCodeGenerator - Strings.Designer.cs - Microsoft.NET.Build.Tasks - + @@ -74,12 +62,10 @@ - + - - build\%(FileName)%(Extension) - - + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs index 13194644e492..460e0924d674 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs @@ -36,6 +36,8 @@ public class ResolvePackageAssets : TaskBase public bool MarkPackageReferencesAsExternallyResolved { get; set; } + public bool EnsureNETCoreAppRuntime { get; set; } + [Output] public ITaskItem[] Analyzers { get; private set; } @@ -63,8 +65,12 @@ public class ResolvePackageAssets : TaskBase [Output] public ITaskItem[] TransitiveProjectReferences { get; private set; } + private NuGetPackageResolver _packageResolver; + private const string NETCoreAppFrameworkName = ".NETCoreApp"; + private const string NETCoreAppPackageName = "Microsoft.NETCore.App"; + protected override void ExecuteCore() { var lockFile = new LockFileCache(BuildEngine4).GetLockFile(ProjectAssetsFile); @@ -74,6 +80,13 @@ protected override void ExecuteCore() var compileTimeTarget = lockFile.GetTargetAndThrowIfNotFound(targetFramework, runtime: null); var runtimeTarget = lockFile.GetTargetAndThrowIfNotFound(targetFramework, RuntimeIdentifier); + if (EnsureNETCoreAppRuntime + && !string.IsNullOrEmpty(RuntimeIdentifier) + && targetFramework.Framework == NETCoreAppFrameworkName) + { + CheckForNETCoreAppRuntime(compileTimeTarget, runtimeTarget); + } + Analyzers = RaiseAnalyzers( lockFile, runtimeTarget); @@ -367,6 +380,43 @@ private static Dictionary GetProjectReferencePaths(LockFile lock return paths; } + private void CheckForNETCoreAppRuntime(LockFileTarget compileTimeTarget, LockFileTarget runtimeTarget) + { + LockFileTargetLibrary compileTimeLibrary = GetNETCoreAppLibrary(compileTimeTarget); + if (compileTimeLibrary == null) + { + return; // Microsoft.NETCore.App not referenced; no error. + } + + bool hasRuntimeSpecificNETCoreAppPackageDependency = false; + LockFileTargetLibrary runtimeLibrary = GetNETCoreAppLibrary(runtimeTarget); + if (runtimeLibrary != null) + { + var compileTimeDependencies = GetDependencySet(compileTimeLibrary); + var runtimeDependencies = GetDependencySet(compileTimeLibrary); + runtimeDependencies.ExceptWith(compileTimeDependencies); + + hasRuntimeSpecificNETCoreAppPackageDependency = runtimeDependencies.Count > 0; + } + + if (!hasRuntimeSpecificNETCoreAppPackageDependency) + { + Log.LogError(Strings.UnsupportedNETCoreAppRuntimeIdentifier, RuntimeIdentifier); + } + } + + private static HashSet GetDependencySet(LockFileTargetLibrary package) + { + var set = new HashSet(StringComparer.OrdinalIgnoreCase); + + foreach (var l in package.Dependencies) + { + set.Add(l.Id); + } + + return set; + } + private static bool IsPackage(LockFileTargetLibrary library) => library.Type == "package"; @@ -385,5 +435,8 @@ private static bool IsPlaceholder(LockFileItem asset) private static string NormalizeRelativePath(string relativePath) => relativePath.Replace('/', Path.DirectorySeparatorChar); + + private static LockFileTargetLibrary GetNETCoreAppLibrary(LockFileTarget compileTimeTarget) + => compileTimeTarget.Libraries.FirstOrDefault(p => p.Name == NETCoreAppPackageName); } } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets index bb3763b07f6d..b7a4f9538d12 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets @@ -164,7 +164,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + @@ -192,6 +192,10 @@ Copyright (c) .NET Foundation. All rights reserved. Condition=" '$(DesignTimeBuild)' != 'true' Or Exists('$(ProjectAssetsFile)')" DependsOnTargets="ReportAssetsLogMessages"> + + true + +