diff --git a/README.md b/README.md index e99d726ed..02abd5534 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The current official release of the csproj-enabled CLI tools is **CLI Preview 4* There are a couple of things to keep in mind: * Preview 4 CLI bits are still **in development** so some rough edges are to be expected. -* Preview 4 bits **do not support** project.json so you will have to either keep Preview 2 tools around or migrate your project. You can find more information on this using the [project.json to csproj instructions](https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/ProjectJsonToCSProj.md). +* Preview 4 bits **do not support** project.json so you will have to either keep Preview 2 tools around or migrate your project or add a global.json file to your project to target preview2. You can find more information on this using the [project.json to csproj instructions](https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/ProjectJsonToCSProj.md). * Preview 4 refers to the **CLI tools only** and does not cover Visual Studio, VS Code or Visual Studio for Mac. * We welcome any and all issues that relate to MSBuild-based tools, so feel free to try them out and leave comments and file any bugs/problems. diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 6c674f057..2b34bd344 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -11,6 +11,23 @@ bring it to our attention. Post an issue or email us: The attached notices are provided for information only. +License notice for Nuget.Client +------------------------------- + +Copyright (c) .NET Foundation. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +these files except in compliance with the License. You may obtain a copy of the +License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + + License notice for LZMA SDK --------------------------- diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/NoSolutionItemsAfterMigration.sln b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/NoSolutionItemsAfterMigration.sln new file mode 100644 index 000000000..da0ae5935 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/NoSolutionItemsAfterMigration.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26006.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.xproj", "{D65E5A1F-719F-4F95-8835-88BDD67AD457}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FAACC4BE-31AE-4EB7-A4C8-5BB4617EB4AF}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x64.ActiveCfg = Debug|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x64.Build.0 = Debug|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x86.ActiveCfg = Debug|x86 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x86.Build.0 = Debug|x86 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|Any CPU.Build.0 = Release|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x64.ActiveCfg = Release|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x64.Build.0 = Release|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x86.ActiveCfg = Release|x86 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/ReadmeSolutionItemAfterMigration.sln b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/ReadmeSolutionItemAfterMigration.sln new file mode 100644 index 000000000..05aecb75d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/ReadmeSolutionItemAfterMigration.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26006.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.xproj", "{D65E5A1F-719F-4F95-8835-88BDD67AD457}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FAACC4BE-31AE-4EB7-A4C8-5BB4617EB4AF}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + readme.txt = readme.txt + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x64.ActiveCfg = Debug|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x64.Build.0 = Debug|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x86.ActiveCfg = Debug|x86 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Debug|x86.Build.0 = Debug|x86 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|Any CPU.Build.0 = Release|Any CPU + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x64.ActiveCfg = Release|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x64.Build.0 = Release|x64 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x86.ActiveCfg = Release|x86 + {D65E5A1F-719F-4F95-8835-88BDD67AD457}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/Program.cs similarity index 59% rename from TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs rename to TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/Program.cs index bd9a33ffe..2289ac741 100644 --- a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/Program.cs @@ -2,14 +2,14 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; - -namespace TestLibrary +namespace TestApp { - public static class Helper + public class Program { - public static void SayHi() + public static int Main(string[] args) { - Console.WriteLine("Hello there!"); + Console.WriteLine("Hello World!"); + return 0; } } } diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/TestApp.xproj b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/TestApp.xproj new file mode 100644 index 000000000..d18702195 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/TestApp.xproj @@ -0,0 +1,18 @@ + + + + 14.0.23107 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 0138cb8f-4aa9-4029-a21e-c07c30f425ba + TestAppWithContents + ..\..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\..\artifacts\ + + + 2.0 + + + diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/project.json new file mode 100644 index 000000000..166d41c2b --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/TestApp/project.json @@ -0,0 +1,26 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + "dependencies": { + "Microsoft.NETCore.App": "1.0.1" + }, + "frameworks": { + "netcoreapp1.0": {} + }, + "runtimes": { + "win7-x64": {}, + "win7-x86": {}, + "osx.10.10-x64": {}, + "osx.10.11-x64": {}, + "ubuntu.14.04-x64": {}, + "ubuntu.16.04-x64": {}, + "centos.7-x64": {}, + "rhel.7.2-x64": {}, + "debian.8-x64": {}, + "fedora.23-x64": {}, + "opensuse.13.2-x64": {} + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/global.json b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/global.json new file mode 100644 index 000000000..22936715c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "." ] +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/readme.txt b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/readme.txt new file mode 100644 index 000000000..6e3eb33f4 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndSolutionItemsToMoveToBackup/readme.txt @@ -0,0 +1 @@ +This is just for our test to verify that we do not remove the readme.txt link from the solution. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefThatRefsCsprojWhereSlnDoesNotRefCsproj/TestApp/src/subdir/subdir.csproj b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefThatRefsCsprojWhereSlnDoesNotRefCsproj/TestApp/src/subdir/subdir.csproj index cec816e3f..731464ac2 100644 --- a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefThatRefsCsprojWhereSlnDoesNotRefCsproj/TestApp/src/subdir/subdir.csproj +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefThatRefsCsprojWhereSlnDoesNotRefCsproj/TestApp/src/subdir/subdir.csproj @@ -8,12 +8,6 @@ F8F96F4A-F10C-4C54-867C-A9EFF55494C8 - - - - - - 1.6.0 diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs index c56978bf5..2906f8bbf 100644 --- a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs @@ -2,9 +2,9 @@ using System; namespace App.Tests { - public class Program + public class TestAssetProgram { - public static void Main(string[] args) + public static void TestAssetMain(string[] args) { Console.WriteLine("Hello World!"); } diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompilation/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompilation/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompilation/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompilation/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompilation/project.json new file mode 100644 index 000000000..9f677856d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompilation/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "compilerName": "csc", + "compilationOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/Helper1.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/Helper1.cs new file mode 100644 index 000000000..dd2447c0f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/Helper1.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Helper1 + { + public static string GetMessage() + { + return "Hello from Helper1 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/Helper2.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/Helper2.cs new file mode 100644 index 000000000..eeabb8a3d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/Helper2.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Helper2 + { + public static string GetMessage() + { + return "Hello from Helper2 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/IncludeThis.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/IncludeThis.cs new file mode 100644 index 000000000..d9300fe2d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/IncludeThis.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class IncludeThis + { + public static string GetMessage() + { + return "Hello from IncludeThis class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/Program.cs new file mode 100644 index 000000000..67d7bea12 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine(IncludeThis.GetMessage()); + Console.WriteLine(Helper1.GetMessage()); + Console.WriteLine(Helper2.GetMessage()); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/project.json new file mode 100644 index 000000000..87eeadaa3 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompile/project/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "compile": "../Helper1.cs", + "compileFiles": "../Helper2.cs", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/HelperBuiltIn1.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/HelperBuiltIn1.cs new file mode 100644 index 000000000..042fc53d1 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/HelperBuiltIn1.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class HelperBuiltIn1 + { + public static string GetMessage() + { + return "Hello from HelperBuiltIn1 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/HelperBuiltIn2.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/HelperBuiltIn2.cs new file mode 100644 index 000000000..5ba00add3 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/HelperBuiltIn2.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class HelperBuiltIn2 + { + public static string GetMessage() + { + return "Hello from HelperBuiltIn2 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/IncludeThis.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/IncludeThis.cs new file mode 100644 index 000000000..d9300fe2d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/IncludeThis.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class IncludeThis + { + public static string GetMessage() + { + return "Hello from IncludeThis class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/Program.cs new file mode 100644 index 000000000..bf3f8b064 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine(IncludeThis.GetMessage()); + Console.WriteLine(HelperBuiltIn1.GetMessage()); + Console.WriteLine(HelperBuiltIn2.GetMessage()); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/project.json new file mode 100644 index 000000000..7418df38c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileBuiltIn/project/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "compileBuiltIn": [ "Program.cs", "IncludeThis.cs", "../HelperBuiltIn1.cs", "../HelperBuiltIn2.cs" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/ExcludeThis1.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/ExcludeThis1.cs new file mode 100644 index 000000000..c8ee6c75e --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/ExcludeThis1.cs @@ -0,0 +1 @@ +This does not compile but is used to test compile exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/ExcludeThis2.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/ExcludeThis2.cs new file mode 100644 index 000000000..c8ee6c75e --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/ExcludeThis2.cs @@ -0,0 +1 @@ +This does not compile but is used to test compile exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/project.json new file mode 100644 index 000000000..3b457a6dc --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedCompileExclude/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "compileExclude": "ExcludeThis1.cs", + "exclude": [ "ExcludeThis2.cs" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFile1.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFile1.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFile1.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFile2.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFile2.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFile2.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFileBuiltIn1.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFileBuiltIn1.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFileBuiltIn1.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFileBuiltIn2.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFileBuiltIn2.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/ContentFileBuiltIn2.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/ExcludeThis1.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/ExcludeThis1.txt new file mode 100644 index 000000000..949ca7b7c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/ExcludeThis1.txt @@ -0,0 +1 @@ +Test content file that should be excluded. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/ExcludeThis2.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/ExcludeThis2.txt new file mode 100644 index 000000000..949ca7b7c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/ExcludeThis2.txt @@ -0,0 +1 @@ +Test content file that should be excluded. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/IncludeThis.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/IncludeThis.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/IncludeThis.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/project.json new file mode 100644 index 000000000..bf61a22e2 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedContent/project/project.json @@ -0,0 +1,24 @@ +{ + "version": "1.0.0-*", + "content": "*.txt", + "contentExclude": "ExcludeThis1.txt", + "contentFiles": [ "../ContentFile1.txt", "../ContentFile2.txt" ], + "contentBuiltIn": [ "../ContentFileBuiltIn1.txt", "../ContentFileBuiltIn2.txt" ], + "publishExclude": "ExcludeThis2.txt", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedNamedResource/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedNamedResource/Program.cs new file mode 100644 index 000000000..8fdd24dff --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedNamedResource/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedNamedResource/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedNamedResource/project.json new file mode 100644 index 000000000..e0c6115f7 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedNamedResource/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "namedResource": [ "My.Alias", "Strings.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Content1.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Content1.txt new file mode 100644 index 000000000..a36501f3f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Content1.txt @@ -0,0 +1 @@ +Test pack content file. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Content2.txt b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Content2.txt new file mode 100644 index 000000000..a36501f3f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Content2.txt @@ -0,0 +1 @@ +Test pack content file. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/project.json new file mode 100644 index 000000000..5daf77a20 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedPack/project.json @@ -0,0 +1,32 @@ +{ + "version": "1.0.0-*", + "projectUrl": "http://projecturl/", + "licenseUrl": "http://licenseurl/", + "iconUrl": "http://iconurl/", + "owners": [ "owner1", "owner2" ], + "tags": [ "tag1", "tag2" ], + "releaseNotes": "releaseNotes", + "requireLicenseAcceptance": true, + "summary": "summary", + "repository": { + "type": "git", + "url": "http://url/" + }, + "packInclude": [ "Content1.txt", "Content2.txt" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/Strings1.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/Strings1.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/Strings1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/Strings2.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/Strings2.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/Strings2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/Resources/Strings.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/Resources/Strings.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/Resources/Strings.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/project.json new file mode 100644 index 000000000..369f7325d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResource/project/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "resource": "../Strings1.resx", + "resourceFiles": [ "../Strings2.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/Strings1.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/Strings1.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/Strings1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/Strings2.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/Strings2.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/Strings2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/Resources/Strings.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/Resources/Strings.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/Resources/Strings.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/project.json new file mode 100644 index 000000000..d4f8ee07f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceBuiltIn/project/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "resourceBuiltIn": [ "../Strings1.resx", "../Strings2.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Exclude1.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Exclude1.resx new file mode 100644 index 000000000..a82c91ddd --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Exclude1.resx @@ -0,0 +1 @@ +This is not a resource file but is used to test resource exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Exclude2.resx b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Exclude2.resx new file mode 100644 index 000000000..a82c91ddd --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Exclude2.resx @@ -0,0 +1 @@ +This is not a resource file but is used to test resource exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Program.cs b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/project.json b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/project.json new file mode 100644 index 000000000..01c3c9e23 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJDeprecatedResourceExclude/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "exclude": "Exclude1.resx", + "resourceExclude": [ "Exclude2.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj b/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj index 8a1e7d530..b2d04e484 100644 --- a/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj +++ b/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj @@ -1,10 +1,10 @@ - + 1.0.0-rc netcoreapp1.0;net451 dotnet-desktop-and-portable Exe - win7-x64;win7-x86;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64;osx.10.10-x64;rhel.7-x64 + win7-x64;win7-x86 @@ -19,12 +19,14 @@ + + + + + - - - $(DefineConstants);RELEASE - diff --git a/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj b/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj index b6603c2d8..c1ec38777 100644 --- a/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj +++ b/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj @@ -1,6 +1,6 @@  - netcoreapp1.0 + netcoreapp1.1 dotnet-hello Exe win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64 @@ -8,7 +8,7 @@ - 1.0.3 + 1.1.0 diff --git a/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj b/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj index eaa06bf6e..510f6a431 100644 --- a/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj +++ b/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj @@ -1,7 +1,7 @@  2.0.0 - netcoreapp1.0 + netcoreapp1.1 dotnet-hello Exe win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64 @@ -9,7 +9,7 @@ - 1.0.3 + 1.1.0 diff --git a/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj b/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj index fe4c0e02c..9c9243987 100755 --- a/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj +++ b/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj @@ -1,12 +1,12 @@  - netcoreapp1.0 + netcoreapp1.1 Exe - 1.0.3 + 1.1.0 1.0.0 diff --git a/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj b/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj index bbfb9be11..1f2bc2278 100755 --- a/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj +++ b/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj @@ -1,14 +1,14 @@  1.0.0 - netcoreapp1.0 + netcoreapp1.1 AppWithDirectDep Exe false - 1.0.3 + 1.1.0 1.0.0 diff --git a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj index 6a76893df..cf78cd7a8 100755 --- a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj +++ b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj @@ -18,6 +18,11 @@ 1.0.0-* + + + + $(DefineConstants);RELEASE;TRACE true diff --git a/TestAssets/TestProjects/TestAppWithExplicitInclude/Program.cs b/TestAssets/TestProjects/TestAppWithExplicitInclude/Program.cs new file mode 100644 index 000000000..c81448f54 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithExplicitInclude/Program.cs @@ -0,0 +1,9 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } +} diff --git a/TestAssets/TestProjects/TestAppWithExplicitInclude/project.json b/TestAssets/TestProjects/TestAppWithExplicitInclude/project.json new file mode 100644 index 000000000..c29a3797c --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithExplicitInclude/project.json @@ -0,0 +1,24 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true, + "compile": { + "include": [ + "Program.cs" + ] + } + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/TestProjects/TestAppWithExplicitIncludeGlob/Program.cs b/TestAssets/TestProjects/TestAppWithExplicitIncludeGlob/Program.cs new file mode 100644 index 000000000..c81448f54 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithExplicitIncludeGlob/Program.cs @@ -0,0 +1,9 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } +} diff --git a/TestAssets/TestProjects/TestAppWithExplicitIncludeGlob/project.json b/TestAssets/TestProjects/TestAppWithExplicitIncludeGlob/project.json new file mode 100644 index 000000000..67a885251 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithExplicitIncludeGlob/project.json @@ -0,0 +1,24 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true, + "compile": { + "include": [ + "**/*.cs" + ] + } + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/.noautobuild b/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/.noautobuild deleted file mode 100644 index e69de29bb..000000000 diff --git a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json b/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json deleted file mode 100644 index 90cf856ff..000000000 --- a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "xmlDoc": true - }, - "packInclude": {}, - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - "frameworks": { - "netstandard1.5": {} - } -} diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index e22746ca5..4b85fbc01 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -1,316 +1,319 @@ - - - - - - - runtimes/any/native - $(RepoRoot)/resources/MSBuildImports - - - - - - - - - - - - - $(RepoRoot)/src - - - - - - - - @(CompileStageInputs) - $(Stage1Directory) - $(Stage1SymbolsDirectory) - $(Stage0Directory) - - - @(CompileStageInputs) - $(Stage2Directory) - $(Stage2SymbolsDirectory) - $(Stage0Directory) - - - - - - - - lib - - .dll - .dylib - .so - - dotnet$(ExeExtension) - $(DynamicLibPrefix)hostfxr$(DynamicLibSuffix) - $(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix) - - %(Stage.StageDirectory) - %(Stage.StageSymbolsDirectory) - $(StageDirectory)/sdk/$(SdkVersion) - $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) - $(SdkOutputDirectory)/runtimes/any/native - - $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkVersion) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - u=rw,g=r,o=r - - - - - u=rwx,g=rx,o=rx - - - - - u=rwx,g=rx,o=rx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CLIBuildDll=$(CLIBuildDll); - NuGetPackagesDir=$(NuGetPackagesDir); - SdkLayoutDirectory=$(SdkOutputDirectory)/Sdks/%(BundledSdk.Identity); - SdkPackageName=%(BundledSdk.Identity); - SdkPackageVersion=%(BundledSdk.Version); - Stage0Directory=$(Stage0Directory) - - - - - - - - - - - - - TemplateLayoutDirectory=$(SdkOutputDirectory)/Templates; - TemplatePackageName=%(BundledTemplate.Identity); - TemplatePackageVersion=%(BundledTemplate.Version); - Stage0Directory=$(Stage0Directory) - - - - - - - + + + + + + + runtimes/any/native + $(RepoRoot)/resources/MSBuildImports + + + + + + + + + + + + + $(RepoRoot)/src + + + + + + + + @(CompileStageInputs) + $(Stage1Directory) + $(Stage1SymbolsDirectory) + $(Stage0Directory) + + + @(CompileStageInputs) + $(Stage2Directory) + $(Stage2SymbolsDirectory) + $(Stage0Directory) + + + + + + + + lib + + .dll + .dylib + .so + + dotnet$(ExeExtension) + $(DynamicLibPrefix)hostfxr$(DynamicLibSuffix) + $(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix) + + %(Stage.StageDirectory) + %(Stage.StageSymbolsDirectory) + $(StageDirectory)/sdk/$(SdkVersion) + $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) + $(SdkOutputDirectory)/runtimes/any/native + + $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkVersion) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + u=rw,g=r,o=r + + + + + u=rwx,g=rx,o=rx + + + + + u=rwx,g=rx,o=rx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CLIBuildDll=$(CLIBuildDll); + NuGetPackagesDir=$(NuGetPackagesDir); + SdkLayoutDirectory=$(SdkOutputDirectory)/Sdks/%(BundledSdk.Identity); + SdkPackageName=%(BundledSdk.Identity); + SdkPackageVersion=%(BundledSdk.Version); + Stage0Directory=$(Stage0Directory) + + + + + + + + + + + + + TemplateLayoutDirectory=$(SdkOutputDirectory)/Templates; + TemplatePackageName=%(BundledTemplate.Identity); + TemplatePackageVersion=%(BundledTemplate.Version); + Stage0Directory=$(Stage0Directory) + + + + + + + \ No newline at end of file diff --git a/build/Microsoft.DotNet.Cli.DependencyVersions.props b/build/Microsoft.DotNet.Cli.DependencyVersions.props index 02b103618..cd701bd64 100644 --- a/build/Microsoft.DotNet.Cli.DependencyVersions.props +++ b/build/Microsoft.DotNet.Cli.DependencyVersions.props @@ -3,13 +3,13 @@ 2.0.0-beta-001386-00 1.2.0-beta-24904-03 - 15.1.0-preview-000523-01 - 2.0.0-rc3-61212-03 - 1.0.0-alpha-20170117-4 + 15.1.0-preview-000539-01 + 2.0.0-rc4-61325-08 + 1.0.0-alpha-20170125-1 4.0.0-rc3-2193 1.0.0-alpha-20170120-3-249 - 15.0.0-preview-20170106-08 - 1.0.0-beta1-20170108-83 + 15.0.0-preview-20170125-04 + 1.0.0-beta1-20170126-102 diff --git a/build/Microsoft.DotNet.Cli.Monikers.props b/build/Microsoft.DotNet.Cli.Monikers.props index 7a8439645..10981406b 100644 --- a/build/Microsoft.DotNet.Cli.Monikers.props +++ b/build/Microsoft.DotNet.Cli.Monikers.props @@ -3,8 +3,8 @@ Microsoft .NET Core 1.0.3 - SDK RC 4 Microsoft .NET Core 1.0.3 - Runtime - Microsoft .NET Core 1.0.1 - Host - Microsoft .NET Core 1.0.1 - Host FX Resolver + Microsoft .NET Core 1.1.0 - Host + Microsoft .NET Core 1.1.0 - Host FX Resolver Microsoft .NET Core 1.1.0 - Runtime Microsoft .NET Core 1.1.0 - Host diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 3c00134cf..608d3e932 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -43,6 +43,10 @@ $(BaseOutputDirectory)/intermediate $(BaseOutputDirectory)/packages $(IntermediateDirectory)/sharedFrameworkPublish + $(Rid) + win7-$(Architecture) + osx.10.10-x64 + rhel.7-x64 @@ -54,10 +58,7 @@ VersionMinor="$(VersionMinor)" VersionPatch="$(VersionPatch)" ReleaseSuffix="$(ReleaseSuffix)"> - - - - + @@ -68,6 +69,12 @@ + $(DefaultCommitCount) + + $(VersionMajor).$(VersionMinor).$(VersionPatch).$(CommitCount) + $(ReleaseSuffix)-$(CommitCount) + $(VersionMajor).$(VersionMinor).$(VersionPatch)-$(VersionSuffix) + $(BaseOutputDirectory)/$(VersionBadgeMoniker)_$(Configuration)_version_badge.svg $(NugetVersion) diff --git a/build/Microsoft.DotNet.Cli.Test.targets b/build/Microsoft.DotNet.Cli.Test.targets index 0941fa6c9..f9de278d8 100644 --- a/build/Microsoft.DotNet.Cli.Test.targets +++ b/build/Microsoft.DotNet.Cli.Test.targets @@ -11,7 +11,8 @@ + DependsOnTargets="EnsureStageSeparation; + BuildTests;"> : @@ -81,37 +82,29 @@ + ProjectPath=""$(TestDirectory)/Microsoft.DotNet.Cli.Tests.sln"" + MaxCpuCount="1" /> - - - %(TestPackageProject.Framework) - true - /p:TargetFramework=$(Framework) - /p:RuntimeIdentifier=%(TestPackageProject.PackRuntime) - + Outputs="%(TestPackageProject.Identity)"> - - - + - + MsbuildArgs="%(TestPackageProject.MsbuildArgs) /p:SdkNuGetVersion=$(SdkNugetVersion)" /> + + + + + diff --git a/build/Microsoft.DotNet.Cli.tasks b/build/Microsoft.DotNet.Cli.tasks index 49553a226..89c188c72 100644 --- a/build/Microsoft.DotNet.Cli.tasks +++ b/build/Microsoft.DotNet.Cli.tasks @@ -9,6 +9,7 @@ + diff --git a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets index 4a9e88ccd..cde2d7385 100644 --- a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets +++ b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets @@ -66,10 +66,25 @@ + + + <configuration> + <packageSources> + <add key="configurable.source" value="%CLI_LZMA_PACKAGE_SOURCE%" /> + </packageSources> + </configuration> + + $(NuGetPackagesArchiveProject)/Nuget.config + + + + diff --git a/build/crossgen/Microsoft.DotNet.Cli.Crossgen.targets b/build/crossgen/Microsoft.DotNet.Cli.Crossgen.targets index 14aded3ac..a6ee063b7 100644 --- a/build/crossgen/Microsoft.DotNet.Cli.Crossgen.targets +++ b/build/crossgen/Microsoft.DotNet.Cli.Crossgen.targets @@ -3,14 +3,9 @@ - $(Rid) - win7-$(Architecture) - osx.10.10-x64 - rhel.7-x64 - + runtime.$(CoreCLRRid).microsoft.netcore.runtime.coreclr runtime.$(CoreCLRRid).microsoft.netcore.runtime.coreclr runtime.$(CoreCLRRid).microsoft.netcore.jit - runtime.$(CoreCLRRid).microsoft.netcore.runtime.coreclr $(NuGetPackagesDir)/$(CoreCLRPackageName)/$(CLI_CoreCLRVersion)/runtimes/$(CoreCLRRid)/lib/netstandard1.0 $(NuGetPackagesDir)/$(CrossGenPackageName)/$(CLI_CoreCLRVersion)/tools/crossgen$(ExeExtension) diff --git a/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj b/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj index e035c773f..fb4aab4a6 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj +++ b/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj @@ -90,14 +90,14 @@ Outputs="$(DebianTestResultsXmlFile)" > - - - - + + + + diff --git a/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets b/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets index d3d11daf0..ca94cf99f 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets +++ b/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets @@ -15,7 +15,7 @@ - + diff --git a/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets b/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets index b0c1a17a4..c1d1474d3 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets +++ b/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets @@ -108,12 +108,12 @@ + DependsOnTargets="SetupTestPackageProjectFrameworks"> - - %(Name) - - - - %(BuildOutputs) - $(TestPackagesDir)%(NuPkgName).%(VersionPrefix)%(VersionSuffix).nupkg - - - - - - - - %(TestPackageProject.OutputPath)%(TestPackageProject.Name).dll - - - %(TestPackageProjectFrameworks.Identity) - - + DependsOnTargets="SetupTestPackageProjectBaseData"> - - $(CurrentBuildFramework) - $(CoreCLRRid) - %(OutputPath)$(CurrentBuildFramework)/ + - - - %(BaseTestPackageProject.ProjectPath) - - - - - @(__TestPackageProjectInputs) - - - - - - - <__TestPackageProjectInputs Include="%(BaseTestPackageProject.BuildInputIncludeFilter)" - Exclude="%(BaseTestPackageProject.BuildInputExcludeFilter)"> - %(BaseTestPackageProject.ProjectPath) - - - - - + + Microsoft.DotNet.Cli.Utils + Microsoft.DotNet.Cli.Utils.csproj + True + True + $(CliVersionPrefix)- + rc4-$(TestPackageBuildVersionSuffix) + False + + Microsoft.DotNet.Cli.Utils Microsoft.DotNet.Cli.Utils.csproj True @@ -78,7 +35,7 @@ $(CliVersionPrefix)- $(ReleaseSuffix)-$(TestPackageBuildVersionSuffix) False - netstandard1.5 + /p:TargetFramework=netstandard1.5 Microsoft.DotNet.InternalAbstractions @@ -88,9 +45,9 @@ 2.0.0-beta- beta-$(TestPackageBuildVersionSuffix) False - netstandard1.3 - + PackageWithFakeNativeDep PackageWithFakeNativeDep.csproj False @@ -98,8 +55,7 @@ 1.0.0 True - net45 - $(CoreCLRRid) + /p:RuntimeIdentifier=$(CoreCLRRid) dotnet-dependency-context-test @@ -109,7 +65,6 @@ 1.0.0-rc- rc-$(TestPackageBuildVersionSuffix) True - netcoreapp1.0 dotnet-dependency-tool-invoker @@ -119,9 +74,9 @@ 1.0.0-rc- rc-$(TestPackageBuildVersionSuffix) True - netcoreapp1.0 - + dotnet-desktop-and-portable dotnet-desktop-and-portable.csproj True @@ -129,11 +84,10 @@ 1.0.0-rc- rc-$(TestPackageBuildVersionSuffix) True - net451;netcoreapp1.0 - $(CoreCLRRid) + /p:RuntimeIdentifier=$(CoreCLRRid) + Condition=" '$(IsDesktopAvailable)' == 'True' "> dotnet-desktop-binding-redirects dotnet-desktop-binding-redirects.csproj True @@ -142,8 +96,7 @@ 1.0.0-rc- rc-$(TestPackageBuildVersionSuffix) True - net451 - $(CoreCLRRid) + /p:RuntimeIdentifier=$(CoreCLRRid) dotnet-hello @@ -153,7 +106,6 @@ 1.0.0 True - netcoreapp1.0 dotnet-hello @@ -163,7 +115,6 @@ 2.0.0 True - netcoreapp1.0 dotnet-portable @@ -173,7 +124,6 @@ 1.0.0 True - netcoreapp1.0 dotnet-prefercliruntime @@ -183,7 +133,6 @@ 1.0.0 True - netcoreapp1.0 dotnet-tool-with-output-name @@ -194,13 +143,8 @@ 1.0.0 True - netcoreapp1.0 - - - - $(RepoRoot)%(Identity)/ $(TestPackagesBuildDir)%(Identity)/bin/$(Configuration)/ @@ -208,8 +152,6 @@ %(ProjectDir)%(ProjectName) - %(ProjectDir)**/*.* - %(ProjectDir)bin/**/*.*;%(ProjectDir)obj/**/*.* @@ -219,4 +161,4 @@ %(Name) - \ No newline at end of file + diff --git a/build_projects/Microsoft.DotNet.Cli.Build.SelfTest/InvokeWithStage0.proj b/build_projects/Microsoft.DotNet.Cli.Build.SelfTest/InvokeWithStage0.proj new file mode 100644 index 000000000..4175b21fc --- /dev/null +++ b/build_projects/Microsoft.DotNet.Cli.Build.SelfTest/InvokeWithStage0.proj @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/build_projects/Microsoft.DotNet.Cli.Build.SelfTest/InvokeWithStage2.proj b/build_projects/Microsoft.DotNet.Cli.Build.SelfTest/InvokeWithStage2.proj new file mode 100644 index 000000000..1493128e7 --- /dev/null +++ b/build_projects/Microsoft.DotNet.Cli.Build.SelfTest/InvokeWithStage2.proj @@ -0,0 +1,29 @@ + + + + $([System.IO.Path]::GetDirectoryName($(ToolPath)/)) + + + + false + true + false + true + false + true + + + + + + + + + + + + \ No newline at end of file diff --git a/build_projects/dotnet-cli-build/DotNetBuild.cs b/build_projects/dotnet-cli-build/DotNetBuild.cs index f11ec52f4..513542710 100644 --- a/build_projects/dotnet-cli-build/DotNetBuild.cs +++ b/build_projects/dotnet-cli-build/DotNetBuild.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Cli.Build { - public class DotNetBuild : DotNetTool + public class DotNetBuild : DotNetMSBuildTool { protected override string Command { @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {GetOutputPath()} {GetMaxCpuCount()}"; } + get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {GetOutputPath()}"; } } public string BuildBasePath { get; set; } @@ -26,9 +26,7 @@ namespace Microsoft.DotNet.Cli.Build public string ProjectPath { get; set; } public string OutputPath { get; set; } - - public string MaxCpuCount { get; set; } - + private string GetOutputPath() { if (!string.IsNullOrEmpty(OutputPath)) @@ -78,15 +76,5 @@ namespace Microsoft.DotNet.Cli.Build return null; } - - private string GetMaxCpuCount() - { - if (!string.IsNullOrEmpty(MaxCpuCount)) - { - return $"/maxcpucount:{MaxCpuCount}"; - } - - return null; - } } } diff --git a/build_projects/dotnet-cli-build/DotNetMSBuild.cs b/build_projects/dotnet-cli-build/DotNetMSBuild.cs new file mode 100644 index 000000000..6ff30abd8 --- /dev/null +++ b/build_projects/dotnet-cli-build/DotNetMSBuild.cs @@ -0,0 +1,30 @@ +// 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. + +namespace Microsoft.DotNet.Cli.Build +{ + public class DotNetMSBuild : DotNetMSBuildTool + { + protected override string Command + { + get { return "msbuild"; } + } + + protected override string Args + { + get { return $"{base.Args} {GetArguments()}"; } + } + + public string Arguments { get; set; } + + private string GetArguments() + { + if (!string.IsNullOrEmpty(Arguments)) + { + return $"{Arguments}"; + } + + return null; + } + } +} diff --git a/build_projects/dotnet-cli-build/DotNetMSBuildTool.cs b/build_projects/dotnet-cli-build/DotNetMSBuildTool.cs new file mode 100644 index 000000000..d70103a46 --- /dev/null +++ b/build_projects/dotnet-cli-build/DotNetMSBuildTool.cs @@ -0,0 +1,32 @@ +// 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 Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +using Microsoft.DotNet.Cli.Build.Framework; + +namespace Microsoft.DotNet.Cli.Build +{ + public abstract class DotNetMSBuildTool : DotNetTool + { + public int MaxCpuCount {get; set;} = 0; + + protected override string Args + { + get + { + return $"{GetMaxCpuCountArg()}"; + } + } + + private string GetMaxCpuCountArg() + { + if (MaxCpuCount > 0) + { + return $"/m:{MaxCpuCount}"; + } + + return null; + } + } +} diff --git a/build_projects/dotnet-cli-build/DotNetPack.cs b/build_projects/dotnet-cli-build/DotNetPack.cs index 96bcbc884..bf4bef93d 100644 --- a/build_projects/dotnet-cli-build/DotNetPack.cs +++ b/build_projects/dotnet-cli-build/DotNetPack.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Cli.Build { - public class DotNetPack : DotNetTool + public class DotNetPack : DotNetMSBuildTool { protected override string Command { @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetProjectPath()} {GetConfiguration()} {GetNoBuild()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {MsbuildArgs}"; } + get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetNoBuild()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {MsbuildArgs}"; } } public string Configuration { get; set; } diff --git a/build_projects/dotnet-cli-build/DotNetPublish.cs b/build_projects/dotnet-cli-build/DotNetPublish.cs index 8fbb88cbc..f4c2aec24 100644 --- a/build_projects/dotnet-cli-build/DotNetPublish.cs +++ b/build_projects/dotnet-cli-build/DotNetPublish.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Cli.Build { - public class DotNetPublish : DotNetTool + public class DotNetPublish : DotNetMSBuildTool { protected override string Command { @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetNativeSubdirectory()} {GetBuildBasePath()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {GetMSBuildArgs()}"; } + get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetNativeSubdirectory()} {GetBuildBasePath()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {GetMSBuildArgs()}"; } } public string BuildBasePath { get; set; } diff --git a/build_projects/dotnet-cli-build/DotNetRestore.cs b/build_projects/dotnet-cli-build/DotNetRestore.cs index d3f1a2b4d..88bca5e22 100644 --- a/build_projects/dotnet-cli-build/DotNetRestore.cs +++ b/build_projects/dotnet-cli-build/DotNetRestore.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Cli.Build { - public class DotNetRestore : DotNetTool + public class DotNetRestore : DotNetMSBuildTool { protected override string Command { @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetProjectPath()} {GetConfigFile()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {GetAdditionalParameters()}"; } + get { return $"{base.Args} {GetProjectPath()} {GetConfigFile()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {GetAdditionalParameters()}"; } } public string ConfigFile { get; set; } diff --git a/build_projects/dotnet-cli-build/DotNetTest.cs b/build_projects/dotnet-cli-build/DotNetTest.cs index fd10ed7ea..6ed55055c 100644 --- a/build_projects/dotnet-cli-build/DotNetTest.cs +++ b/build_projects/dotnet-cli-build/DotNetTest.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Cli.Build { - public class DotNetTest : DotNetTool + public class DotNetTest : DotNetMSBuildTool { protected override string Command { @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetProjectPath()} {GetConfiguration()} {GetLogger()} {GetNoBuild()}"; } + get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetLogger()} {GetNoBuild()}"; } } public string Configuration { get; set; } diff --git a/build_projects/dotnet-cli-build/DotNetTool.cs b/build_projects/dotnet-cli-build/DotNetTool.cs index d074856b0..cc3d1cd83 100644 --- a/build_projects/dotnet-cli-build/DotNetTool.cs +++ b/build_projects/dotnet-cli-build/DotNetTool.cs @@ -1,5 +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.Diagnostics; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -18,6 +19,24 @@ namespace Microsoft.DotNet.Cli.Build protected abstract string Args { get; } + protected override ProcessStartInfo GetProcessStartInfo( + string pathToTool, + string commandLineCommands, + string responseFileSwitch) + { + var psi = base.GetProcessStartInfo( + pathToTool, + commandLineCommands, + responseFileSwitch); + + foreach (var environmentVariableName in new EnvironmentFilter().GetEnvironmentVariableNamesToRemove()) + { + psi.Environment.Remove(environmentVariableName); + } + + return psi; + } + public string WorkingDirectory { get; set; } protected override string ToolName diff --git a/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs b/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs new file mode 100644 index 000000000..d5a7a5acf --- /dev/null +++ b/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs @@ -0,0 +1,57 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.DotNet.Cli.Build +{ + public class EnvironmentFilter + { + private const string _MSBuildEnvironmentVariablePrefix = "MSBuild"; + private const string _DotNetEnvironmentVariablePrefix = "DOTNET"; + private const string _NugetEnvironmentVariablePrefix = "NUGET"; + + private IEnumerable _prefixesOfEnvironmentVariablesToRemove = new string [] + { + _MSBuildEnvironmentVariablePrefix, + _DotNetEnvironmentVariablePrefix, + _NugetEnvironmentVariablePrefix + }; + + private IEnumerable _environmentVariablesToRemove = new string [] + { + "CscToolExe" + }; + + private IEnumerable _environmentVariablesToKeep = new string [] + { + "DOTNET_CLI_TELEMETRY_SESSIONID", + "DOTNET_RUNTIME_ID", + "DOTNET_SKIP_FIRST_TIME_EXPERIENCE", + "NUGET_PACKAGES" + }; + + public IEnumerable GetEnvironmentVariableNamesToRemove() + { + var allEnvironmentVariableNames = (IEnumerable)Environment + .GetEnvironmentVariables() + .Keys + .Cast(); + + var environmentVariablesToRemoveByPrefix = allEnvironmentVariableNames + .Where(e => _prefixesOfEnvironmentVariablesToRemove.Any(p => e.StartsWith(p))); + + var environmentVariablesToRemoveByName = allEnvironmentVariableNames + .Where(e => _environmentVariablesToRemove.Contains(e)); + + var environmentVariablesToRemove = environmentVariablesToRemoveByName + .Concat(environmentVariablesToRemoveByPrefix) + .Distinct() + .Except(_environmentVariablesToKeep); + + return environmentVariablesToRemove; + } + } +} diff --git a/build_projects/dotnet-cli-build/dotnet-cli-build.csproj b/build_projects/dotnet-cli-build/dotnet-cli-build.csproj index 7ed07d117..e1ed4996a 100644 --- a/build_projects/dotnet-cli-build/dotnet-cli-build.csproj +++ b/build_projects/dotnet-cli-build/dotnet-cli-build.csproj @@ -3,10 +3,10 @@ Build scripts for dotnet-cli 1.0.0 - netcoreapp1.0 + netcoreapp1.1 true bin\$(Configuration) - $(PackageTargetFallback);portable-net45+win8+wp8+wpa81 + $(PackageTargetFallback);portable-net45+win8+wp8+wpa81 @@ -17,7 +17,7 @@ 1.6.0 - 1.0.4 + 1.1.0 $(CLI_MSBuild_Version) diff --git a/run-build.sh b/run-build.sh old mode 100755 new mode 100644 diff --git a/scripts/docker/centos/Dockerfile b/scripts/docker/centos/Dockerfile index ae3e87d6a..6bba0fb81 100644 --- a/scripts/docker/centos/Dockerfile +++ b/scripts/docker/centos/Dockerfile @@ -6,6 +6,10 @@ # Dockerfile that creates a container suitable to build dotnet-cli FROM centos:7.1.1503 +# Swap the "fakesystemd" package with the real "systemd" package, because fakesystemd conflicts with openssl-devel. +# The CentOS Docker image uses fakesystemd instead of systemd to reduce disk space. +RUN yum -q -y swap -- remove fakesystemd -- install systemd systemd-libs + RUN yum -q -y install deltarpm RUN yum -q -y install epel-release # RUN yum -y update diff --git a/scripts/dockerrun.sh b/scripts/dockerrun.sh index 3b6b4133a..b478a2a10 100755 --- a/scripts/dockerrun.sh +++ b/scripts/dockerrun.sh @@ -133,5 +133,6 @@ docker run $INTERACTIVE -t --rm --sig-proxy=true \ -e CHECKSUM_STORAGE_ACCOUNT \ -e CHECKSUM_STORAGE_CONTAINER \ -e CLIBUILD_SKIP_TESTS \ + -e CommitCount \ $DOTNET_BUILD_CONTAINER_TAG \ $BUILD_COMMAND "$@" diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandUnknownException.cs b/src/Microsoft.DotNet.Cli.Utils/CommandUnknownException.cs index 6a27faae2..93034ba7d 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandUnknownException.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandUnknownException.cs @@ -4,10 +4,6 @@ namespace Microsoft.DotNet.Cli.Utils { public class CommandUnknownException : GracefulException { - public CommandUnknownException() - { - } - public CommandUnknownException(string commandName) : base(string.Format( LocalizableStrings.NoExecutableFoundMatchingCommand, commandName)) diff --git a/src/Microsoft.DotNet.Cli.Utils/ExceptionExtensions.cs b/src/Microsoft.DotNet.Cli.Utils/ExceptionExtensions.cs index 68743b1d8..7756f77e7 100644 --- a/src/Microsoft.DotNet.Cli.Utils/ExceptionExtensions.cs +++ b/src/Microsoft.DotNet.Cli.Utils/ExceptionExtensions.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.DotNet.Cli.Utils.ExceptionExtensions +namespace Microsoft.DotNet.Cli.Utils { internal static class ExceptionExtensions { @@ -11,5 +11,10 @@ namespace Microsoft.DotNet.Cli.Utils.ExceptionExtensions { Reporter.Verbose.WriteLine($"Warning: Ignoring exception: {e.ToString().Yellow()}"); } + + public static bool ShouldBeDisplayedAsError(this Exception e) => + e.Data.Contains(CLI_User_Displayed_Exception); + + internal const string CLI_User_Displayed_Exception = "CLI_User_Displayed_Exception"; } } diff --git a/src/Microsoft.DotNet.Cli.Utils/GracefulException.cs b/src/Microsoft.DotNet.Cli.Utils/GracefulException.cs index 817f8d03d..448049ee4 100644 --- a/src/Microsoft.DotNet.Cli.Utils/GracefulException.cs +++ b/src/Microsoft.DotNet.Cli.Utils/GracefulException.cs @@ -4,12 +4,9 @@ namespace Microsoft.DotNet.Cli.Utils { public class GracefulException : Exception { - public GracefulException() - { - } - public GracefulException(string message) : base(message) { + Data.Add(ExceptionExtensions.CLI_User_Displayed_Exception, true); } public GracefulException(string format, params string[] args) : this(string.Format(format, args)) @@ -18,6 +15,7 @@ namespace Microsoft.DotNet.Cli.Utils public GracefulException(string message, Exception innerException) : base(message, innerException) { + Data.Add(ExceptionExtensions.CLI_User_Displayed_Exception, true); } } } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj b/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj index 382259d99..53f8615de 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj +++ b/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj @@ -15,7 +15,7 @@ 1.0.1-beta-000933 - 1.0.1-beta-000933 + 1.1.0 $(CLI_NuGet_Version) diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index 57583883e..7a2778d9c 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -165,7 +165,8 @@ namespace Microsoft.DotNet.Internal.ProjectModel // Project files project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath); - AddProjectFilesCollectionDiagnostics(rawProject, project); + AddProjectFilesDeprecationDiagnostics(rawProject, project); + ConvertDeprecatedToSupportedFormat(rawProject); var commands = rawProject.Value("commands") as JObject; if (commands != null) @@ -758,10 +759,14 @@ namespace Microsoft.DotNet.Internal.ProjectModel if (rawPackOptions != null) { - var packOptionValue = rawPackOptions.Value(option); - if (packOptionValue != null) + var hasOption = rawPackOptions.Value(option) != null; + if (hasOption) { - return packOptionValue; + var packOptionValue = rawPackOptions.Value(option); + if (packOptionValue != null) + { + return packOptionValue; + } } } @@ -807,37 +812,45 @@ namespace Microsoft.DotNet.Internal.ProjectModel return File.Exists(projectPath); } - private static void AddProjectFilesCollectionDiagnostics(JObject rawProject, Project project) + private static void AddProjectFilesDeprecationDiagnostics(JObject rawProject, Project project) { var compileWarning = "'compile' in 'buildOptions'"; - AddDiagnosticMesage(rawProject, project, "compile", compileWarning); - AddDiagnosticMesage(rawProject, project, "compileExclude", compileWarning); - AddDiagnosticMesage(rawProject, project, "compileFiles", compileWarning); - AddDiagnosticMesage(rawProject, project, "compileBuiltIn", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compile", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compileExclude", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compileFiles", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compileBuiltIn", compileWarning); var resourceWarning = "'embed' in 'buildOptions'"; - AddDiagnosticMesage(rawProject, project, "resource", resourceWarning); - AddDiagnosticMesage(rawProject, project, "resourceExclude", resourceWarning); - AddDiagnosticMesage(rawProject, project, "resourceFiles", resourceWarning); - AddDiagnosticMesage(rawProject, project, "resourceBuiltIn", resourceWarning); - AddDiagnosticMesage(rawProject, project, "namedResource", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resource", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resourceExclude", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resourceFiles", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resourceBuiltIn", resourceWarning); + // Issue: https://github.com/dotnet/cli/issues/5471 + // This is why we mark it as an error which will fail migration. + AddDeprecatedDiagnosticMessage( + rawProject, + project, + "namedResource", + resourceWarning, + DiagnosticMessageSeverity.Error); var contentWarning = "'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output"; - AddDiagnosticMesage(rawProject, project, "content", contentWarning); - AddDiagnosticMesage(rawProject, project, "contentExclude", contentWarning); - AddDiagnosticMesage(rawProject, project, "contentFiles", contentWarning); - AddDiagnosticMesage(rawProject, project, "contentBuiltIn", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "content", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "contentExclude", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "contentFiles", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "contentBuiltIn", contentWarning); - AddDiagnosticMesage(rawProject, project, "packInclude", "'files' in 'packOptions'"); - AddDiagnosticMesage(rawProject, project, "publishExclude", "'publishOptions'"); - AddDiagnosticMesage(rawProject, project, "exclude", "'exclude' within 'compile' or 'embed'"); + AddDeprecatedDiagnosticMessage(rawProject, project, "packInclude", "'files' in 'packOptions'"); + AddDeprecatedDiagnosticMessage(rawProject, project, "publishExclude", "'publishOptions'"); + AddDeprecatedDiagnosticMessage(rawProject, project, "exclude", "'exclude' within 'compile' or 'embed'"); } - private static void AddDiagnosticMesage( + private static void AddDeprecatedDiagnosticMessage( JObject rawProject, Project project, string option, - string message) + string message, + DiagnosticMessageSeverity severity = DiagnosticMessageSeverity.Warning) { var lineInfo = rawProject.Value(option); if (lineInfo == null) @@ -850,11 +863,132 @@ namespace Microsoft.DotNet.Internal.ProjectModel ErrorCodes.DOTNET1015, $"The '{option}' option is deprecated. Use {message} instead.", project.ProjectFilePath, - DiagnosticMessageSeverity.Warning, + severity, lineInfo.LineNumber, lineInfo.LinePosition)); } + private static void ConvertDeprecatedToSupportedFormat(JObject rawProject) + { + ConvertToBuildOptionsCompile(rawProject); + ConvertToBuildOptionsEmbed(rawProject); + ConvertToBuildOptionsCopyToOutput(rawProject); + ConvertToPackOptions(rawProject); + ConvertToPublishOptions(rawProject); + } + + private static void ConvertToBuildOptionsCompile(JObject rawProject) + { + var jpath = "buildOptions.compile"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "compile", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "exclude", "exclude"); + ConvertFromDeprecatedFormat(rawProject, jpath, "compileExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "compileFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "compileBuiltIn", "include"); + } + + private static void ConvertToBuildOptionsEmbed(JObject rawProject) + { + var jpath = "buildOptions.embed"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "resource", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "exclude", "exclude"); + ConvertFromDeprecatedFormat(rawProject, jpath, "resourceExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "resourceFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "resourceBuiltIn", "include"); + } + + private static void ConvertToBuildOptionsCopyToOutput(JObject rawProject) + { + var jpath = "buildOptions.copyToOutput"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "content", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "contentBuiltIn", "include"); + } + + private static void ConvertToPackOptions(JObject rawProject) + { + var jpath = "packOptions"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.files", "packInclude", "include"); + } + + private static void ConvertToPublishOptions(JObject rawProject) + { + var jpath = "publishOptions"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "content", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "publishExclude", "exclude"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "contentBuiltIn", "include"); + } + + private static bool AreDeprecatedOptionsIgnored(JObject rawProject, string jpathToNewFormatObject) + { + // If the node already exists this means that the project.json file contained both the old and + // new format. In these cases the project.json build ignores the deprecated format and just uses + // the new format. + return (rawProject.SelectToken(jpathToNewFormatObject) != null); + } + + private static void ConvertFromDeprecatedFormat( + JObject rawProject, + string jpathToObject, + string deprecatedKey, + string newKey + ) + { + var deprecatedValue = rawProject.Value(deprecatedKey); + if (deprecatedValue != null) + { + var objectNode = GetOrCreateObjectHierarchy(rawProject, jpathToObject); + objectNode[newKey] = deprecatedValue.DeepClone(); + } + } + + private static JObject GetOrCreateObjectHierarchy(JObject rawProject, string jpath) + { + var currentObject = rawProject as JObject; + + var objectHierarchy = jpath.Split('.'); + foreach (var name in objectHierarchy) + { + var childObject = currentObject.Value(name); + if (childObject == null) + { + childObject = new JObject(); + currentObject[name] = childObject; + } + currentObject = childObject; + } + + return currentObject; + } + private static bool TryGetStringEnumerable(JToken token, out IEnumerable result) { IEnumerable values; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs index 380a9a435..d8332258a 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs @@ -314,7 +314,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration } foreach (var projectDirectory in - Enumerable.Repeat(directory, 1).Union(directory.GetDirectories())) + Enumerable.Repeat(directory, 1).Union(directory.GetDirectories("*", SearchOption.AllDirectories))) { AddIfProjectExists(projects, projectDirectory); } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs index 2596d8f2f..9aa45ea11 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs @@ -9,7 +9,7 @@ using Microsoft.Build.Construction; using Microsoft.DotNet.Internal.ProjectModel; using Microsoft.DotNet.Internal.ProjectModel.Graph; using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.Utils.ExceptionExtensions; +using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.ProjectJsonMigration.Rules; using Microsoft.DotNet.Tools.Common; @@ -41,10 +41,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration IEnumerable projectDependencies = null; var projectMigrationReports = new List(); + List warnings = null; try { // Verify up front so we can prefer these errors over an unresolved project dependency - VerifyInputs(rootInputs, rootSettings); + VerifyInputs(rootInputs, rootSettings, out warnings); projectMigrationReports.Add(MigrateProject(rootSettings)); @@ -67,7 +68,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration rootSettings.ProjectDirectory, rootInputs?.DefaultProjectContext?.GetProjectName(), new List {e.Error}, - null) + warnings) }); } @@ -143,6 +144,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration var projectName = migrationRuleInputs.DefaultProjectContext.GetProjectName(); var outputProject = Path.Combine(migrationSettings.OutputDirectory, projectName + ".csproj"); + List warnings = null; try { if (File.Exists(outputProject)) @@ -165,7 +167,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration } } - VerifyInputs(migrationRuleInputs, migrationSettings); + VerifyInputs(migrationRuleInputs, migrationSettings, out warnings); SetupOutputDirectory(migrationSettings.ProjectDirectory, migrationSettings.OutputDirectory); @@ -178,7 +180,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration exc.Error }; - return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, error, null); + return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, error, warnings); } List csprojDependencies = null; @@ -207,7 +209,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration projectName, outputProject, null, - null, + warnings, csprojDependencies); } @@ -234,13 +236,22 @@ namespace Microsoft.DotNet.ProjectJsonMigration return new MigrationRuleInputs(projectContexts, templateMSBuildProject, itemGroup, propertyGroup, xproj); } - private void VerifyInputs(MigrationRuleInputs migrationRuleInputs, MigrationSettings migrationSettings) + private void VerifyInputs( + MigrationRuleInputs migrationRuleInputs, + MigrationSettings migrationSettings, + out List warningMessages + ) { - VerifyProject(migrationRuleInputs.ProjectContexts, migrationSettings.ProjectDirectory); + VerifyProject(migrationRuleInputs.ProjectContexts, migrationSettings.ProjectDirectory, out warningMessages); } - private void VerifyProject(IEnumerable projectContexts, string projectDirectory) + private void VerifyProject( + IEnumerable projectContexts, + string projectDirectory, + out List warningMessages) { + warningMessages = null; + if (!projectContexts.Any()) { MigrationErrorCodes.MIGRATE1013(String.Format(LocalizableStrings.MIGRATE1013Arg, projectDirectory)).Throw(); @@ -251,9 +262,29 @@ namespace Microsoft.DotNet.ProjectJsonMigration var diagnostics = defaultProjectContext.ProjectFile.Diagnostics; if (diagnostics.Any()) { - MigrationErrorCodes.MIGRATE1011( - String.Format("{0}{1}{2}", projectDirectory, Environment.NewLine, string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d))))) - .Throw(); + var warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning); + if (warnings.Any()) + { + var migrationError = MigrationErrorCodes.MIGRATE1011(String.Format( + "{0}{1}{2}", + projectDirectory, + Environment.NewLine, + string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d))))); + + warningMessages = new List(); + warningMessages.Add(migrationError.GetFormattedErrorMessage()); + } + + var errors = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Error); + if (errors.Any()) + { + MigrationErrorCodes.MIGRATE1011(String.Format( + "{0}{1}{2}", + projectDirectory, + Environment.NewLine, + string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d))))) + .Throw(); + } } var compilerName = diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs index f31be9ba2..e419c615b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs @@ -43,7 +43,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules foreach (var item in msbuildProject.Items) { - if (string.IsNullOrEmpty(item.Include) && string.IsNullOrEmpty(item.Update)) + if (string.IsNullOrEmpty(item.Include) && + string.IsNullOrEmpty(item.Remove) && + string.IsNullOrEmpty(item.Update)) { item.Parent.RemoveChild(item); } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs index c0e3b0201..ef2183979 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs @@ -55,7 +55,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules compilerOptions => compilerOptions.PreserveCompilationContext != null && compilerOptions.PreserveCompilationContext.Value); private AddPropertyTransform WarningsAsErrorsTransform => - new AddPropertyTransform("WarningsAsErrors", + new AddPropertyTransform("TreatWarningsAsErrors", compilerOptions => compilerOptions.WarningsAsErrors.ToString().ToLower(), compilerOptions => compilerOptions.WarningsAsErrors != null && compilerOptions.WarningsAsErrors.Value); @@ -110,16 +110,40 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules compilerOptions => projectFolderName, compilerOptions => compilerOptions.OutputName != null); + private string[] _compilePatternsToExclude = new string[] { + "**/*.cs" + }; + + private static bool IsPlainFileName(string fileName) + { + return !fileName.Contains('/') && !fileName.Contains('\\'); + } + + private bool CompileFilesExcludeRule(string pattern) + { + return _compilePatternsToExclude.Contains(pattern.Replace('\\', '/')) + || IsPlainFileName(pattern); + } + private IncludeContextTransform CompileFilesTransform => new IncludeContextTransform( "Compile", transformMappings: false, + excludePatternsRule: CompileFilesExcludeRule, condition: ic => ic != null, emitBuiltInIncludes: false); + private RemoveContextTransform RemoveCompileFilesTransform => + new RemoveContextTransform( + "Compile", + condition: ic => ic != null); + private IncludeContextTransform EmbedFilesTransform => new IncludeContextTransform("EmbeddedResource", transformMappings: false, condition: ic => ic != null); + private RemoveContextTransform RemoveEmbedFilesTransform => + new RemoveContextTransform("EmbeddedResource", condition: ic => ic != null); + private IncludeContextTransform CopyToOutputFilesTransform => new IncludeContextTransform("Content", transformMappings: true) .WithMetadata("CopyToOutputDirectory", "PreserveNewest"); @@ -141,14 +165,22 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules projectContext => string.Empty, projectContext => File.Exists(Path.Combine(projectContext.ProjectDirectory, "App.config"))); - private Func>CompileFilesTransformExecute => + private Func> CompileFilesTransformExecute => (compilerOptions, projectDirectory, projectType) => CompileFilesTransform.Transform(compilerOptions.CompileInclude); + private Func> RemoveCompileFilesTransformExecute => + (compilerOptions, projectDirectory, projectType) => + RemoveCompileFilesTransform.Transform(compilerOptions.CompileInclude); + private Func> EmbedFilesTransformExecute => (compilerOptions, projectDirectory, projectType) => EmbedFilesTransform.Transform(GetEmbedIncludeContext(compilerOptions)); + private Func> RemoveEmbedFilesTransformExecute => + (compilerOptions, projectDirectory, projectType) => + RemoveEmbedFilesTransform.Transform(GetEmbedIncludeContext(compilerOptions)); + private Func> CopyToOutputFilesTransformExecute => (compilerOptions, projectDirectory, projectType) => { @@ -167,6 +199,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules private readonly CommonCompilerOptions _configurationBuildOptions; private List> _propertyTransforms; + private List>> _removeContextTransformExecutes; private List>> _includeContextTransformExecutes; private readonly ITransformApplicator _transformApplicator; @@ -213,6 +246,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules _propertyTransforms.AddRange(EmitEntryPointTransforms); _propertyTransforms.AddRange(KeyFileTransforms); + _removeContextTransformExecutes = + new List>>() + { + RemoveCompileFilesTransformExecute, + RemoveEmbedFilesTransformExecute + }; + _includeContextTransformExecutes = new List>>() { @@ -295,6 +335,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules } } + foreach (var removeContextTransformExecutes in _removeContextTransformExecutes) + { + var nonConfigurationOutput = + removeContextTransformExecutes(compilerOptions, projectDirectory, projectType); + var configurationOutput = + removeContextTransformExecutes(configurationCompilerOptions, projectDirectory, projectType); + + if (configurationOutput != null) + { + transformApplicator.Execute(configurationOutput, itemGroup, mergeExisting: true); + } + } + foreach (var includeContextTransformExecute in _includeContextTransformExecutes) { var nonConfigurationOutput = @@ -302,7 +355,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules var configurationOutput = includeContextTransformExecute(configurationCompilerOptions, projectDirectory, projectType); - if (configurationOutput != null) { transformApplicator.Execute(configurationOutput, itemGroup, mergeExisting: true); @@ -310,25 +362,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules } } - private void RemoveCommonIncludes(IEnumerable itemsToRemoveFrom, - IEnumerable otherItems) - { - foreach (var item1 in itemsToRemoveFrom) - { - if (item1 == null) - { - continue; - } - foreach ( - var item2 in - otherItems.Where( - i => i != null && string.Equals(i.ItemType, item1.ItemType, StringComparison.Ordinal))) - { - item1.Include = string.Join(";", item1.Includes().Except(item2.Includes())); - } - } - } - private bool PropertiesAreEqual(ProjectPropertyElement nonConfigurationOutput, ProjectPropertyElement configurationOutput) { if (configurationOutput != null && nonConfigurationOutput != null) @@ -353,6 +386,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules transformApplicator.Execute(transform.Transform(compilerOptions), propertyGroup, mergeExisting: true); } + foreach (var removeContextTransformExecutes in _removeContextTransformExecutes) + { + var transform = removeContextTransformExecutes(compilerOptions, projectDirectory, projectType); + + if (transform != null) + { + transformApplicator.Execute( + transform, + itemGroup, + mergeExisting: true); + } + } + foreach (var includeContextTransformExecute in _includeContextTransformExecutes) { var transform = includeContextTransformExecute(compilerOptions, projectDirectory, projectType); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs index 3c07316e0..f95260149 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs @@ -53,10 +53,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules // Migrate Direct Deps first MigrateDependencies( project, - migrationRuleInputs.OutputMSBuildProject, + migrationRuleInputs, null, project.Dependencies, - migrationRuleInputs.ProjectXproj, migrationSettings.SolutionFile, itemGroup: noFrameworkPackageReferenceItemGroup); @@ -72,10 +71,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules MigrateDependencies( project, - migrationRuleInputs.OutputMSBuildProject, + migrationRuleInputs, targetFramework.FrameworkName, targetFramework.Dependencies, - migrationRuleInputs.ProjectXproj, migrationSettings.SolutionFile); } @@ -147,21 +145,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules mergeExisting: false); } break; - case ProjectType.Library: - if (!project.HasDependency( - (dep) => dep.Name.Trim().ToLower() == SupportedPackageVersions.NetStandardPackageName.ToLower())) - { - _transformApplicator.Execute( - PackageDependencyInfoTransform().Transform( - new PackageDependencyInfo - { - Name = SupportedPackageVersions.NetStandardPackageName, - Version = SupportedPackageVersions.NetStandardPackageVersion - }), - noFrameworkPackageReferenceItemGroup, - mergeExisting: true); - } - break; default: break; } @@ -221,20 +204,23 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules private void MigrateDependencies( Project project, - ProjectRootElement output, + MigrationRuleInputs migrationRuleInputs, NuGetFramework framework, - IEnumerable dependencies, - ProjectRootElement xproj, + IEnumerable dependencies, SlnFile solutionFile, ProjectItemGroupElement itemGroup=null) { - var projectDependencies = new HashSet(GetAllProjectReferenceNames(project, framework, xproj, solutionFile)); + var projectDependencies = new HashSet(GetAllProjectReferenceNames( + project, + framework, + migrationRuleInputs.ProjectXproj, + solutionFile)); var packageDependencies = dependencies.Where(d => !projectDependencies.Contains(d.Name)).ToList(); string condition = framework?.GetMSBuildCondition() ?? ""; itemGroup = itemGroup - ?? output.ItemGroups.FirstOrDefault(i => i.Condition == condition) - ?? output.AddItemGroup(); + ?? migrationRuleInputs.OutputMSBuildProject.ItemGroups.FirstOrDefault(i => i.Condition == condition) + ?? migrationRuleInputs.OutputMSBuildProject.AddItemGroup(); itemGroup.Condition = condition; AutoInjectImplicitProjectJsonAssemblyReferences(framework, packageDependencies); @@ -268,12 +254,36 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules } } - _transformApplicator.Execute( - transform.Transform(ToPackageDependencyInfo( + var packageDependencyInfo = ToPackageDependencyInfo( packageDependency, - _supportedPackageVersions.ProjectDependencyPackages)), - itemGroup, - mergeExisting: true); + _supportedPackageVersions.ProjectDependencyPackages); + + if (packageDependencyInfo != null && packageDependencyInfo.IsMetaPackage) + { + var metaPackageTransform = RuntimeFrameworkVersionTransformation.Transform(packageDependencyInfo); + if(metaPackageTransform == null) + { + metaPackageTransform = + NetStandardImplicitPackageVersionTransformation.Transform(packageDependencyInfo); + } + + if (migrationRuleInputs.IsMultiTFM) + { + metaPackageTransform.Condition = condition; + } + + _transformApplicator.Execute( + metaPackageTransform, + migrationRuleInputs.CommonPropertyGroup, + mergeExisting: true); + } + else + { + _transformApplicator.Execute( + transform.Transform(packageDependencyInfo), + itemGroup, + mergeExisting: true); + } } } @@ -432,5 +442,17 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules "PackageTargetFallback", t => $"$(PackageTargetFallback);{string.Join(";", t.Imports)}", t => t.Imports.OrEmptyIfNull().Any()); + + private AddPropertyTransform RuntimeFrameworkVersionTransformation => + new AddPropertyTransform( + "RuntimeFrameworkVersion", + p => p.Version, + p => p.Name.Equals("Microsoft.NETCore.App", StringComparison.OrdinalIgnoreCase)); + + private AddPropertyTransform NetStandardImplicitPackageVersionTransformation => + new AddPropertyTransform( + "NetStandardImplicitPackageVersion", + p => p.Version, + p => p.Name.Equals("NETStandard.Library", StringComparison.OrdinalIgnoreCase)); } } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/SupportedPackageVersions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/SupportedPackageVersions.cs index 28ff6336f..f1feedeb0 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/SupportedPackageVersions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/SupportedPackageVersions.cs @@ -12,6 +12,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration public string Name { get; set; } public string Version { get; set; } public string PrivateAssets { get; set; } + + public bool IsMetaPackage + { + get + { + return !string.IsNullOrEmpty(Name) && + (Name.Equals("Microsoft.NETCore.App", StringComparison.OrdinalIgnoreCase) || + Name.Equals("NETStandard.Library", StringComparison.OrdinalIgnoreCase)); + } + } } internal class SupportedPackageVersions diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs index 099f553c2..7f5d1a984 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs @@ -1,7 +1,11 @@ // 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 Microsoft.DotNet.Tools.Common; using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { @@ -25,5 +29,74 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms } public abstract U ConditionallyTransform(T source); + + protected string FormatGlobPatternsForMsbuild(IEnumerable patterns, string projectDirectory) + { + if (patterns == null) + { + return string.Empty; + } + + List mutatedPatterns = new List(patterns.Count()); + + foreach (var pattern in patterns) + { + // Do not use forward slashes + // https://github.com/Microsoft/msbuild/issues/724 + var mutatedPattern = pattern.Replace('/', '\\'); + + // MSBuild cannot copy directories + mutatedPattern = ReplaceDirectoriesWithGlobs(mutatedPattern, projectDirectory); + + mutatedPatterns.Add(mutatedPattern); + } + + return string.Join(";", mutatedPatterns); + } + + private string ReplaceDirectoriesWithGlobs(string pattern, string projectDirectory) + { + if (PatternIsDirectory(pattern, projectDirectory)) + { + return $"{pattern.TrimEnd(new char[] { '\\' })}\\**\\*"; + } + else + { + return pattern; + } + } + + private bool PatternIsDirectory(string pattern, string projectDirectory) + { + // TODO: what about /some/path/**/somedir? + // Should this even be migrated? + var path = pattern; + + if (!Path.IsPathRooted(path)) + { + path = Path.Combine(projectDirectory, path); + } + + return Directory.Exists(path); + } + + protected string ConvertTargetPathToMsbuildMetadata(string targetPath) + { + var targetIsFile = MappingsTargetPathIsFile(targetPath); + + if (targetIsFile) + { + return targetPath; + } + + return $"{targetPath}%(FileName)%(Extension)"; + } + + private bool MappingsTargetPathIsFile(string targetPath) + { + var normalizedTargetPath = PathUtility.GetPathWithDirectorySeparator(targetPath); + + return normalizedTargetPath[normalizedTargetPath.Length - 1] != Path.DirectorySeparatorChar; + } } } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs index 65630c2da..e71bcf923 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs @@ -19,11 +19,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms (itemName) => new AddItemTransform( itemName, - includeContext => FormatGlobPatternsForMsbuild(includeContext.IncludeFiles, includeContext.SourceBasePath), + includeContext => FormatGlobPatternsForMsbuild(includeContext.IncludeFiles.OrEmptyIfNull() + .Where((pattern) => !_excludePatternRule(pattern)), + includeContext.SourceBasePath), includeContext => FormatGlobPatternsForMsbuild(includeContext.ExcludeFiles, includeContext.SourceBasePath), includeContext => includeContext != null && includeContext.IncludeFiles != null - && includeContext.IncludeFiles.Count > 0); + && includeContext.IncludeFiles.Where((pattern) => !_excludePatternRule(pattern)).Count() > 0); protected virtual Func> IncludeExcludeTransformGetter => (itemName) => new AddItemTransform( @@ -36,6 +38,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms fullIncludeSet = fullIncludeSet.Union(includeContext.BuiltInsInclude.OrEmptyIfNull()); } + fullIncludeSet = fullIncludeSet.Where((pattern) => !_excludePatternRule(pattern)); + return FormatGlobPatternsForMsbuild(fullIncludeSet, includeContext.SourceBasePath); }, includeContext => @@ -50,7 +54,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { return includeContext != null && ( - (includeContext.IncludePatterns != null && includeContext.IncludePatterns.Count > 0) + (includeContext.IncludePatterns != null && includeContext.IncludePatterns.Where((pattern) => !_excludePatternRule(pattern)).Count() > 0) || (_emitBuiltInIncludes && includeContext.BuiltInsInclude != null && @@ -68,6 +72,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms private readonly string _itemName; private bool _transformMappings; + private Func _excludePatternRule; private bool _emitBuiltInIncludes; private readonly List> _metadata = new List>(); @@ -75,11 +80,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms string itemName, bool transformMappings = true, Func condition = null, - bool emitBuiltInIncludes = true) : base(condition) + bool emitBuiltInIncludes = true, + Func excludePatternsRule = null) : base(condition) { _itemName = itemName; _transformMappings = transformMappings; _emitBuiltInIncludes = emitBuiltInIncludes; + _excludePatternRule = excludePatternsRule ?? ((pattern) => false); _mappingsToTransfrom = (addItemTransform, targetPath) => { @@ -165,80 +172,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms return transformSet.Select(t => t.Item1.Transform(t.Item2)); } - protected string FormatGlobPatternsForMsbuild(IEnumerable patterns, string projectDirectory) - { - if (patterns == null) - { - return string.Empty; - } - - List mutatedPatterns = new List(patterns.Count()); - - foreach (var pattern in patterns) - { - // Do not use forward slashes - // https://github.com/Microsoft/msbuild/issues/724 - var mutatedPattern = pattern.Replace('/', '\\'); - - // MSBuild cannot copy directories - mutatedPattern = ReplaceDirectoriesWithGlobs(mutatedPattern, projectDirectory); - - mutatedPatterns.Add(mutatedPattern); - } - - return string.Join(";", mutatedPatterns); - } - - private string ReplaceDirectoriesWithGlobs(string pattern, string projectDirectory) - { - if (PatternIsDirectory(pattern, projectDirectory)) - { - return $"{pattern.TrimEnd(new char[] { '\\' })}\\**\\*"; - } - else - { - return pattern; - } - } - private AddItemTransform AddMappingToTransform( AddItemTransform addItemTransform, string targetPath) { return _mappingsToTransfrom(addItemTransform, targetPath); } - - private bool PatternIsDirectory(string pattern, string projectDirectory) - { - // TODO: what about /some/path/**/somedir? - // Should this even be migrated? - var path = pattern; - - if (!Path.IsPathRooted(path)) - { - path = Path.Combine(projectDirectory, path); - } - - return Directory.Exists(path); - } - - private string ConvertTargetPathToMsbuildMetadata(string targetPath) - { - var targetIsFile = MappingsTargetPathIsFile(targetPath); - - if (targetIsFile) - { - return targetPath; - } - - return $"{targetPath}%(FileName)%(Extension)"; - } - - private bool MappingsTargetPathIsFile(string targetPath) - { - var normalizedTargetPath = PathUtility.GetPathWithDirectorySeparator(targetPath); - - return normalizedTargetPath[normalizedTargetPath.Length - 1] != Path.DirectorySeparatorChar; - } } } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/RemoveContextTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/RemoveContextTransform.cs new file mode 100644 index 000000000..1dae3a581 --- /dev/null +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/RemoveContextTransform.cs @@ -0,0 +1,110 @@ +// 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 Microsoft.DotNet.Internal.ProjectModel.Files; +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Build.Construction; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.ProjectJsonMigration.Models; +using Microsoft.DotNet.Tools.Common; + +namespace Microsoft.DotNet.ProjectJsonMigration.Transforms +{ + internal class RemoveContextTransform : ConditionalTransform> + { + protected virtual Func> RemoveTransformGetter => + (itemName) => new RemoveItemTransform( + itemName, + includeContext => + { + var fullRemoveSet = includeContext.ExcludePatterns.OrEmptyIfNull() + .Union(includeContext.ExcludeFiles.OrEmptyIfNull()); + + return FormatGlobPatternsForMsbuild(fullRemoveSet, includeContext.SourceBasePath); + }, + includeContext => + { + return includeContext != null && + ( + (includeContext.ExcludePatterns != null && includeContext.ExcludePatterns.Count > 0) + || + (includeContext.ExcludeFiles != null && includeContext.ExcludeFiles.Count > 0) + ); + }); + + private Func> MappingsRemoveTransformGetter => + (itemName, targetPath) => AddMappingToTransform(RemoveTransformGetter(itemName), targetPath); + + private Func, string, RemoveItemTransform> _mappingsToTransfrom; + + private readonly string _itemName; + private readonly List> _metadata = new List>(); + + public RemoveContextTransform( + string itemName, + Func condition = null + ) : base(condition) + { + _itemName = itemName; + + _mappingsToTransfrom = (removeItemTransform, targetPath) => + { + var msbuildLinkMetadataValue = ConvertTargetPathToMsbuildMetadata(targetPath); + + return removeItemTransform.WithMetadata("Link", msbuildLinkMetadataValue); + }; + } + + public override IEnumerable ConditionallyTransform(IncludeContext source) + { + var transformSet = CreateTransformSet(source); + return transformSet.Select(t => t.Item1.Transform(t.Item2)); + } + + private IEnumerable, IncludeContext>> CreateTransformSet(IncludeContext source) + { + var transformSet = new List, IncludeContext>> + { + Tuple.Create(RemoveTransformGetter(_itemName), source) + }; + + if (source == null) + { + return transformSet; + } + + // Mappings must be executed before the transform set to prevent a the + // non-mapped items that will merge with mapped items from being encompassed + foreach (var mappingEntry in source.Mappings.OrEmptyIfNull()) + { + var targetPath = mappingEntry.Key; + var includeContext = mappingEntry.Value; + + transformSet.Insert(0, + Tuple.Create( + MappingsRemoveTransformGetter(_itemName, targetPath), + includeContext)); + } + + foreach (var metadataElement in _metadata) + { + foreach (var transform in transformSet) + { + transform.Item1.WithMetadata(metadataElement); + } + } + + return transformSet; + } + + private RemoveItemTransform AddMappingToTransform( + RemoveItemTransform removeItemTransform, + string targetPath) + { + return _mappingsToTransfrom(removeItemTransform, targetPath); + } + } +} diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/RemoveItemTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/RemoveItemTransform.cs new file mode 100644 index 000000000..7833e4b8b --- /dev/null +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/RemoveItemTransform.cs @@ -0,0 +1,69 @@ +// 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.Collections.Generic; +using Microsoft.Build.Construction; +using Microsoft.DotNet.ProjectJsonMigration.Models; + +namespace Microsoft.DotNet.ProjectJsonMigration.Transforms +{ + internal class RemoveItemTransform : ConditionalTransform + { + private readonly ProjectRootElement _itemObjectGenerator = ProjectRootElement.Create(); + + private readonly string _itemName; + private readonly Func _removeValueFunc; + + private readonly List> _metadata = new List>(); + + public RemoveItemTransform( + string itemName, + Func removeValueFunc, + Func condition) + : base(condition) + { + _itemName = itemName; + _removeValueFunc = removeValueFunc; + } + + public RemoveItemTransform WithMetadata(ItemMetadataValue metadata) + { + _metadata.Add(metadata); + return this; + } + + public RemoveItemTransform WithMetadata( + string metadataName, + string metadataValue, + bool expressedAsAttribute = false) + { + _metadata.Add(new ItemMetadataValue( + metadataName, + metadataValue, + expressedAsAttribute: expressedAsAttribute)); + return this; + } + + public override ProjectItemElement ConditionallyTransform(T source) + { + string removeValue = _removeValueFunc(source); + + var item = _itemObjectGenerator.AddItem(_itemName, "PlaceHolderSinceNullOrEmptyCannotBePassedToConstructor"); + item.Include = null; + item.Remove = removeValue; + + foreach (var metadata in _metadata) + { + if (metadata.ShouldWriteMetadata(source)) + { + var metametadata = item.AddMetadata(metadata.MetadataName, metadata.GetMetadataValue(source)); + metametadata.Condition = metadata.Condition; + metametadata.ExpressedAsAttribute = metadata.ExpressedAsAttribute; + } + } + + return item; + } + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs b/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs index ea942eb65..3fc98f0a4 100644 --- a/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs +++ b/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs @@ -104,6 +104,15 @@ namespace Microsoft.DotNet.TestFramework return this; } + public TestAssetInstance WithEmptyGlobalJson() + { + var file = Root.Parent.GetFile("global.json"); + + File.WriteAllText(file.FullName, @"{}"); + + return this; + } + private void CopyFiles(IEnumerable filesToCopy) { foreach (var file in filesToCopy) diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj index 1b6c8e41c..3bf1aba42 100644 --- a/src/dotnet-archive/dotnet-archive.csproj +++ b/src/dotnet-archive/dotnet-archive.csproj @@ -2,7 +2,7 @@ - netcoreapp1.0 + netcoreapp1.1 Exe @@ -13,7 +13,7 @@ - 1.0.3 + 1.1.0 diff --git a/src/dotnet/CommandLine/CommandParsingException.cs b/src/dotnet/CommandLine/CommandParsingException.cs index 375c17394..8eef0ea6f 100644 --- a/src/dotnet/CommandLine/CommandParsingException.cs +++ b/src/dotnet/CommandLine/CommandParsingException.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools; namespace Microsoft.DotNet.Cli.CommandLine @@ -18,6 +19,8 @@ namespace Microsoft.DotNet.Cli.CommandLine { Command = command; _isRequireSubCommandMissing = isRequireSubCommandMissing; + + Data.Add("CLI_User_Displayed_Exception", true); } public CommandLineApplication Command { get; } diff --git a/src/dotnet/MulticoreJitActivator.cs b/src/dotnet/MulticoreJitActivator.cs index a22bb39ab..c222bab4c 100644 --- a/src/dotnet/MulticoreJitActivator.cs +++ b/src/dotnet/MulticoreJitActivator.cs @@ -4,7 +4,6 @@ using System; using System.Runtime.Loader; using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Cli.Utils.ExceptionExtensions; using Microsoft.DotNet.Tools.Common; namespace Microsoft.DotNet.Cli diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index e95d56aa4..47f8cc897 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Configurer; using Microsoft.DotNet.PlatformAbstractions; using Microsoft.DotNet.Tools.Add; @@ -76,9 +77,11 @@ namespace Microsoft.DotNet.Cli return ProcessArgs(args); } } - catch (GracefulException e) + catch (Exception e) when (e.ShouldBeDisplayedAsError()) { - Reporter.Error.WriteLine(CommandContext.IsVerbose() ? e.ToString().Red().Bold() : e.Message.Red().Bold()); + Reporter.Error.WriteLine(CommandContext.IsVerbose() ? + e.ToString().Red().Bold() : + e.Message.Red().Bold()); return 1; } diff --git a/src/dotnet/SlnFileExtensions.cs b/src/dotnet/SlnFileExtensions.cs new file mode 100644 index 000000000..7fbf0fb70 --- /dev/null +++ b/src/dotnet/SlnFileExtensions.cs @@ -0,0 +1,330 @@ +// 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 Microsoft.Build.Construction; +using Microsoft.Build.Evaluation; +using Microsoft.Build.Execution; +using Microsoft.DotNet.Cli.Sln.Internal; +using Microsoft.DotNet.Cli.Utils; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Microsoft.DotNet.Tools.Common +{ + internal static class SlnFileExtensions + { + public static void AddProject(this SlnFile slnFile, string fullProjectPath) + { + if (string.IsNullOrEmpty(fullProjectPath)) + { + throw new ArgumentException(); + } + + var relativeProjectPath = PathUtility.GetRelativePath( + PathUtility.EnsureTrailingSlash(slnFile.BaseDirectory), + fullProjectPath); + + if (slnFile.Projects.Any((p) => + string.Equals(p.FilePath, relativeProjectPath, StringComparison.OrdinalIgnoreCase))) + { + Reporter.Output.WriteLine(string.Format( + CommonLocalizableStrings.SolutionAlreadyContainsProject, + slnFile.FullPath, + relativeProjectPath)); + } + else + { + var projectInstance = new ProjectInstance(fullProjectPath); + + var slnProject = new SlnProject + { + Id = projectInstance.GetProjectId(), + TypeGuid = projectInstance.GetProjectTypeGuid(), + Name = Path.GetFileNameWithoutExtension(relativeProjectPath), + FilePath = relativeProjectPath + }; + + slnFile.AddDefaultBuildConfigurations(slnProject); + + slnFile.AddSolutionFolders(slnProject); + + slnFile.Projects.Add(slnProject); + + Reporter.Output.WriteLine( + string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, relativeProjectPath)); + } + } + + public static void AddDefaultBuildConfigurations(this SlnFile slnFile, SlnProject slnProject) + { + if (slnProject == null) + { + throw new ArgumentException(); + } + + var defaultConfigurations = new List() + { + "Debug|Any CPU", + "Debug|x64", + "Debug|x86", + "Release|Any CPU", + "Release|x64", + "Release|x86", + }; + + // NOTE: The order you create the sections determines the order they are written to the sln + // file. In the case of an empty sln file, in order to make sure the solution configurations + // section comes first we need to add it first. This doesn't affect correctness but does + // stop VS from re-ordering things later on. Since we are keeping the SlnFile class low-level + // it shouldn't care about the VS implementation details. That's why we handle this here. + AddDefaultSolutionConfigurations(defaultConfigurations, slnFile.SolutionConfigurationsSection); + AddDefaultProjectConfigurations( + defaultConfigurations, + slnFile.ProjectConfigurationsSection.GetOrCreatePropertySet(slnProject.Id)); + } + + private static void AddDefaultSolutionConfigurations( + List defaultConfigurations, + SlnPropertySet solutionConfigs) + { + foreach (var config in defaultConfigurations) + { + if (!solutionConfigs.ContainsKey(config)) + { + solutionConfigs[config] = config; + } + } + } + + private static void AddDefaultProjectConfigurations( + List defaultConfigurations, + SlnPropertySet projectConfigs) + { + foreach (var config in defaultConfigurations) + { + var activeCfgKey = $"{config}.ActiveCfg"; + if (!projectConfigs.ContainsKey(activeCfgKey)) + { + projectConfigs[activeCfgKey] = config; + } + + var build0Key = $"{config}.Build.0"; + if (!projectConfigs.ContainsKey(build0Key)) + { + projectConfigs[build0Key] = config; + } + } + } + + public static void AddSolutionFolders(this SlnFile slnFile, SlnProject slnProject) + { + if (slnProject == null) + { + throw new ArgumentException(); + } + + var solutionFolders = slnProject.GetSolutionFoldersFromProject(); + + if (solutionFolders.Any()) + { + var nestedProjectsSection = slnFile.Sections.GetOrCreateSection( + "NestedProjects", + SlnSectionType.PreProcess); + + var pathToGuidMap = slnFile.GetSolutionFolderPaths(nestedProjectsSection.Properties); + + string parentDirGuid = null; + var solutionFolderHierarchy = string.Empty; + foreach (var dir in solutionFolders) + { + solutionFolderHierarchy = Path.Combine(solutionFolderHierarchy, dir); + if (pathToGuidMap.ContainsKey(solutionFolderHierarchy)) + { + parentDirGuid = pathToGuidMap[solutionFolderHierarchy]; + } + else + { + var solutionFolder = new SlnProject + { + Id = Guid.NewGuid().ToString("B").ToUpper(), + TypeGuid = ProjectTypeGuids.SolutionFolderGuid, + Name = dir, + FilePath = dir + }; + + slnFile.Projects.Add(solutionFolder); + + if (parentDirGuid != null) + { + nestedProjectsSection.Properties[solutionFolder.Id] = parentDirGuid; + } + parentDirGuid = solutionFolder.Id; + } + } + + nestedProjectsSection.Properties[slnProject.Id] = parentDirGuid; + } + } + + private static IDictionary GetSolutionFolderPaths( + this SlnFile slnFile, + SlnPropertySet nestedProjects) + { + var solutionFolderPaths = new Dictionary(); + + var solutionFolderProjects = slnFile.Projects.GetProjectsByType(ProjectTypeGuids.SolutionFolderGuid); + foreach (var slnProject in solutionFolderProjects) + { + var path = slnProject.FilePath; + var id = slnProject.Id; + while (nestedProjects.ContainsKey(id)) + { + id = nestedProjects[id]; + var parentSlnProject = solutionFolderProjects.Where(p => p.Id == id).Single(); + path = Path.Combine(parentSlnProject.FilePath, path); + } + + solutionFolderPaths[path] = slnProject.Id; + } + + return solutionFolderPaths; + } + + public static bool RemoveProject(this SlnFile slnFile, string projectPath) + { + if (string.IsNullOrEmpty(projectPath)) + { + throw new ArgumentException(); + } + + var projectPathNormalized = PathUtility.GetPathWithDirectorySeparator(projectPath); + + var projectsToRemove = slnFile.Projects.Where((p) => + string.Equals(p.FilePath, projectPathNormalized, StringComparison.OrdinalIgnoreCase)).ToList(); + + bool projectRemoved = false; + if (projectsToRemove.Count == 0) + { + Reporter.Output.WriteLine(string.Format( + CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, + projectPath)); + } + else + { + foreach (var slnProject in projectsToRemove) + { + var buildConfigsToRemove = slnFile.ProjectConfigurationsSection.GetPropertySet(slnProject.Id); + if (buildConfigsToRemove != null) + { + slnFile.ProjectConfigurationsSection.Remove(buildConfigsToRemove); + } + + var nestedProjectsSection = slnFile.Sections.GetSection( + "NestedProjects", + SlnSectionType.PreProcess); + if (nestedProjectsSection != null && nestedProjectsSection.Properties.ContainsKey(slnProject.Id)) + { + nestedProjectsSection.Properties.Remove(slnProject.Id); + } + + slnFile.Projects.Remove(slnProject); + Reporter.Output.WriteLine( + string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, slnProject.FilePath)); + } + + projectRemoved = true; + } + + return projectRemoved; + } + + public static void RemoveEmptyConfigurationSections(this SlnFile slnFile) + { + if (slnFile.Projects.Count == 0) + { + var solutionConfigs = slnFile.Sections.GetSection("SolutionConfigurationPlatforms"); + if (solutionConfigs != null) + { + slnFile.Sections.Remove(solutionConfigs); + } + + var projectConfigs = slnFile.Sections.GetSection("ProjectConfigurationPlatforms"); + if (projectConfigs != null) + { + slnFile.Sections.Remove(projectConfigs); + } + } + } + + public static void RemoveEmptySolutionFolders(this SlnFile slnFile) + { + var solutionFolderProjects = slnFile.Projects + .GetProjectsByType(ProjectTypeGuids.SolutionFolderGuid) + .ToList(); + + if (solutionFolderProjects.Any()) + { + var nestedProjectsSection = slnFile.Sections.GetSection( + "NestedProjects", + SlnSectionType.PreProcess); + + if (nestedProjectsSection == null) + { + foreach (var solutionFolderProject in solutionFolderProjects) + { + if (solutionFolderProject.Sections.Count() == 0) + { + slnFile.Projects.Remove(solutionFolderProject); + } + } + } + else + { + var solutionFoldersInUse = slnFile.GetSolutionFoldersThatContainProjectsInItsHierarchy( + nestedProjectsSection.Properties); + + foreach (var solutionFolderProject in solutionFolderProjects) + { + if (!solutionFoldersInUse.Contains(solutionFolderProject.Id)) + { + nestedProjectsSection.Properties.Remove(solutionFolderProject.Id); + if (solutionFolderProject.Sections.Count() == 0) + { + slnFile.Projects.Remove(solutionFolderProject); + } + } + } + + if (nestedProjectsSection.IsEmpty) + { + slnFile.Sections.Remove(nestedProjectsSection); + } + } + } + } + + private static HashSet GetSolutionFoldersThatContainProjectsInItsHierarchy( + this SlnFile slnFile, + SlnPropertySet nestedProjects) + { + var solutionFoldersInUse = new HashSet(); + + var nonSolutionFolderProjects = slnFile.Projects.GetProjectsNotOfType( + ProjectTypeGuids.SolutionFolderGuid); + + foreach (var nonSolutionFolderProject in nonSolutionFolderProjects) + { + var id = nonSolutionFolderProject.Id; + while (nestedProjects.ContainsKey(id)) + { + id = nestedProjects[id]; + solutionFoldersInUse.Add(id); + } + } + + return solutionFoldersInUse; + } + } +} diff --git a/src/dotnet/SlnProjectCollectionExtensions.cs b/src/dotnet/SlnProjectCollectionExtensions.cs index d99b34eee..09499e5a2 100644 --- a/src/dotnet/SlnProjectCollectionExtensions.cs +++ b/src/dotnet/SlnProjectCollectionExtensions.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Microsoft.DotNet.Tools.Common { - public static class SlnProjectCollectionExtensions + internal static class SlnProjectCollectionExtensions { public static IEnumerable GetProjectsByType( this SlnProjectCollection projects, diff --git a/src/dotnet/SlnProjectExtensions.cs b/src/dotnet/SlnProjectExtensions.cs index 925089beb..80ebf5d3e 100644 --- a/src/dotnet/SlnProjectExtensions.cs +++ b/src/dotnet/SlnProjectExtensions.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Microsoft.DotNet.Tools.Common { - public static class SlnProjectExtensions + internal static class SlnProjectExtensions { public static IList GetSolutionFoldersFromProject(this SlnProject project) { diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-reference/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-reference/xlf/LocalizableStrings.de.xlf index becde7aba..ab216036c 100644 --- a/src/dotnet/commands/dotnet-add/dotnet-add-reference/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-add/dotnet-add-reference/xlf/LocalizableStrings.de.xlf @@ -10,7 +10,7 @@ Command to add project to project reference - Befehl zum Hinzufügen des Projekts zum Projektverweis + Befehl zum Hinzufügen eines Projekt-zu-Projekt-Verweises diff --git a/src/dotnet/commands/dotnet-build/Program.cs b/src/dotnet/commands/dotnet-build/Program.cs index 64fb721e8..785d3b944 100644 --- a/src/dotnet/commands/dotnet-build/Program.cs +++ b/src/dotnet/commands/dotnet-build/Program.cs @@ -29,7 +29,7 @@ namespace Microsoft.DotNet.Tools.Build CommandOption runtimeOption = app.Option( $"-r|--runtime <{LocalizableStrings.RuntimeOptionName}>", LocalizableStrings.RuntimeOptionDescription, CommandOptionType.SingleValue); - CommandOption configurationOption = app.Option($"-c|--configuration <{LocalizableStrings.ConfigurationOptionName}>", LocalizableStrings.FrameworkOptionDescription, CommandOptionType.SingleValue); + CommandOption configurationOption = app.Option($"-c|--configuration <{LocalizableStrings.ConfigurationOptionName}>", LocalizableStrings.ConfigurationOptionDescription, CommandOptionType.SingleValue); CommandOption versionSuffixOption = app.Option($"--version-suffix <{LocalizableStrings.VersionSuffixOptionName}>", LocalizableStrings.VersionSuffixOptionDescription, CommandOptionType.SingleValue); CommandOption noIncrementalOption = app.Option("--no-incremental", LocalizableStrings.NoIncrementialOptionDescription, CommandOptionType.NoValue); diff --git a/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs b/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs index f443a269c..feb594fc8 100644 --- a/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs @@ -31,6 +31,34 @@ Defaults to current directory if nothing is specified."; public const string MigrationFailedError = "Migration failed."; - public const string MigrationAdditionalHelp = "Your project has been migrated to the .csproj format and can be used with this build of the .NET Core Tools. Please visit https://aka.ms/coremigration to report issues or ask for help."; + public const string MigrationAdditionalHelp = "The project migration has finished. Please visit https://aka.ms/coremigration to report any issues you've encountered or ask for help."; + + public const string MigrationReportSummary = "Summary"; + + public const string MigrationReportTotalProjects = "Total Projects: {0}"; + + public const string MigrationReportSucceededProjects = "Succeeded Projects: {0}"; + + public const string MigrationReportFailedProjects = "Failed Projects: {0}"; + + public const string ProjectMigrationSucceeded = "Project {0} migration succeeded ({1})."; + + public const string ProjectMigrationFailed = "Project {0} migration failed ({1})."; + + public const string MigrationFailedToFindProjectInGlobalJson = "Unable to find any projects in global.json."; + + public const string MigrationUnableToFindProjects = "Unable to find any projects in {0}."; + + public const string MigrationProjectJsonNotFound = "No project.json file found in '{0}'."; + + public const string MigrationInvalidProjectArgument = "Invalid project argument - '{0}' is not a project.json, global.json, or solution.sln file and a directory named '{0}' doesn't exist."; + + public const string MigratonUnableToFindProjectJson = "Unable to find project.json file at {0}."; + + public const string MigrationUnableToFindGlobalJson = "Unable to find global settings file at {0}."; + + public const string MigrationUnableToFindSolutionFile = "Unable to find the solution file at {0}."; + + public const string MigrateFilesBackupLocation = "Files backed up to {0}"; } -} \ No newline at end of file +} diff --git a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs index bc7e6b444..131a9c3c2 100644 --- a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs +++ b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs @@ -103,7 +103,24 @@ namespace Microsoft.DotNet.Tools.Migrate private void UpdateSolutionFile(MigrationReport migrationReport) { - if (_slnFile == null) + if(_slnFile != null) + { + UpdateSolutionFile(migrationReport, _slnFile); + } + else + { + foreach (var slnPath in _workspaceDirectory.EnumerateFiles("*.sln")) + { + var slnFile = SlnFile.Read(slnPath.FullName); + + UpdateSolutionFile(migrationReport, slnFile); + } + } + } + + private void UpdateSolutionFile(MigrationReport migrationReport, SlnFile slnFile) + { + if (slnFile == null) { return; } @@ -115,7 +132,7 @@ namespace Microsoft.DotNet.Tools.Migrate var csprojFilesToAdd = new HashSet(); - var slnPathWithTrailingSlash = PathUtility.EnsureTrailingSlash(_slnFile.BaseDirectory); + var slnPathWithTrailingSlash = PathUtility.EnsureTrailingSlash(slnFile.BaseDirectory); foreach (var report in migrationReport.ProjectMigrationReports) { var reportPathWithTrailingSlash = PathUtility.EnsureTrailingSlash(report.ProjectDirectory); @@ -124,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Migrate reportPathWithTrailingSlash); var xprojPath = Path.Combine(relativeReportPath, report.ProjectName + ".xproj"); - var xprojProjectsReferencedBySolution = _slnFile.Projects.Where(p => p.FilePath == xprojPath); + var xprojProjectsReferencedBySolution = slnFile.Projects.Where(p => p.FilePath == xprojPath); var migratedProjectName = report.ProjectName + ".csproj"; if (xprojProjectsReferencedBySolution.Count() == 1) @@ -138,7 +155,7 @@ namespace Microsoft.DotNet.Tools.Migrate else { var csprojPath = Path.Combine(relativeReportPath, migratedProjectName); - var solutionContainsCsprojPriorToMigration = _slnFile.Projects + var solutionContainsCsprojPriorToMigration = slnFile.Projects .Where(p => p.FilePath == csprojPath) .Any(); @@ -155,21 +172,43 @@ namespace Microsoft.DotNet.Tools.Migrate } Version version; - if (!Version.TryParse(_slnFile.VisualStudioVersion, out version) || version.Major < 15) + if (!Version.TryParse(slnFile.VisualStudioVersion, out version) || version.Major < 15) { - _slnFile.ProductDescription = ProductDescription; - _slnFile.VisualStudioVersion = VisualStudioVersion; - _slnFile.MinimumVisualStudioVersion = MinimumVisualStudioVersion; + slnFile.ProductDescription = ProductDescription; + slnFile.VisualStudioVersion = VisualStudioVersion; + slnFile.MinimumVisualStudioVersion = MinimumVisualStudioVersion; } - _slnFile.Write(); + RemoveReferencesToMigratedFiles(slnFile); + + slnFile.Write(); foreach (var csprojFile in csprojFilesToAdd) { - AddProject(_slnFile.FullPath, csprojFile); + AddProject(slnFile.FullPath, csprojFile); } } + private void RemoveReferencesToMigratedFiles(SlnFile slnFile) + { + var solutionFolders = slnFile.Projects.GetProjectsByType(ProjectTypeGuids.SolutionFolderGuid); + + foreach (var solutionFolder in solutionFolders) + { + var solutionItems = solutionFolder.Sections.GetSection("SolutionItems"); + if (solutionItems != null && solutionItems.Properties.ContainsKey("global.json")) + { + solutionItems.Properties.Remove("global.json"); + if (solutionItems.IsEmpty) + { + solutionFolder.Sections.Remove(solutionItems); + } + } + } + + slnFile.RemoveEmptySolutionFolders(); + } + private void AddProject(string slnPath, string csprojPath) { List args = new List() @@ -214,7 +253,9 @@ namespace Microsoft.DotNet.Tools.Migrate backupPlan.PerformBackup(); - Reporter.Output.WriteLine($"Files backed up to {backupPlan.RootBackupDirectory.FullName}"); + Reporter.Output.WriteLine(string.Format( + LocalizableStrings.MigrateFilesBackupLocation, + backupPlan.RootBackupDirectory.FullName)); } private void WriteReport(MigrationReport migrationReport) @@ -238,6 +279,8 @@ namespace Microsoft.DotNet.Tools.Migrate { var errorContent = GetProjectReportErrorContent(projectMigrationReport, colored: true); var successContent = GetProjectReportSuccessContent(projectMigrationReport, colored: true); + var warningContent = GetProjectReportWarningContent(projectMigrationReport, colored: true); + Reporter.Output.WriteLine(warningContent); if (!string.IsNullOrEmpty(errorContent)) { Reporter.Error.WriteLine(errorContent); @@ -266,6 +309,8 @@ namespace Microsoft.DotNet.Tools.Migrate { var errorContent = GetProjectReportErrorContent(projectMigrationReport, colored: colored); var successContent = GetProjectReportSuccessContent(projectMigrationReport, colored: colored); + var warningContent = GetProjectReportWarningContent(projectMigrationReport, colored: colored); + sb.AppendLine(warningContent); if (!string.IsNullOrEmpty(errorContent)) { sb.AppendLine(errorContent); @@ -285,10 +330,15 @@ namespace Microsoft.DotNet.Tools.Migrate { StringBuilder sb = new StringBuilder(); - sb.AppendLine("Summary"); - sb.AppendLine($"Total Projects: {migrationReport.MigratedProjectsCount}"); - sb.AppendLine($"Succeeded Projects: {migrationReport.SucceededProjectsCount}"); - sb.AppendLine($"Failed Projects: {migrationReport.FailedProjectsCount}"); + sb.AppendLine(LocalizableStrings.MigrationReportSummary); + sb.AppendLine( + string.Format(LocalizableStrings.MigrationReportTotalProjects, migrationReport.MigratedProjectsCount)); + sb.AppendLine(string.Format( + LocalizableStrings.MigrationReportSucceededProjects, + migrationReport.SucceededProjectsCount)); + sb.AppendLine(string.Format( + LocalizableStrings.MigrationReportFailedProjects, + migrationReport.FailedProjectsCount)); return sb.ToString(); } @@ -296,7 +346,23 @@ namespace Microsoft.DotNet.Tools.Migrate private string GetProjectReportSuccessContent(ProjectMigrationReport projectMigrationReport, bool colored) { Func GreenIfColored = (str) => colored ? str.Green() : str; - return GreenIfColored($"Project {projectMigrationReport.ProjectName} migration succeeded ({projectMigrationReport.ProjectDirectory})"); + return GreenIfColored(string.Format( + LocalizableStrings.ProjectMigrationSucceeded, + projectMigrationReport.ProjectName, + projectMigrationReport.ProjectDirectory)); + } + + private string GetProjectReportWarningContent(ProjectMigrationReport projectMigrationReport, bool colored) + { + StringBuilder sb = new StringBuilder(); + Func YellowIfColored = (str) => colored ? str.Yellow() : str; + + foreach (var warning in projectMigrationReport.Warnings) + { + sb.AppendLine(YellowIfColored(warning)); + } + + return sb.ToString(); } private string GetProjectReportErrorContent(ProjectMigrationReport projectMigrationReport, bool colored) @@ -306,7 +372,10 @@ namespace Microsoft.DotNet.Tools.Migrate if (projectMigrationReport.Errors.Any()) { - sb.AppendLine(RedIfColored($"Project {projectMigrationReport.ProjectName} migration failed ({projectMigrationReport.ProjectDirectory})")); + sb.AppendLine(RedIfColored(string.Format( + LocalizableStrings.ProjectMigrationFailed, + projectMigrationReport.ProjectName, + projectMigrationReport.ProjectDirectory))); foreach (var error in projectMigrationReport.Errors.Select(e => e.GetFormattedErrorMessage())) { @@ -336,7 +405,7 @@ namespace Microsoft.DotNet.Tools.Migrate if (!projects.Any()) { - throw new GracefulException("Unable to find any projects in global.json"); + throw new GracefulException(LocalizableStrings.MigrationFailedToFindProjectInGlobalJson); } } else if (File.Exists(projectArg) && @@ -346,7 +415,8 @@ namespace Microsoft.DotNet.Tools.Migrate if (!projects.Any()) { - throw new GracefulException($"Unable to find any projects in {projectArg}"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationUnableToFindProjects, projectArg)); } } else if (Directory.Exists(projectArg)) @@ -355,12 +425,14 @@ namespace Microsoft.DotNet.Tools.Migrate if (!projects.Any()) { - throw new GracefulException($"No project.json file found in '{projectArg}'"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationProjectJsonNotFound, projectArg)); } } else { - throw new GracefulException($"Invalid project argument - '{projectArg}' is not a project.json, global.json, or solution.sln file and a directory named '{projectArg}' doesn't exist."); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationInvalidProjectArgument, projectArg)); } foreach (var project in projects) @@ -386,7 +458,7 @@ namespace Microsoft.DotNet.Tools.Migrate return projectJson; } - throw new GracefulException($"Unable to find project file at {projectJson}"); + throw new GracefulException(string.Format(LocalizableStrings.MigratonUnableToFindProjectJson, projectJson)); } private IEnumerable GetProjectsFromGlobalJson(string globalJson) @@ -418,7 +490,8 @@ namespace Microsoft.DotNet.Tools.Migrate { if (!File.Exists(globalJson)) { - throw new GracefulException($"Unable to find global settings file at {globalJson}"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationUnableToFindGlobalJson, globalJson)); } var globalJsonDirectory = Path.GetDirectoryName(globalJson); @@ -429,7 +502,8 @@ namespace Microsoft.DotNet.Tools.Migrate { if (!File.Exists(slnPath)) { - throw new GracefulException($"Unable to find the solution file at {slnPath}"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationUnableToFindSolutionFile, slnPath)); } _slnFile = SlnFile.Read(slnPath); diff --git a/src/dotnet/commands/dotnet-new/CSharp_Mstest/$projectName$.csproj b/src/dotnet/commands/dotnet-new/CSharp_Mstest/$projectName$.csproj index 689b3f8f2..5c1b545d3 100644 --- a/src/dotnet/commands/dotnet-new/CSharp_Mstest/$projectName$.csproj +++ b/src/dotnet/commands/dotnet-new/CSharp_Mstest/$projectName$.csproj @@ -1,14 +1,13 @@ - Exe netcoreapp1.0 - - - + + + diff --git a/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj b/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj index 35d10cc4c..fe8e903d9 100644 --- a/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj +++ b/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj @@ -9,6 +9,6 @@ - + diff --git a/src/dotnet/commands/dotnet-new/CSharp_Web1.1/$projectName$.csproj b/src/dotnet/commands/dotnet-new/CSharp_Web1.1/$projectName$.csproj index 17ceafd29..d47c2a3c4 100644 --- a/src/dotnet/commands/dotnet-new/CSharp_Web1.1/$projectName$.csproj +++ b/src/dotnet/commands/dotnet-new/CSharp_Web1.1/$projectName$.csproj @@ -6,9 +6,9 @@ - + - + diff --git a/src/dotnet/commands/dotnet-new/CSharp_Xunittest/$projectName$.csproj b/src/dotnet/commands/dotnet-new/CSharp_Xunittest/$projectName$.csproj index 1de3d53ff..d9861e85f 100644 --- a/src/dotnet/commands/dotnet-new/CSharp_Xunittest/$projectName$.csproj +++ b/src/dotnet/commands/dotnet-new/CSharp_Xunittest/$projectName$.csproj @@ -1,12 +1,11 @@ - Exe netcoreapp1.0 - + diff --git a/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj index 00636ee77..29391a64b 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj @@ -1,7 +1,6 @@ - Exe netcoreapp1.0 false @@ -14,9 +13,9 @@ - - - + + + diff --git a/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj index 6c1ac726b..5d64ddfc6 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj @@ -20,7 +20,7 @@ - + diff --git a/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj index 2197d2277..abe460164 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj @@ -1,7 +1,6 @@ - Exe netcoreapp1.0 false @@ -14,7 +13,7 @@ - + diff --git a/src/dotnet/commands/dotnet-sln/add/Program.cs b/src/dotnet/commands/dotnet-sln/add/Program.cs index 889506662..6b6124a29 100644 --- a/src/dotnet/commands/dotnet-sln/add/Program.cs +++ b/src/dotnet/commands/dotnet-sln/add/Program.cs @@ -1,9 +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 Microsoft.Build.Construction; -using Microsoft.Build.Evaluation; -using Microsoft.Build.Execution; using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.Cli.Utils; @@ -49,7 +46,7 @@ namespace Microsoft.DotNet.Tools.Sln.Add int preAddProjectCount = slnFile.Projects.Count; foreach (var fullProjectPath in fullProjectPaths) { - AddProject(slnFile, fullProjectPath); + slnFile.AddProject(fullProjectPath); } if (slnFile.Projects.Count > preAddProjectCount) @@ -59,165 +56,5 @@ namespace Microsoft.DotNet.Tools.Sln.Add return 0; } - - private void AddProject(SlnFile slnFile, string fullProjectPath) - { - var relativeProjectPath = PathUtility.GetRelativePath( - PathUtility.EnsureTrailingSlash(slnFile.BaseDirectory), - fullProjectPath); - - if (slnFile.Projects.Any((p) => - string.Equals(p.FilePath, relativeProjectPath, StringComparison.OrdinalIgnoreCase))) - { - Reporter.Output.WriteLine(string.Format( - CommonLocalizableStrings.SolutionAlreadyContainsProject, - slnFile.FullPath, - relativeProjectPath)); - } - else - { - var projectInstance = new ProjectInstance(fullProjectPath); - - var slnProject = new SlnProject - { - Id = projectInstance.GetProjectId(), - TypeGuid = projectInstance.GetProjectTypeGuid(), - Name = Path.GetFileNameWithoutExtension(relativeProjectPath), - FilePath = relativeProjectPath - }; - - AddDefaultBuildConfigurations(slnFile, slnProject); - - AddSolutionFolders(slnFile, slnProject); - - slnFile.Projects.Add(slnProject); - - Reporter.Output.WriteLine( - string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, relativeProjectPath)); - } - } - - private void AddDefaultBuildConfigurations(SlnFile slnFile, SlnProject slnProject) - { - var defaultConfigurations = new List() - { - "Debug|Any CPU", - "Debug|x64", - "Debug|x86", - "Release|Any CPU", - "Release|x64", - "Release|x86", - }; - - // NOTE: The order you create the sections determines the order they are written to the sln - // file. In the case of an empty sln file, in order to make sure the solution configurations - // section comes first we need to add it first. This doesn't affect correctness but does - // stop VS from re-ordering things later on. Since we are keeping the SlnFile class low-level - // it shouldn't care about the VS implementation details. That's why we handle this here. - AddDefaultSolutionConfigurations(defaultConfigurations, slnFile.SolutionConfigurationsSection); - AddDefaultProjectConfigurations( - defaultConfigurations, - slnFile.ProjectConfigurationsSection.GetOrCreatePropertySet(slnProject.Id)); - } - - private void AddDefaultSolutionConfigurations( - List defaultConfigurations, - SlnPropertySet solutionConfigs) - { - foreach (var config in defaultConfigurations) - { - if (!solutionConfigs.ContainsKey(config)) - { - solutionConfigs[config] = config; - } - } - } - - private void AddDefaultProjectConfigurations( - List defaultConfigurations, - SlnPropertySet projectConfigs) - { - foreach (var config in defaultConfigurations) - { - var activeCfgKey = $"{config}.ActiveCfg"; - if (!projectConfigs.ContainsKey(activeCfgKey)) - { - projectConfigs[activeCfgKey] = config; - } - - var build0Key = $"{config}.Build.0"; - if (!projectConfigs.ContainsKey(build0Key)) - { - projectConfigs[build0Key] = config; - } - } - } - - private void AddSolutionFolders(SlnFile slnFile, SlnProject slnProject) - { - var solutionFolders = slnProject.GetSolutionFoldersFromProject(); - - if (solutionFolders.Any()) - { - var nestedProjectsSection = slnFile.Sections.GetOrCreateSection( - "NestedProjects", - SlnSectionType.PreProcess); - - var pathToGuidMap = GetSolutionFolderPaths(slnFile, nestedProjectsSection.Properties); - - string parentDirGuid = null; - var solutionFolderHierarchy = string.Empty; - foreach (var dir in solutionFolders) - { - solutionFolderHierarchy = Path.Combine(solutionFolderHierarchy, dir); - if (pathToGuidMap.ContainsKey(solutionFolderHierarchy)) - { - parentDirGuid = pathToGuidMap[solutionFolderHierarchy]; - } - else - { - var solutionFolder = new SlnProject - { - Id = Guid.NewGuid().ToString("B").ToUpper(), - TypeGuid = ProjectTypeGuids.SolutionFolderGuid, - Name = dir, - FilePath = dir - }; - - slnFile.Projects.Add(solutionFolder); - - if (parentDirGuid != null) - { - nestedProjectsSection.Properties[solutionFolder.Id] = parentDirGuid; - } - parentDirGuid = solutionFolder.Id; - } - } - - nestedProjectsSection.Properties[slnProject.Id] = parentDirGuid; - } - } - - private IDictionary GetSolutionFolderPaths(SlnFile slnFile, SlnPropertySet nestedProjects) - { - var solutionFolderPaths = new Dictionary(); - - var solutionFolderProjects = slnFile.Projects.GetProjectsByType(ProjectTypeGuids.SolutionFolderGuid); - foreach (var slnProject in solutionFolderProjects) - { - var path = slnProject.FilePath; - var id = slnProject.Id; - while (nestedProjects.ContainsKey(id)) - { - id = nestedProjects[id]; - var parentSlnProject = solutionFolderProjects.Where(p => p.Id == id).Single(); - path = Path.Combine(parentSlnProject.FilePath, path); - } - - solutionFolderPaths[path] = slnProject.Id; - } - - return solutionFolderPaths; - } } } diff --git a/src/dotnet/commands/dotnet-sln/remove/Program.cs b/src/dotnet/commands/dotnet-sln/remove/Program.cs index 18f3866e5..c147052cd 100644 --- a/src/dotnet/commands/dotnet-sln/remove/Program.cs +++ b/src/dotnet/commands/dotnet-sln/remove/Program.cs @@ -48,12 +48,12 @@ namespace Microsoft.DotNet.Tools.Sln.Remove bool slnChanged = false; foreach (var path in relativeProjectPaths) { - slnChanged |= RemoveProject(slnFile, path); + slnChanged |= slnFile.RemoveProject(path); } - RemoveEmptyConfigurationSections(slnFile); + slnFile.RemoveEmptyConfigurationSections(); - RemoveEmptySolutionFolders(slnFile); + slnFile.RemoveEmptySolutionFolders(); if (slnChanged) { @@ -62,120 +62,5 @@ namespace Microsoft.DotNet.Tools.Sln.Remove return 0; } - - private bool RemoveProject(SlnFile slnFile, string projectPath) - { - var projectPathNormalized = PathUtility.GetPathWithDirectorySeparator(projectPath); - - var projectsToRemove = slnFile.Projects.Where((p) => - string.Equals(p.FilePath, projectPathNormalized, StringComparison.OrdinalIgnoreCase)).ToList(); - - bool projectRemoved = false; - if (projectsToRemove.Count == 0) - { - Reporter.Output.WriteLine(string.Format( - CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, - projectPath)); - } - else - { - foreach (var slnProject in projectsToRemove) - { - var buildConfigsToRemove = slnFile.ProjectConfigurationsSection.GetPropertySet(slnProject.Id); - if (buildConfigsToRemove != null) - { - slnFile.ProjectConfigurationsSection.Remove(buildConfigsToRemove); - } - - var nestedProjectsSection = slnFile.Sections.GetSection( - "NestedProjects", - SlnSectionType.PreProcess); - if (nestedProjectsSection != null && nestedProjectsSection.Properties.ContainsKey(slnProject.Id)) - { - nestedProjectsSection.Properties.Remove(slnProject.Id); - } - - slnFile.Projects.Remove(slnProject); - Reporter.Output.WriteLine( - string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, slnProject.FilePath)); - } - - projectRemoved = true; - } - - return projectRemoved; - } - - private void RemoveEmptyConfigurationSections(SlnFile slnFile) - { - if (slnFile.Projects.Count == 0) - { - var solutionConfigs = slnFile.Sections.GetSection("SolutionConfigurationPlatforms"); - if (solutionConfigs != null) - { - slnFile.Sections.Remove(solutionConfigs); - } - - var projectConfigs = slnFile.Sections.GetSection("ProjectConfigurationPlatforms"); - if (projectConfigs != null) - { - slnFile.Sections.Remove(projectConfigs); - } - } - } - - private void RemoveEmptySolutionFolders(SlnFile slnFile) - { - var solutionFolderProjects = slnFile.Projects - .GetProjectsByType(ProjectTypeGuids.SolutionFolderGuid) - .ToList(); - - if (solutionFolderProjects.Any()) - { - var nestedProjectsSection = slnFile.Sections.GetSection( - "NestedProjects", - SlnSectionType.PreProcess); - - var solutionFoldersInUse = GetSolutionFoldersThatContainProjectsInItsHierarchy( - slnFile, - nestedProjectsSection.Properties); - - foreach (var solutionFolderProject in solutionFolderProjects) - { - if (!solutionFoldersInUse.Contains(solutionFolderProject.Id)) - { - slnFile.Projects.Remove(solutionFolderProject); - nestedProjectsSection.Properties.Remove(solutionFolderProject.Id); - } - } - - if (nestedProjectsSection.IsEmpty) - { - slnFile.Sections.Remove(nestedProjectsSection); - } - } - } - - private HashSet GetSolutionFoldersThatContainProjectsInItsHierarchy( - SlnFile slnFile, - SlnPropertySet nestedProjects) - { - var solutionFoldersInUse = new HashSet(); - - var nonSolutionFolderProjects = slnFile.Projects.GetProjectsNotOfType( - ProjectTypeGuids.SolutionFolderGuid); - - foreach (var nonSolutionFolderProject in nonSolutionFolderProjects) - { - var id = nonSolutionFolderProject.Id; - while (nestedProjects.ContainsKey(id)) - { - id = nestedProjects[id]; - solutionFoldersInUse.Add(id); - } - } - - return solutionFoldersInUse; - } } } diff --git a/src/dotnet/commands/dotnet-test/LocalizableStrings.cs b/src/dotnet/commands/dotnet-test/LocalizableStrings.cs index af567dceb..16159aa0f 100644 --- a/src/dotnet/commands/dotnet-test/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-test/LocalizableStrings.cs @@ -55,7 +55,8 @@ public const string RunSettingsArgsHelpText = @"Any extra commandline runsettings arguments that should be passed to vstest. See 'dotnet vstest --help' for available options. Example: -- RunConfiguration.ResultsDirectory=""C:\users\user\desktop\Results Directory"" MSTest.DeploymentEnabled=false"; - public const string CmdResultsDirectoryDescription = @"Test results directory will be created in specified path if not exists. + + public const string CmdResultsDirectoryDescription = @"The test results directory will be created in the specified path if it does not exist. Example: --results-directory "; } } diff --git a/src/dotnet/dotnet.csproj b/src/dotnet/dotnet.csproj old mode 100755 new mode 100644 index 133e490b4..0e706a3c5 --- a/src/dotnet/dotnet.csproj +++ b/src/dotnet/dotnet.csproj @@ -32,7 +32,7 @@ 9.0.1 - 4.0.1 + 4.3.0 2.0.0 @@ -41,26 +41,26 @@ $(CLI_SharedFrameworkVersion) - 4.0.0 + 4.3.0 - 4.0.0 + 4.3.0 - 4.1.1 + 4.3.0 - 4.1.1 + 4.3.0 - 4.0.0 + 4.3.0 Analyzers;Build;ContentFiles;Native;Runtime $(CLI_MSBuild_Version) - 1.0.1-beta-000933 + 1.1.0 diff --git a/src/tool_msbuild/tool_msbuild.csproj b/src/tool_msbuild/tool_msbuild.csproj index 40082b920..006bbeec2 100644 --- a/src/tool_msbuild/tool_msbuild.csproj +++ b/src/tool_msbuild/tool_msbuild.csproj @@ -3,11 +3,11 @@ $(CliVersionPrefix) - netcoreapp1.0 + netcoreapp1.1 - 1.0.3 + 1.1.0 $(CLI_MSBuild_Version) diff --git a/src/tool_nuget/tool_nuget.csproj b/src/tool_nuget/tool_nuget.csproj index a9163b695..163953ae9 100644 --- a/src/tool_nuget/tool_nuget.csproj +++ b/src/tool_nuget/tool_nuget.csproj @@ -3,11 +3,11 @@ $(CliVersionPrefix) - netcoreapp1.0 + netcoreapp1.1 - 1.0.3 + 1.1.0 $(CLI_NuGet_Version) diff --git a/src/tool_roslyn/tool_roslyn.csproj b/src/tool_roslyn/tool_roslyn.csproj index 3171191fe..063b591e1 100644 --- a/src/tool_roslyn/tool_roslyn.csproj +++ b/src/tool_roslyn/tool_roslyn.csproj @@ -13,7 +13,7 @@ - + @@ -38,18 +38,18 @@ AfterTargets="Publish" BeforeTargets="RemoveFilesAfterPublish"> - - + + + - - - + SectionName="%(AssetsToRemoveFromDeps.SectionName)" + AssetPath="%(AssetsToRemoveFromDeps.Identity)" /> + 2.2.0-beta4-build3444 - 1.0.1-beta-000933 + 1.1.0 diff --git a/test/EndToEnd/EndToEnd.csproj b/test/EndToEnd/EndToEnd.csproj index 3cb933826..bd792b4e3 100644 --- a/test/EndToEnd/EndToEnd.csproj +++ b/test/EndToEnd/EndToEnd.csproj @@ -41,7 +41,7 @@ 1.0.0-prerelease-00206 - 1.0.1-beta-000933 + 1.1.0 diff --git a/test/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.csproj b/test/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.csproj index ae2dace02..ee13293c5 100644 --- a/test/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.csproj +++ b/test/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.csproj @@ -31,7 +31,7 @@ 2.2.0-beta4-build1194 - 4.0.0 + 4.18.0 \ No newline at end of file diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj b/test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj index 79d12a9d0..838c38319 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj @@ -61,7 +61,7 @@ 2.2.0-beta4-build3444 - 1.0.1-beta-000933 + 1.1.0 $(CLI_MSBuild_Version) diff --git a/test/Microsoft.DotNet.Configurer.UnitTests/Microsoft.DotNet.Configurer.UnitTests.csproj b/test/Microsoft.DotNet.Configurer.UnitTests/Microsoft.DotNet.Configurer.UnitTests.csproj index d5dc9f695..34cb13f3a 100644 --- a/test/Microsoft.DotNet.Configurer.UnitTests/Microsoft.DotNet.Configurer.UnitTests.csproj +++ b/test/Microsoft.DotNet.Configurer.UnitTests/Microsoft.DotNet.Configurer.UnitTests.csproj @@ -35,7 +35,7 @@ 2.2.0-beta4-build1194 - 4.0.0 + 4.18.0 4.4.0-beta8 diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs index d15de0265..386c44d9b 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs @@ -6,6 +6,7 @@ using FluentAssertions; using Microsoft.Build.Construction; using Microsoft.DotNet.ProjectJsonMigration.Rules; using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.TestFramework; using Microsoft.DotNet.Tools.Common; using Microsoft.DotNet.Tools.Test.Utilities; using NuGet.Frameworks; @@ -39,24 +40,54 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } [Fact] - public void ItHasErrorWhenMigratingADeprecatedProjectJson() + public void ItHasWarningWhenMigratingADeprecatedProjectJson() { - var testProjectDirectory = - TestAssetsManager.CreateTestInstance("TestLibraryWithDeprecatedProjectFile", callingMethod: "z") - .Path; + var testProjectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project") + .FullName; var mockProj = ProjectRootElement.Create(); - var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(testProjectDirectory, testProjectDirectory, mockProj); + var testSettings = MigrationSettings.CreateMigrationSettingsTestHook( + testProjectDirectory, + testProjectDirectory, + mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); var report = projectMigrator.Migrate(testSettings); var projectReport = report.ProjectMigrationReports.First(); + var warningMessage = projectReport.Warnings.First(); + warningMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); + warningMessage.Should().Contain("The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead. (line: 3, file:"); + } + [Fact] + public void ItHasErrorWhenMigratingADeprecatedNamedResourceOptionProjectJson() + { + var testProjectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedNamedResource") + .CreateInstance() + .WithSourceFiles() + .Root + .FullName; + + var mockProj = ProjectRootElement.Create(); + var testSettings = MigrationSettings.CreateMigrationSettingsTestHook( + testProjectDirectory, + testProjectDirectory, + mockProj); + + var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); + var report = projectMigrator.Migrate(testSettings); + + var projectReport = report.ProjectMigrationReports.First(); var errorMessage = projectReport.Errors.First().GetFormattedErrorMessage(); errorMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); - errorMessage.Should().Contain("The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead. (line: 6, file:"); - errorMessage.Should().Contain("The 'compilationOptions' option is deprecated. Use 'buildOptions' instead. (line: 3, file:"); + errorMessage.Should().Contain("The 'namedResource' option is deprecated. Use 'embed' in 'buildOptions' instead. (line: 3, file:"); } [Fact] diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Microsoft.DotNet.ProjectJsonMigration.Tests.csproj b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Microsoft.DotNet.ProjectJsonMigration.Tests.csproj index 8ee2cad1a..09db009b0 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Microsoft.DotNet.ProjectJsonMigration.Tests.csproj +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Microsoft.DotNet.ProjectJsonMigration.Tests.csproj @@ -42,7 +42,7 @@ 2.2.0-beta4-build3444 - 4.0.0 + 4.18.0 4.4.0-beta8 diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs index 50819632c..521618155 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs @@ -193,8 +193,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } }"); - mockProj.Properties.Count(p => p.Name == "WarningsAsErrors").Should().Be(1); - mockProj.Properties.First(p => p.Name == "WarningsAsErrors").Value.Should().Be("true"); + mockProj.Properties.Count(p => p.Name == "TreatWarningsAsErrors").Should().Be(1); + mockProj.Properties.First(p => p.Name == "TreatWarningsAsErrors").Value.Should().Be("true"); mockProj = RunBuildOptionsRuleOnPj(@" { @@ -203,7 +203,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } }"); - mockProj.Properties.Count(p => p.Name == "WarningsAsErrors").Should().Be(0); + mockProj.Properties.Count(p => p.Name == "TreatWarningsAsErrors").Should().Be(0); } [Fact] @@ -420,12 +420,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } [Theory] - [InlineData("compile", "Compile")] - [InlineData("embed", "EmbeddedResource")] - [InlineData("copyToOutput", "Content")] + [InlineData("compile", "Compile", 3, "")] + [InlineData("embed", "EmbeddedResource", 3, ";rootfile.cs")] + [InlineData("copyToOutput", "Content", 2, ";rootfile.cs")] private void MigratingGroupIncludeExcludePopulatesAppropriateProjectItemElement( string group, - string itemName) + string itemName, + int expectedNumberOfCompileItems, + string expectedRootFiles) { var testDirectory = Temp.CreateDirectory().Path; WriteExtraFiles(testDirectory); @@ -445,7 +447,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var mockProj = RunBuildOptionsRuleOnPj(pj, testDirectory: testDirectory); - mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(2); + mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)) + .Should().Be(expectedNumberOfCompileItems); var defaultIncludePatterns = GetDefaultIncludePatterns(group); var defaultExcludePatterns = GetDefaultExcludePatterns(group); @@ -454,7 +457,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests { VerifyContentMetadata(item); - if (item.Include.Contains(@"src\file1.cs")) + if (string.IsNullOrEmpty(item.Include)) + { + item.Remove.Should() + .Be(@"src\**\*;rootfile.cs;src\file2.cs"); + } + else if (item.Include.Contains(@"src\file1.cs")) { item.Include.Should().Be(@"src\file1.cs;src\file2.cs"); item.Exclude.Should().Be(@"src\file2.cs"); @@ -464,12 +472,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests if (defaultIncludePatterns.Any()) { item.Include.Should() - .Be(@"root\**\*;src\**\*;rootfile.cs;" + string.Join(";", defaultIncludePatterns).Replace("/", "\\")); + .Be($@"root\**\*;src\**\*{expectedRootFiles};" + string.Join(";", defaultIncludePatterns).Replace("/", "\\")); } else { item.Include.Should() - .Be(@"root\**\*;src\**\*;rootfile.cs"); + .Be($@"root\**\*;src\**\*{expectedRootFiles}"); } if (defaultExcludePatterns.Any()) @@ -488,12 +496,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } [Theory] - [InlineData("compile", "Compile")] - [InlineData("embed", "EmbeddedResource")] - [InlineData("copyToOutput", "Content")] + [InlineData("compile", "Compile", "")] + [InlineData("embed", "EmbeddedResource", ";rootfile.cs")] + [InlineData("copyToOutput", "Content", ";rootfile.cs")] private void MigratingGroupIncludeOnlyPopulatesAppropriateProjectItemElement( string group, - string itemName) + string itemName, + string expectedRootFiles) { var testDirectory = Temp.CreateDirectory().Path; WriteExtraFiles(testDirectory); @@ -522,12 +531,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests if (defaultIncludePatterns.Any()) { item.Include.Should() - .Be(@"root\**\*;src\**\*;rootfile.cs;" + string.Join(";", defaultIncludePatterns).Replace("/", "\\")); + .Be($@"root\**\*;src\**\*{expectedRootFiles};" + string.Join(";", defaultIncludePatterns).Replace("/", "\\")); } else { item.Include.Should() - .Be(@"root\**\*;src\**\*;rootfile.cs"); + .Be($@"root\**\*;src\**\*{expectedRootFiles}"); } if (defaultExcludePatterns.Any()) @@ -579,6 +588,36 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests mockProj.Items.First(i => i.ItemType == "None").Include.Should().Be("App.config"); } + [Fact] + public void MigratingCompileIncludeWithPlainFileNamesRemovesThem() + { + var mockProj = RunBuildOptionsRuleOnPj(@" + { + ""buildOptions"": { + ""compile"": { + ""include"": [""filename1.cs"", ""filename2.cs""], + } + } + }"); + + mockProj.Items.Count(i => i.ItemType.Equals("Compile", StringComparison.Ordinal)).Should().Be(0); + } + + [Fact] + public void MigratingCompileIncludeFilesWithPlainFileNamesRemovesThem() + { + var mockProj = RunBuildOptionsRuleOnPj(@" + { + ""buildOptions"": { + ""compile"": { + ""includeFiles"": [""filename1.cs"", ""filename2.cs""], + } + } + }"); + + mockProj.Items.Count(i => i.ItemType.Equals("Compile", StringComparison.Ordinal)).Should().Be(0); + } + private static IEnumerable GetDefaultExcludePatterns(string group) { var defaultExcludePatterns = new List(group == "copyToOutput" ? diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackageDependencies.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackageDependencies.cs index 3067b567a..1bc10c03a 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackageDependencies.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackageDependencies.cs @@ -406,79 +406,116 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests i => (i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference")); } - [Theory] - [InlineData(@" + [Fact] + public void ItMigratesMicrosoftNETCoreAppMetaPackageToRuntimeFrameworkVersionProperty() + { + var mockProj = RunPackageDependenciesRuleOnPj( + @"{ ""dependencies"": { ""Microsoft.NETCore.App"" : { ""version"": ""1.1.0"", ""type"": ""build"" } } }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "Microsoft.NETCore.App" && i.ItemType == "PackageReference"); + mockProj.Properties.Should().ContainSingle(p => p.Name == "RuntimeFrameworkVersion").Which.Value.Should().Be("1.1.0"); + } + + [Fact] + public void ItMigratesMicrosoftNETCoreAppMetaPackageToRuntimeFrameworkVersionPropertyConditionedOnTFMWhenMultiTFM() + { + var mockProj = RunPackageDependenciesRuleOnPj(@" + { + ""frameworks"": { + ""netcoreapp1.0"": { + ""dependencies"": { + ""Microsoft.NETCore.App"": ""1.1.0"" + } + }, + ""netcoreapp1.1"": { + } + } + }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "Microsoft.NETCore.App" && i.ItemType == "PackageReference"); + var runtimeFrameworkVersion = mockProj.Properties.Should().ContainSingle(p => p.Name == "RuntimeFrameworkVersion").Which; + runtimeFrameworkVersion.Value.Should().Be("1.1.0"); + runtimeFrameworkVersion.Condition.Should().Contain("netcoreapp1.0"); + } + + [Fact] + public void ItMigratesMicrosoftNETCoreAppMetaPackageToRuntimeFrameworkVersionPropertyWithNoConditionedOnTFMWhenSingleTFM() + { + var mockProj = RunPackageDependenciesRuleOnPj(@" + { + ""frameworks"": { + ""netcoreapp1.0"": { + ""dependencies"": { + ""Microsoft.NETCore.App"": ""1.1.0"" + } + } + } + }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "Microsoft.NETCore.App" && i.ItemType == "PackageReference"); + var runtimeFrameworkVersion = mockProj.Properties.Should().ContainSingle(p => p.Name == "RuntimeFrameworkVersion").Which; + runtimeFrameworkVersion.Value.Should().Be("1.1.0"); + runtimeFrameworkVersion.Condition.Should().BeEmpty(); + } + + [Fact] + public void ItMigratesNETStandardLibraryMetaPackageToNetStandardImplicitPackageVersionProperty() + { + var mockProj = RunPackageDependenciesRuleOnPj( + @"{ ""dependencies"": { ""NETStandard.Library"" : { ""version"": ""1.6.0"", ""type"": ""build"" } } }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "NETStandard.Library" && i.ItemType == "PackageReference"); + mockProj.Properties.Should().ContainSingle(p => p.Name == "NetStandardImplicitPackageVersion").Which.Value.Should().Be("1.6.0"); + } + + [Fact] + public void ItMigratesNETStandardLibraryMetaPackageToNetStandardImplicitPackageVersionPropertyConditionedOnTFMWhenMultiTFM() + { + var mockProj = RunPackageDependenciesRuleOnPj(@" { ""frameworks"": { ""netstandard1.3"": { ""dependencies"": { - ""System.AppContext"": ""4.1.0"", - ""NETStandard.Library"": ""1.5.0"" + ""NETStandard.Library"": ""1.6.0"" } + }, + ""netstandard1.5"": { } } - }")] - [InlineData(@" + }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "NETStandard.Library" && i.ItemType == "PackageReference"); + var netStandardImplicitPackageVersion = + mockProj.Properties.Should().ContainSingle(p => p.Name == "NetStandardImplicitPackageVersion").Which; + netStandardImplicitPackageVersion.Value.Should().Be("1.6.0"); + netStandardImplicitPackageVersion.Condition.Should().Contain("netstandard1.3"); + } + + [Fact] + public void ItMigratesNETStandardLibraryMetaPackageToNetStandardImplicitPackageVersionPropertyWithNoConditionOnTFMWhenSingleTFM() + { + var mockProj = RunPackageDependenciesRuleOnPj(@" { ""frameworks"": { ""netstandard1.3"": { ""dependencies"": { - ""System.AppContext"": ""4.1.0"" + ""NETStandard.Library"": ""1.6.0"" } } } - }")] - public void ItMigratesLibraryAndDoesNotDoubleNetstandardRef(string pjContent) - { - var mockProj = RunPackageDependenciesRuleOnPj(pjContent); + }"); - mockProj.Items.Should().ContainSingle( - i => (i.Include == "NETStandard.Library" && i.ItemType == "PackageReference")); - } - - new private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple[] packageSpecs) - { - foreach (var packageSpec in packageSpecs) - { - var packageName = packageSpec.Item1; - var packageVersion = packageSpec.Item2; - var packageTFM = packageSpec.Item3; - - var items = mockProj.Items - .Where(i => i.ItemType == "PackageReference") - .Where(i => string.IsNullOrEmpty(packageTFM) || i.ConditionChain().Any(c => c.Contains(packageTFM))) - .Where(i => i.Include == packageName) - .Where(i => i.GetMetadataWithName("Version").Value == packageVersion && - i.GetMetadataWithName("Version").ExpressedAsAttribute); - - items.Should().HaveCount(1); - } - } - - new private void EmitsToolReferences(ProjectRootElement mockProj, params Tuple[] toolSpecs) - { - foreach (var toolSpec in toolSpecs) - { - var packageName = toolSpec.Item1; - var packageVersion = toolSpec.Item2; - - var items = mockProj.Items - .Where(i => i.ItemType == "DotNetCliToolReference") - .Where(i => i.Include == packageName) - .Where(i => i.GetMetadataWithName("Version").Value == packageVersion && - i.GetMetadataWithName("Version").ExpressedAsAttribute); - - items.Should().HaveCount(1); - } - } - - new private ProjectRootElement RunPackageDependenciesRuleOnPj(string s, string testDirectory = null) - { - testDirectory = testDirectory ?? Temp.CreateDirectory().Path; - return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[] - { - new MigratePackageDependenciesAndToolsRule() - }, s, testDirectory); + mockProj.Items.Should().NotContain( + i => i.Include == "NETStandard.Library" && i.ItemType == "PackageReference"); + var netStandardImplicitPackageVersion = + mockProj.Properties.Should().ContainSingle(p => p.Name == "NetStandardImplicitPackageVersion").Which; + netStandardImplicitPackageVersion.Value.Should().Be("1.6.0"); + netStandardImplicitPackageVersion.Condition.Should().BeEmpty(); } } } \ No newline at end of file diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackagesToTheirLTSVersions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackagesToTheirLTSVersions.cs index c8ab19dde..d2e17fe0b 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackagesToTheirLTSVersions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackagesToTheirLTSVersions.cs @@ -12,20 +12,38 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests public class GivenThatIWantToMigratePackagesToTheirLTSVersions : PackageDependenciesTestBase { [Theory] - [InlineData("Microsoft.NETCore.App", "1.0.0", "Microsoft.NETCore.App", "1.0.3")] - [InlineData("Microsoft.NETCore.App", "1.0.3-preview2", "Microsoft.NETCore.App", "1.0.3")] - [InlineData("NETStandard.Library", "1.4.0", "NETStandard.Library", "1.6.0")] - public void ItUpliftsMetaPackages( - string sourcePackageName, + [InlineData("1.0.0", "1.0.3")] + [InlineData("1.0.3-preview2", "1.0.3")] + public void ItUpliftsMicrosoftNETCoreAppMetaPackages( string sourceVersion, - string targetPackageName, string targetVersion) { - ValidatePackageMigration(sourcePackageName, sourceVersion, targetPackageName, targetVersion); + ValidateNetCoreAppMetaPackageMigration(sourceVersion, targetVersion); + } + + [Fact] + public void ItDoesNotDropMicrosoftNETCoreAppMetapackageThatDoNotHaveAMatchingVersionInTheMapping() + { + ValidateNetCoreAppMetaPackageMigration("1.2.0-*", "1.2.0-*"); + } + + [Theory] + [InlineData("1.4.0", "1.6.0")] + [InlineData("1.5.0", "1.6.0")] + public void ItUpliftsNetStandardMetaPackages( + string sourceVersion, + string targetVersion) + { + ValidateNetStandardMetaPackageMigration(sourceVersion, targetVersion); + } + + [Fact] + public void ItDoesNotDropNetStandardMetapackageThatDoNotHaveAMatchingVersionInTheMapping() + { + ValidateNetStandardMetaPackageMigration("1.6.2-*", "1.6.2-*"); } [Theory] - [InlineData("NETStandard.Library", "1.6.2-*", "NETStandard.Library", "1.6.2-*")] [InlineData("System.Text.Encodings.Web", "4.4.0-*", "System.Text.Encodings.Web", "4.4.0-*")] public void ItDoesNotDropDependenciesThatDoNotHaveAMatchingVersionInTheMapping( string sourcePackageName, @@ -236,5 +254,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests packageRef.GetMetadataWithName("Version").Value.Should().Be(targetVersion); } + + private void ValidateNetStandardMetaPackageMigration( + string sourceVersion, + string targetVersion) + { + var mockProj = RunPackageDependenciesRuleOnPj("{ \"dependencies\": { \"NETStandard.Library\" : { \"version\": \"" + sourceVersion + "\", \"type\": \"build\" } } }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "NETStandard.Library" && i.ItemType == "PackageReference"); + mockProj.Properties + .Should().ContainSingle(p => p.Name == "NetStandardImplicitPackageVersion") + .Which.Value.Should().Be(targetVersion); + } + + private void ValidateNetCoreAppMetaPackageMigration( + string sourceVersion, + string targetVersion) + { + var mockProj = RunPackageDependenciesRuleOnPj("{ \"dependencies\": { \"Microsoft.NETCore.App\" : { \"version\": \"" + sourceVersion + "\", \"type\": \"build\" } } }"); + + mockProj.Items.Should().NotContain( + i => i.Include == "Microsoft.NETCore.App" && i.ItemType == "PackageReference"); + mockProj.Properties + .Should().ContainSingle(p => p.Name == "RuntimeFrameworkVersion") + .Which.Value.Should().Be(targetVersion); + } } } \ No newline at end of file diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/PackageDependenciesTestBase.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/PackageDependenciesTestBase.cs index e0eb3a99e..9a5526646 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/PackageDependenciesTestBase.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/PackageDependenciesTestBase.cs @@ -24,7 +24,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests .Where(i => i.ItemType == "PackageReference") .Where(i => string.IsNullOrEmpty(packageTFM) || i.ConditionChain().Any(c => c.Contains(packageTFM))) .Where(i => i.Include == packageName) - .Where(i => i.GetMetadataWithName("Version").Value == packageVersion); + .Where(i => i.GetMetadataWithName("Version").Value == packageVersion && + i.GetMetadataWithName("Version").ExpressedAsAttribute); items.Should().HaveCount(1); } @@ -40,7 +41,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var items = mockProj.Items .Where(i => i.ItemType == "DotNetCliToolReference") .Where(i => i.Include == packageName) - .Where(i => i.GetMetadataWithName("Version").Value == packageVersion); + .Where(i => i.GetMetadataWithName("Version").Value == packageVersion && + i.GetMetadataWithName("Version").ExpressedAsAttribute); items.Should().HaveCount(1); } @@ -48,7 +50,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests protected ProjectRootElement RunPackageDependenciesRuleOnPj(string s, string testDirectory = null) { - testDirectory = testDirectory ?? Temp.CreateDirectory().Path; + testDirectory = + testDirectory ?? + Temp.CreateDirectory().DirectoryInfo.CreateSubdirectory("project").FullName; + return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[] { new MigratePackageDependenciesAndToolsRule() diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/TemporaryProjectFileRuleRunner.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/TemporaryProjectFileRuleRunner.cs index f574e26a6..e8b7484ed 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/TemporaryProjectFileRuleRunner.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/TemporaryProjectFileRuleRunner.cs @@ -3,7 +3,9 @@ using System.Linq; using Microsoft.Build.Construction; using Microsoft.DotNet.ProjectJsonMigration.Rules; using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.TestFramework; using NuGet.Frameworks; +using System.IO; namespace Microsoft.DotNet.ProjectJsonMigration.Tests { @@ -23,6 +25,21 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests string projectDirectory, string json) { + + var globalJson = Path.Combine(new DirectoryInfo(projectDirectory).Parent.FullName, "global.json"); + if (!File.Exists(globalJson)) + { + var file = new FileInfo(globalJson); + try + { + File.WriteAllText(file.FullName, @"{}"); + } + catch (IOException) + { + //this means there is someone else writing to the file already. So, just ignore it. + } + } + var testPj = new ProjectJsonBuilder(null) .FromStringBase(json) .SaveToDisk(projectDirectory); diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj b/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj index cea1f845f..132648280 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj @@ -20,13 +20,13 @@ 1.6.0 - 4.0.0 + 4.18.0 2.2.0-beta4-build3444 - 1.0.1-beta-000933 + 1.1.0 \ No newline at end of file diff --git a/test/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj b/test/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj index 352408c0a..9559ff788 100644 --- a/test/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj +++ b/test/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj @@ -1,41 +1,24 @@ - + netcoreapp2.0 - true Msbuild.Tests.Utilities $(PackageTargetFallback);dotnet5.4;portable-net451+win8 - - true - + - - true - - - true - + + - - 1.6.0 - - - 4.1.1 - - - 4.0.0 - - - 2.2.0-beta4-build3444 - - - $(CLI_MSBuild_Version) - + + + + + diff --git a/test/Performance/Performance.csproj b/test/Performance/Performance.csproj new file mode 100644 index 000000000..7c295a2be --- /dev/null +++ b/test/Performance/Performance.csproj @@ -0,0 +1,55 @@ + + + + + netcoreapp1.1 + true + Performance + $(PackageTargetFallback);dotnet5.4;portable-net451+win8 + + + + + + + true + + + true + + + + + + true + + + + + + 15.0.0-preview-20161024-02 + + + 2.2.0-beta4-build1194 + + + 1.1.0 + + + 4.3.0 + + + 2.2.0-beta4-build3444 + + + 1.0.0-prerelease-00206 + + + 1.0.0-alpha-build0028 + + + + + $(DefineConstants);RELEASE + + diff --git a/test/binding-redirects.Tests/binding-redirects.Tests.csproj b/test/binding-redirects.Tests/binding-redirects.Tests.csproj index d955f5fa0..6c60db847 100644 --- a/test/binding-redirects.Tests/binding-redirects.Tests.csproj +++ b/test/binding-redirects.Tests/binding-redirects.Tests.csproj @@ -17,6 +17,6 @@ - + diff --git a/test/dotnet-add-reference.Tests/dotnet-add-reference.Tests.csproj b/test/dotnet-add-reference.Tests/dotnet-add-reference.Tests.csproj index 36771d873..8f4457281 100644 --- a/test/dotnet-add-reference.Tests/dotnet-add-reference.Tests.csproj +++ b/test/dotnet-add-reference.Tests/dotnet-add-reference.Tests.csproj @@ -32,7 +32,7 @@ 2.2.0-beta4-build1194 - 4.1.1 + 4.3.0 2.2.0-beta4-build3444 diff --git a/test/dotnet-list-reference.Tests/dotnet-list-reference.Tests.csproj b/test/dotnet-list-reference.Tests/dotnet-list-reference.Tests.csproj index eeb875aca..a84af992a 100644 --- a/test/dotnet-list-reference.Tests/dotnet-list-reference.Tests.csproj +++ b/test/dotnet-list-reference.Tests/dotnet-list-reference.Tests.csproj @@ -35,7 +35,7 @@ 2.2.0-beta4-build3444 - 4.0.0 + 4.18.0 diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs new file mode 100644 index 000000000..5c6813bc8 --- /dev/null +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -0,0 +1,544 @@ +// 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.DotNet.TestFramework; +using Microsoft.DotNet.Tools.Test.Utilities; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Xml.Linq; +using Xunit; + +namespace Microsoft.DotNet.Migration.Tests +{ + public class GivenThatIWantToMigrateDeprecatedProjects : TestBase + { + [Fact] + public void WhenMigratingDeprecatedPackOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedPack") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'repository' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'projectUrl' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'licenseUrl' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'iconUrl' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'owners' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'tags' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'releaseNotes' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'requireLicenseAcceptance' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'summary' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead."); + } + + [Fact] + public void MigrateDeprecatedPack() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedPack") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("pack -c Debug") + .Should().Pass(); + + var outputDir = projectDirectory.GetDirectory("bin", "Debug"); + outputDir.Should().Exist() + .And.HaveFile("PJDeprecatedPack.1.0.0.nupkg"); + + var outputPackage = outputDir.GetFile("PJDeprecatedPack.1.0.0.nupkg"); + + var zip = ZipFile.Open(outputPackage.FullName, ZipArchiveMode.Read); + zip.Entries.Should().Contain(e => e.FullName == "PJDeprecatedPack.nuspec") + .And.Contain(e => e.FullName == "content/Content1.txt") + .And.Contain(e => e.FullName == "content/Content2.txt"); + + var manifestReader = new StreamReader( + zip.Entries.First(e => e.FullName == "PJDeprecatedPack.nuspec").Open()); + + // NOTE: Commented out those that are not migrated. + // https://microsoft.sharepoint.com/teams/netfx/corefx/_layouts/15/WopiFrame.aspx?sourcedoc=%7B0cfbc196-0645-4781-84c6-5dffabd76bee%7D&action=edit&wd=target%28Planning%2FMSBuild%20CLI%20integration%2Eone%7C41D470DD-CF44-4595-8E05-0CE238864B55%2FProject%2Ejson%20Migration%7CA553D979-EBC6-484B-A12E-036E0730864A%2F%29 + var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd()); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "projectUrl").Value + .Should().Be("http://projecturl/"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "licenseUrl").Value + .Should().Be("http://licenseurl/"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "iconUrl").Value + .Should().Be("http://iconurl/"); + //nuspecXml.Descendants().Single(e => e.Name.LocalName == "owners").Value + // .Should().Be("owner1,owner2"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "tags").Value + .Should().Be("tag1 tag2"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "releaseNotes").Value + .Should().Be("releaseNotes"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "requireLicenseAcceptance").Value + .Should().Be("true"); + //nuspecXml.Descendants().Single(e => e.Name.LocalName == "summary").Value + // .Should().Be("summary"); + + var repositoryNode = nuspecXml.Descendants().Single(e => e.Name.LocalName == "repository"); + repositoryNode.Attributes("type").Single().Value.Should().Be("git"); + repositoryNode.Attributes("url").Single().Value.Should().Be("http://url/"); + } + + [Fact] + public void WhenMigratingDeprecatedCompilationOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompilation") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compilerName' option in the root is deprecated. Use it in 'buildOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'compilationOptions' option is deprecated. Use 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedCompilation() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompilation") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + } + + [Fact] + public void WhenMigratingDeprecatedContentOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedContent") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'content' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + cmd.StdOut.Should().Contain( + "The 'contentExclude' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + cmd.StdOut.Should().Contain( + "The 'contentFiles' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + cmd.StdOut.Should().Contain( + "The 'contentBuiltIn' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + } + + [Fact] + public void MigratingDeprecatedContent() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedContent") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("publish -c Debug") + .Should().Pass(); + + var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0"); + outputDir.Should().Exist() + .And.HaveFiles(new[] + { + "ContentFile1.txt", + "ContentFile2.txt", + "ContentFileBuiltIn1.txt", + "ContentFileBuiltIn2.txt", + "IncludeThis.txt", + }); + Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis1.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis2.txt")).Should().BeFalse(); + + var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0", "publish"); + publishDir.Should().Exist() + .And.HaveFiles(new[] + { + "ContentFile1.txt", + "ContentFile2.txt", + "ContentFileBuiltIn1.txt", + "ContentFileBuiltIn2.txt", + "IncludeThis.txt", + }); + Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis1.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis2.txt")).Should().BeFalse(); + } + + [Fact] + public void WhenMigratingDeprecatedCompileOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'compileFiles' option is deprecated. Use 'compile' in 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedCompile() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + } + + [Fact] + public void WhenMigratingDeprecatedCompileBuiltInOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileBuiltIn") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compileBuiltIn' option is deprecated. Use 'compile' in 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedCompileBuiltIn() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileBuiltIn") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + //Issue: https://github.com/dotnet/cli/issues/5467 + //new DotnetCommand() + // .WithWorkingDirectory(projectDirectory) + // .Execute("build -c Debug") + // .Should().Pass(); + } + + [Fact] + public void WhenMigratingDeprecatedCompileExcludeOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileExclude") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compileExclude' option is deprecated. Use 'compile' in 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedCompileExclude() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileExclude") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + } + + [Fact] + public void WhenMigratingDeprecatedResourceOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResource") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'resource' option is deprecated. Use 'embed' in 'buildOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'resourceFiles' option is deprecated. Use 'embed' in 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedResource() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResource") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("run -c Debug"); + cmd.Should().Pass(); + cmd.StdOut.Should().Contain("3 Resources Found:"); + } + + [Fact] + public void WhenMigratingDeprecatedResourceBuiltInOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceBuiltIn") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'resourceBuiltIn' option is deprecated. Use 'embed' in 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedResourceBuiltIn() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceBuiltIn") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("run -c Debug"); + cmd.Should().Pass(); + // Issue: https://github.com/dotnet/cli/issues/5467 + //cmd.StdOut.Should().Contain("2 Resources Found:"); + } + + [Fact] + public void WhenMigratingDeprecatedResourceExcludeOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceExclude") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'resourceExclude' option is deprecated. Use 'embed' in 'buildOptions' instead."); + } + + [Fact] + public void MigratingDeprecatedResourceExclude() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceExclude") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build -c Debug") + .Should().Pass(); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("run -c Debug"); + cmd.Should().Pass(); + cmd.StdOut.Should().Contain("0 Resources Found:"); + } + } +} diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs index 095518dae..330baa6e0 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs @@ -28,6 +28,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, projectName) .CreateInstance(identifier: projectName) .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var solutionRelPath = "TestApp.sln"; @@ -58,6 +59,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithSlnAndXprojRefs") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); @@ -103,6 +105,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("NonRestoredTestProjects", "PJAppWithSlnAndOneAlreadyMigratedCsproj") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); @@ -136,6 +139,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithSlnAndOneAlreadyMigratedCsproj") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); @@ -149,12 +153,96 @@ namespace Microsoft.DotNet.Migration.Tests cmd.StdErr.Should().BeEmpty(); } + [Theory] + [InlineData("NoSolutionItemsAfterMigration.sln", false)] + [InlineData("ReadmeSolutionItemAfterMigration.sln", true)] + public void WhenMigratingAnSlnLinksReferencingItemsMovedToBackupAreRemoved( + string slnFileName, + bool solutionItemsContainsReadme) + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithSlnAndSolutionItemsToMoveToBackup") + .CreateInstance(Path.GetFileNameWithoutExtension(slnFileName)) + .WithSourceFiles() + .Root + .FullName; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute($"migrate \"{slnFileName}\"") + .Should().Pass(); + + var slnFile = SlnFile.Read(Path.Combine(projectDirectory, slnFileName)); + var solutionFolders = slnFile.Projects.Where(p => p.TypeGuid == ProjectTypeGuids.SolutionFolderGuid); + if (solutionItemsContainsReadme) + { + solutionFolders.Count().Should().Be(1); + var solutionItems = solutionFolders.Single().Sections.GetSection("SolutionItems"); + solutionItems.Should().NotBeNull(); + solutionItems.Properties.Count().Should().Be(1); + solutionItems.Properties["readme.txt"].Should().Be("readme.txt"); + } + else + { + solutionFolders.Count().Should().Be(0); + } + } + + [Fact] + public void ItMigratesSolutionInTheFolderWhenWeRunMigrationInThatFolder() + { + var projectDirectory = TestAssets + .Get("NonRestoredTestProjects", "PJAppWithSlnAndXprojRefs") + .CreateInstance() + .WithSourceFiles() + .WithEmptyGlobalJson() + .Root; + + var workingDirectory = new DirectoryInfo(Path.Combine(projectDirectory.FullName, "TestApp")); + var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); + + new DotnetCommand() + .WithWorkingDirectory(workingDirectory) + .Execute($"migrate") + .Should().Pass(); + + SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath)); + + var nonSolutionFolderProjects = slnFile.Projects + .Where(p => p.TypeGuid != ProjectTypeGuids.SolutionFolderGuid); + + nonSolutionFolderProjects.Count().Should().Be(4); + + var slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestApp").Single(); + slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid); + slnProject.FilePath.Should().Be("TestApp.csproj"); + + slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestLibrary").Single(); + slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid); + slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj")); + + slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "subdir").Single(); + slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj")); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute($"restore \"{solutionRelPath}\"") + .Should().Pass(); + + //ISSUE: https://github.com/dotnet/cli/issues/5205 + //new DotnetCommand() + // .WithWorkingDirectory(projectDirectory) + // .Execute($"build \"{solutionRelPath}\"") + // .Should().Pass(); + } + private void MigrateAndBuild(string groupName, string projectName, [CallerMemberName] string callingMethod = "", string identifier = "") { var projectDirectory = TestAssets .Get(groupName, projectName) .CreateInstance(callingMethod: callingMethod, identifier: identifier) .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index 137eba297..0559cfedb 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -35,6 +35,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance(identifier: projectName) .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; CleanBinObj(projectDirectory); @@ -69,6 +70,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance(identifier: projectName) .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; CleanBinObj(projectDirectory); @@ -88,6 +90,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; CleanBinObj(projectDirectory); @@ -116,6 +119,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("ProjectJsonConsoleTemplate") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var outputComparisonData = GetComparisonData(projectDirectory); @@ -141,6 +145,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var globalDirectory = projectDirectory.Parent; @@ -169,6 +174,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson(projectName) .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; File.Copy("NuGet.tempaspnetpatch.config", projectDirectory.GetFile("NuGet.Config").FullName); @@ -186,6 +192,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("AppWithPackageNamedAfterFolder") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var appProject = solutionDirectory @@ -210,6 +217,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("TestAppDependencyGraph") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; MigrateProject(projectDirectory.GetDirectory(dependencyProject).FullName); @@ -225,6 +233,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var globalDirectory = projectDirectory.Parent; @@ -246,6 +255,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance(identifier: projectName) .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory, projectName); @@ -271,6 +281,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance(identifier: projectName) .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory, projectName); @@ -303,6 +314,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance(identifier: projectName) .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild( @@ -333,6 +345,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("TestAppDependencyGraph") .CreateInstance(identifier: $"{projectName}.RefsTest") .WithSourceFiles() + .WithEmptyGlobalJson() .Root; MigrateProject(new [] { projectDirectory.GetDirectory(projectName).FullName }); @@ -354,6 +367,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("TestAppDependencyGraph") .CreateInstance($"{projectName}.SkipRefsTest") .WithSourceFiles() + .WithEmptyGlobalJson() .Root; MigrateProject(new [] { projectDirectory.GetDirectory(projectName).FullName, "--skip-project-references" }); @@ -370,6 +384,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("TestAppDependencyGraph") .CreateInstance(callingMethod: $"MigrateDirectory.SkipRefs.{skipRefs}") .WithSourceFiles() + .WithEmptyGlobalJson() .Root; if (skipRefs) @@ -393,6 +408,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("TestAppDependencyGraph") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var project = projectDirectory @@ -415,6 +431,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var projectDirectory = assetsDir.GetDirectory("ProjectF"); @@ -450,6 +467,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance(identifier: projectNameSuffix) .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var projectName = $"Project{projectNameSuffix}"; @@ -539,6 +557,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; CleanBinObj(projectDirectory); @@ -558,6 +577,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; CleanBinObj(projectDirectory); @@ -577,6 +597,7 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson("TestAppDependencyGraph") .CreateInstance() .WithSourceFiles() + .WithEmptyGlobalJson() .Root; var projectDirectory = solutionDirectory.GetDirectory(projectName); @@ -601,6 +622,7 @@ namespace Microsoft.DotNet.Migration.Tests .CreateInstance() .WithSourceFiles() .WithRestoreFiles() + .WithEmptyGlobalJson() .Root; var expectedCsprojPath = projectDirectory.GetFile($"{projectName}.csproj"); @@ -641,6 +663,35 @@ namespace Microsoft.DotNet.Migration.Tests .GetProjectJson(projectName) .CreateInstance(identifier: projectName) .WithSourceFiles() + .WithEmptyGlobalJson() + .Root; + + MigrateProject(projectDirectory.FullName); + Restore(projectDirectory, projectName); + BuildMSBuild(projectDirectory, projectName); + } + + [Fact] + public void ItMigratesAndBuildsAppWithExplicitInclude() + { + const string projectName = "TestAppWithExplicitInclude"; + var projectDirectory = TestAssets.Get(projectName) + .CreateInstance() + .WithSourceFiles() + .Root; + + MigrateProject(projectDirectory.FullName); + Restore(projectDirectory, projectName); + BuildMSBuild(projectDirectory, projectName); + } + + [Fact] + public void ItMigratesAndBuildsAppWithExplicitIncludeGlob() + { + const string projectName = "TestAppWithExplicitIncludeGlob"; + var projectDirectory = TestAssets.Get(projectName) + .CreateInstance() + .WithSourceFiles() .Root; MigrateProject(projectDirectory.FullName); diff --git a/test/dotnet-migrate.Tests/dotnet-migrate.Tests.csproj b/test/dotnet-migrate.Tests/dotnet-migrate.Tests.csproj index c90eddde5..41e0b0d92 100644 --- a/test/dotnet-migrate.Tests/dotnet-migrate.Tests.csproj +++ b/test/dotnet-migrate.Tests/dotnet-migrate.Tests.csproj @@ -46,7 +46,7 @@ 2.2.0-beta4-build3444 - 4.0.0 + 4.18.0 4.4.0-beta8 diff --git a/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs b/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs index 80aed33d3..00621c34a 100644 --- a/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs +++ b/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs @@ -41,7 +41,8 @@ namespace Microsoft.DotNet.New.Tests if (useNuGetConfigForAspNet) { - File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(rootPath, "NuGet.Config")); + var configFile = new FileInfo(Path.Combine(rootPath,"..","..","..","..","NuGet.tempaspnetpatch.config")); + File.Copy(configFile.FullName, Path.Combine(rootPath, "NuGet.Config")); } new TestCommand("dotnet") diff --git a/test/dotnet-new.Tests/New3/GivenThatIWantANewAppWithSpecifiedType.cs b/test/dotnet-new.Tests/New3/GivenThatIWantANewAppWithSpecifiedType.cs index b61565d83..c3599bab8 100644 --- a/test/dotnet-new.Tests/New3/GivenThatIWantANewAppWithSpecifiedType.cs +++ b/test/dotnet-new.Tests/New3/GivenThatIWantANewAppWithSpecifiedType.cs @@ -38,13 +38,10 @@ namespace Microsoft.DotNet.New3.Tests if (useNuGetConfigForAspNet) { - File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(rootPath, "NuGet.Config")); + var configFile = new FileInfo(Path.Combine(rootPath,"..","..","..","..","NuGet.tempaspnetpatch.config")); + File.Copy(configFile.FullName, Path.Combine(rootPath, "NuGet.Config")); } - string globalJsonPath = Path.Combine(rootPath, "global.json"); - Assert.True(File.Exists(globalJsonPath)); - Assert.Contains(Product.Version, File.ReadAllText(globalJsonPath)); - new TestCommand("dotnet") .WithWorkingDirectory(rootPath) .Execute($"restore") diff --git a/test/dotnet-new.Tests/NewCommandTests.cs b/test/dotnet-new.Tests/NewCommandTests.cs new file mode 100644 index 000000000..2ab41b0a6 --- /dev/null +++ b/test/dotnet-new.Tests/NewCommandTests.cs @@ -0,0 +1,26 @@ +// 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.DotNet.Tools.Test.Utilities; +using System; +using System.Linq; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.DotNet.New.Tests +{ + public class NewCommandTests + { + [Fact] + public void WhenSwitchIsSkippedThenItPrintsError() + { + var cmd = new DotnetCommand().Execute("new Web1.1"); + + cmd.ExitCode.Should().NotBe(0); + + cmd.StdErr.Should().Be("Unrecognized command or argument 'Web1.1'"); + cmd.StdOut.Should().Be("Specify --help for a list of available options and commands."); + } + } +} diff --git a/test/dotnet-pack.Tests/dotnet-pack.Tests.csproj b/test/dotnet-pack.Tests/dotnet-pack.Tests.csproj index 053e79fc6..b3323a1c1 100644 --- a/test/dotnet-pack.Tests/dotnet-pack.Tests.csproj +++ b/test/dotnet-pack.Tests/dotnet-pack.Tests.csproj @@ -35,7 +35,7 @@ 2.2.0-beta4-build1194 - 4.0.1 + 4.3.0 2.2.0-beta4-build3444 diff --git a/test/dotnet-remove-reference.Tests/dotnet-remove-reference.Tests.csproj b/test/dotnet-remove-reference.Tests/dotnet-remove-reference.Tests.csproj index ecace2003..5b9b4e266 100644 --- a/test/dotnet-remove-reference.Tests/dotnet-remove-reference.Tests.csproj +++ b/test/dotnet-remove-reference.Tests/dotnet-remove-reference.Tests.csproj @@ -38,7 +38,7 @@ $(CLI_MSBuild_Version) - 4.0.0 + 4.18.0 diff --git a/test/dotnet-restore.Tests/dotnet-restore.Tests.csproj b/test/dotnet-restore.Tests/dotnet-restore.Tests.csproj index 5df9c44a1..efc26fc0c 100644 --- a/test/dotnet-restore.Tests/dotnet-restore.Tests.csproj +++ b/test/dotnet-restore.Tests/dotnet-restore.Tests.csproj @@ -47,10 +47,10 @@ 2.2.0-beta4-build3444 - 1.0.1-beta-000933 + 1.1.0 - 4.0.0 + 4.18.0 diff --git a/test/dotnet.Tests/GivenThatTheUserIsRunningDotNetForTheFirstTime.cs b/test/dotnet.Tests/GivenThatTheUserIsRunningDotNetForTheFirstTime.cs index 7e6ee264a..4a4d90a63 100644 --- a/test/dotnet.Tests/GivenThatTheUserIsRunningDotNetForTheFirstTime.cs +++ b/test/dotnet.Tests/GivenThatTheUserIsRunningDotNetForTheFirstTime.cs @@ -82,7 +82,7 @@ A command is running to initially populate your local package cache, to improve { _nugetCacheFolder .Should() - .HaveFile($"{GetDotnetVersion()}.dotnetSentinel"); + .HaveFile($"{GetDotnetVersion()}.dotnetSentinel"); } [Fact] diff --git a/test/dotnet.Tests/PackagedCommandTests.cs b/test/dotnet.Tests/PackagedCommandTests.cs index b08cc2eeb..d1f8b0c93 100644 --- a/test/dotnet.Tests/PackagedCommandTests.cs +++ b/test/dotnet.Tests/PackagedCommandTests.cs @@ -267,7 +267,6 @@ namespace Microsoft.DotNet.Tests new BuildCommand() .WithWorkingDirectory(testInstance.Root) - .WithFramework(NuGet.Frameworks.FrameworkConstants.CommonFrameworks.NetCoreApp10) .Execute() .Should().Pass(); diff --git a/test/dotnet.Tests/dotnet.Tests.csproj b/test/dotnet.Tests/dotnet.Tests.csproj index 7a6844cf4..8caf0bf79 100644 --- a/test/dotnet.Tests/dotnet.Tests.csproj +++ b/test/dotnet.Tests/dotnet.Tests.csproj @@ -61,7 +61,7 @@ 1.0.0-prerelease-00206 - 1.0.1-beta-000933 + 1.1.0 diff --git a/tools/Archiver/Archiver.csproj b/tools/Archiver/Archiver.csproj index 0eb984676..d4ece9545 100644 --- a/tools/Archiver/Archiver.csproj +++ b/tools/Archiver/Archiver.csproj @@ -15,6 +15,5 @@ - \ No newline at end of file