From f863630fd8c09d20a211c77acb47d75de9bfb3b2 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 26 Oct 2016 10:10:48 -0700 Subject: [PATCH 1/8] Adding a rule that turns off assembly info generation for attributes already defined when migrating. --- .../AppWithAssemblyInfo/Program.cs | 14 ++ .../Properties/AssemblyInfo.cs | 27 ++++ .../AppWithAssemblyInfo/project.json | 19 +++ .../Rules/MigrateAssemblyInfoRule.cs | 146 ++++++++++++++++++ .../project.json | 3 +- .../GivenThatIWantToMigrateAssemblyInfo.cs | 128 +++++++++++++++ 6 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 TestAssets/TestProjects/AppWithAssemblyInfo/Program.cs create mode 100644 TestAssets/TestProjects/AppWithAssemblyInfo/Properties/AssemblyInfo.cs create mode 100644 TestAssets/TestProjects/AppWithAssemblyInfo/project.json create mode 100644 src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs create mode 100644 test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs diff --git a/TestAssets/TestProjects/AppWithAssemblyInfo/Program.cs b/TestAssets/TestProjects/AppWithAssemblyInfo/Program.cs new file mode 100644 index 000000000..323c37abb --- /dev/null +++ b/TestAssets/TestProjects/AppWithAssemblyInfo/Program.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public class Program + { + public static void Main(string[] args) + { + } + } +} diff --git a/TestAssets/TestProjects/AppWithAssemblyInfo/Properties/AssemblyInfo.cs b/TestAssets/TestProjects/AppWithAssemblyInfo/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..553ebc670 --- /dev/null +++ b/TestAssets/TestProjects/AppWithAssemblyInfo/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleApp1")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyFileVersion("")] +[assembly: AssemblyInformationalVersion("")] +[assembly: AssemblyTitle("")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: NeutralResourcesLanguage("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ab699746-eb43-467d-ab46-6095b4de9722")] diff --git a/TestAssets/TestProjects/AppWithAssemblyInfo/project.json b/TestAssets/TestProjects/AppWithAssemblyInfo/project.json new file mode 100644 index 000000000..9016d1324 --- /dev/null +++ b/TestAssets/TestProjects/AppWithAssemblyInfo/project.json @@ -0,0 +1,19 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true + }, + + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs new file mode 100644 index 000000000..22edd478d --- /dev/null +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs @@ -0,0 +1,146 @@ +// 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.IO; +using System.Linq; +using Microsoft.Build.Construction; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.DotNet.ProjectJsonMigration; +using Microsoft.DotNet.ProjectJsonMigration.Transforms; +using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.ProjectModel.Files; +using Microsoft.DotNet.Tools.Common; +using NuGet.Frameworks; + +namespace Microsoft.DotNet.ProjectJsonMigration.Rules +{ + public class MigrateAssemblyInfoRule : IMigrationRule + { + private static IReadOnlyDictionary> Suppresses { get; } = new Dictionary> + { + { "csc", new string[] {"CS1701", "CS1702", "CS1705" } } + }; + + private static IReadOnlyList GenerateAssemblyInfoWhitelist = new List() + { + "AssemblyCompany", + "AssemblyConfiguration", + "AssemblyCopyright", + "AssemblyDescription", + "AssemblyFileVersion", + "AssemblyInformationalVersion", + "AssemblyProduct", + "AssemblyTitle", + "AssemblyVersion", + "NeutralResourcesLanguage" + }; + + private readonly ITransformApplicator _transformApplicator; + + public MigrateAssemblyInfoRule(ITransformApplicator transformApplicator = null) + { + _transformApplicator = transformApplicator ?? new TransformApplicator(); + } + + public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) + { + var projectContext = migrationRuleInputs.DefaultProjectContext; + var compilationOptions = ResolveCompilationOptions(projectContext, "Debug"); + var sources = GetCompilationSources(projectContext, compilationOptions); + var assemblyInfoList = GetAssemblyInfo(sources); + + foreach(var assemblyInfo in assemblyInfoList) + { + var propertyTransform = new AddPropertyTransform( + $"Generate{assemblyInfo}Attribute", + a => "false", + a => true); + + _transformApplicator.Execute( + propertyTransform.Transform(assemblyInfo), + migrationRuleInputs.CommonPropertyGroup, + true); + } + } + + public IEnumerable GetCompilationSources(ProjectContext project, CommonCompilerOptions compilerOptions) + { + if (compilerOptions.CompileInclude == null) + { + return project.ProjectFile.Files.SourceFiles; + } + + var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); + + return includeFiles.Select(f => f.SourcePath); + } + + public List GetAssemblyInfo(IEnumerable sourceFiles) + { + var assemblyInfoList = new List(); + foreach (var sourceFile in sourceFiles) + { + var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile)); + var root = tree.GetRoot(); + + // assembly attributes can be only on first level + foreach (var attributeListSyntax in root.ChildNodes().OfType()) + { + if (attributeListSyntax.Target.Identifier.Kind() == SyntaxKind.AssemblyKeyword) + { + foreach (var attributeSyntax in attributeListSyntax + .Attributes + .Select(a => a.Name.ToString()) + .Where(a => GenerateAssemblyInfoWhitelist.Contains(a))) + { + assemblyInfoList.Add(attributeSyntax); + } + } + } + } + + return assemblyInfoList; + } + + // used in incremental compilation for the key file + private CommonCompilerOptions ResolveCompilationOptions(ProjectContext context, string configuration) + { + var compilerOptions = GetLanguageSpecificCompilerOptions(context, context.TargetFramework, configuration); + + // Path to strong naming key in environment variable overrides path in project.json + var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile); + + if (!string.IsNullOrWhiteSpace(environmentKeyFile)) + { + compilerOptions.KeyFile = environmentKeyFile; + } + else if (!string.IsNullOrWhiteSpace(compilerOptions.KeyFile)) + { + // Resolve full path to key file + compilerOptions.KeyFile = + Path.GetFullPath(Path.Combine(context.ProjectFile.ProjectDirectory, compilerOptions.KeyFile)); + } + return compilerOptions; + } + + private CommonCompilerOptions GetLanguageSpecificCompilerOptions( + ProjectContext context, + NuGetFramework framework, + string configurationName) + { + var baseOption = context.ProjectFile.GetCompilerOptions(framework, configurationName); + + IReadOnlyList defaultSuppresses; + var compilerName = baseOption.CompilerName ?? "csc"; + if (Suppresses.TryGetValue(compilerName, out defaultSuppresses)) + { + baseOption.SuppressWarnings = (baseOption.SuppressWarnings ?? Enumerable.Empty()).Concat(defaultSuppresses).Distinct(); + } + + return baseOption; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/project.json b/src/Microsoft.DotNet.ProjectJsonMigration/project.json index 34cd34fd4..d2bb6c028 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/project.json +++ b/src/Microsoft.DotNet.ProjectJsonMigration/project.json @@ -17,7 +17,8 @@ "Microsoft.DotNet.ProjectModel": { "target": "project" }, - "Microsoft.Build": "15.1.319-preview5" + "Microsoft.Build": "15.1.319-preview5", + "Microsoft.CodeAnalysis.CSharp": "2.0.0-beta6-60922-08" }, "frameworks": { "netcoreapp1.0": { } diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs new file mode 100644 index 000000000..8502cc16e --- /dev/null +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs @@ -0,0 +1,128 @@ +// 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 Microsoft.Build.Construction; +using Microsoft.DotNet.ProjectJsonMigration; +using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Tools.Test.Utilities; +using NuGet.Frameworks; +using System.Linq; +using Xunit; +using FluentAssertions; +using Microsoft.DotNet.ProjectJsonMigration.Rules; + +namespace Microsoft.DotNet.ProjectJsonMigration.Tests +{ + public class GivenThatIWantToMigrateAssemblyInfo : TestBase + { + private ProjectRootElement _mockProject; + + public GivenThatIWantToMigrateAssemblyInfo() + { + var projectDirectory = + TestAssetsManager.CreateTestInstance("AppWithAssemblyInfo", callingMethod: "i").Path; + var projectContext = + ProjectContext.Create(projectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10); + _mockProject = ProjectRootElement.Create(); + var testSettings = new MigrationSettings(projectDirectory, projectDirectory, "1.0.0", _mockProject, null); + var testInputs = new MigrationRuleInputs( + new[] {projectContext}, + _mockProject, + _mockProject.AddItemGroup(), + _mockProject.AddPropertyGroup()); + + new MigrateAssemblyInfoRule().Apply(testSettings, testInputs); + } + + [Fact] + public void ItSetsGenerateAssemblyCompanyAttributeToFalseWhenAssemblyCompanyExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyCompanyAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyConfigurationAttributeToFalseWhenAssemblyConfigurationExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyConfigurationAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyCopyrightAttributeToFalseWhenAssemblyCopyrightExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyCopyrightAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyDescriptionAttributeToFalseWhenAssemblyDescriptionExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyDescriptionAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyFileVersionAttributeToFalseWhenAssemblyFileVersionExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyFileVersionAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyInformationalVersionAttributeToFalseWhenAssemblyInformationalVersionExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyInformationalVersionAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyProductAttributeToFalseWhenAssemblyProductExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyProductAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyTitleAttributeToFalseWhenAssemblyTitleExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyTitleAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateAssemblyVersionAttributeToFalseWhenAssemblyVersionExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyVersionAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + + [Fact] + public void ItSetsGenerateNeutralResourcesLanguageAttributeToFalseWhenNeutralResourcesLanguageExists() + { + var generateAssemblyAttributes = + _mockProject.Properties.Where(p => p.Name.Equals("GenerateNeutralResourcesLanguageAttribute", StringComparison.Ordinal)); + generateAssemblyAttributes.Count().Should().Be(1); + generateAssemblyAttributes.First().Value.Should().Be("false"); + } + } +} \ No newline at end of file From 017fe529c16595f8cc0470f9205cc3af71412c38 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 26 Oct 2016 15:13:39 -0700 Subject: [PATCH 2/8] Adding a E2E test for migrating an app with AssemblyInfo. --- test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index b6496d19e..2fdb8a094 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -21,6 +21,7 @@ namespace Microsoft.DotNet.Migration.Tests [Theory] [InlineData("TestAppWithRuntimeOptions")] [InlineData("TestAppWithContents")] + [InlineData("AppWithAssemblyInfo")] public void It_migrates_apps(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i") From 68afda8e4d13f22724a8e7ee19c60d5997f8b8a5 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Wed, 26 Oct 2016 22:23:40 +0000 Subject: [PATCH 3/8] Handle "runtimes" section (#4503) * Migrate "runtimes" section as a RuntimeIdentifiers property in the resulting csproj file. Also do not call restore3 from publish3 anymore. * Fix up the publish3 tests to call restore3 first and the csproj files to have RuntimeIdentifiers --- .../MSBuildTestApp/MSBuildTestApp.csproj | 1 + .../DefaultMigrationRuleSet.cs | 1 + .../Rules/MigrateRuntimesRule.cs | 35 ++++++++ src/Microsoft.DotNet.ProjectModel/Project.cs | 2 + .../ProjectReader.cs | 18 +++++ .../dotnet-publish3/Publish3Command.cs | 20 ----- .../Rules/GivenThatIWantToMigrateRuntimes.cs | 79 +++++++++++++++++++ .../Commands/Publish3Command.cs | 4 +- .../GivenThatIWantToMigrateTestApps.cs | 34 +++++++- .../GivenDotnetPublish3PublishesProjects.cs | 26 +++--- 10 files changed, 183 insertions(+), 37 deletions(-) create mode 100644 src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs create mode 100644 test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateRuntimes.cs diff --git a/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj b/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj index 00f51ebb3..ec55505c2 100644 --- a/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj +++ b/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj @@ -4,6 +4,7 @@ Exe netcoreapp1.0 + 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/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs b/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs index f12f419c7..16fdb6b40 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs @@ -16,6 +16,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration new MigrateJsonPropertiesRule(), new MigratePackOptionsRule(), new MigrateRuntimeOptionsRule(), + new MigrateRuntimesRule(), new MigratePublishOptionsRule(), new MigrateProjectDependenciesRule(), new MigratePackageDependenciesAndToolsRule(), diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs new file mode 100644 index 000000000..c0ddb8c46 --- /dev/null +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs @@ -0,0 +1,35 @@ +// 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.DotNet.ProjectJsonMigration.Transforms; + +namespace Microsoft.DotNet.ProjectJsonMigration.Rules +{ + public class MigrateRuntimesRule : IMigrationRule + { + AddPropertyTransform> RuntimeIdentifiersTransform => + new AddPropertyTransform>( + "RuntimeIdentifiers", + l => String.Join(";", l), + l => l.Count > 0); + + private readonly ITransformApplicator _transformApplicator; + + public MigrateRuntimesRule(ITransformApplicator transformApplicator = null) + { + _transformApplicator = transformApplicator ?? new TransformApplicator(); + } + + public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) + { + var propertyGroup = migrationRuleInputs.CommonPropertyGroup; + + _transformApplicator.Execute( + RuntimeIdentifiersTransform.Transform(migrationRuleInputs.DefaultProjectContext.ProjectFile.Runtimes), + propertyGroup, + mergeExisting: true); + } + } +} diff --git a/src/Microsoft.DotNet.ProjectModel/Project.cs b/src/Microsoft.DotNet.ProjectModel/Project.cs index c174a1806..7a42b0748 100644 --- a/src/Microsoft.DotNet.ProjectModel/Project.cs +++ b/src/Microsoft.DotNet.ProjectModel/Project.cs @@ -71,6 +71,8 @@ namespace Microsoft.DotNet.ProjectModel public RuntimeOptions RuntimeOptions { get; set; } + public IList Runtimes { get; set; } + public IDictionary Commands { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); public IDictionary> Scripts { get; } = new Dictionary>(StringComparer.OrdinalIgnoreCase); diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs index e65b89265..88534e11b 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs @@ -159,6 +159,7 @@ namespace Microsoft.DotNet.ProjectModel project.Dependencies = new List(); project.Tools = new List(); + project.Runtimes = new List(); // Project files project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath); @@ -224,6 +225,8 @@ namespace Microsoft.DotNet.ProjectModel "tools", isGacOrFrameworkReference: false); + PopulateRuntimes(project.Runtimes, rawProject); + JToken runtimeOptionsToken; if (rawProject.TryGetValue("runtimeOptions", out runtimeOptionsToken)) { @@ -370,6 +373,21 @@ namespace Microsoft.DotNet.ProjectModel } } + private static void PopulateRuntimes(IList results, JObject settings) + { + var runtimes = settings.Value("runtimes") as JObject; + if (runtimes != null) + { + foreach (var runtime in runtimes) + { + if (!string.IsNullOrEmpty(runtime.Key)) + { + results.Add(runtime.Key); + } + } + } + } + private void BuildTargetFrameworksAndConfigurations(Project project, JObject projectJsonObject) { // Get the shared compilationOptions diff --git a/src/dotnet/commands/dotnet-publish3/Publish3Command.cs b/src/dotnet/commands/dotnet-publish3/Publish3Command.cs index c6a4cf5f5..79366dab7 100644 --- a/src/dotnet/commands/dotnet-publish3/Publish3Command.cs +++ b/src/dotnet/commands/dotnet-publish3/Publish3Command.cs @@ -25,12 +25,6 @@ namespace Microsoft.DotNet.Tools.Publish3 public int Execute() { - int restoreResult = EnsureRestored(); - if (restoreResult != 0) - { - throw new GracefulException("Restore failed. Please fix the errors and try publishing again."); - } - List msbuildArgs = new List(); if (!string.IsNullOrEmpty(ProjectPath)) @@ -70,19 +64,5 @@ namespace Microsoft.DotNet.Tools.Publish3 return new MSBuildForwardingApp(msbuildArgs).Execute(); } - /// - /// Ensures that the project has been restored for the specified runtime. - /// - private int EnsureRestored() - { - int result = 0; - - if (!string.IsNullOrEmpty(Runtime)) - { - result = Restore3Command.Run(new[] { $"/p:RuntimeIdentifiers={Runtime}" }); - } - - return result; - } } } diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateRuntimes.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateRuntimes.cs new file mode 100644 index 000000000..a92c91754 --- /dev/null +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateRuntimes.cs @@ -0,0 +1,79 @@ +using Microsoft.Build.Construction; +using Microsoft.DotNet.ProjectJsonMigration; +using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Tools.Test.Utilities; +using NuGet.Frameworks; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Xunit; +using FluentAssertions; +using Microsoft.DotNet.ProjectJsonMigration.Rules; + +namespace Microsoft.DotNet.ProjectJsonMigration.Tests +{ + public class GivenThatIWantToMigrateRuntimes : TestBase + { + [Fact] + public void It_migrates_runtimes() + { + var projectJson = @" + { + ""runtimes"": { + ""win7-x64"": { }, + ""win7-x86"": { }, + ""osx.10.10-x64"": { } + } + } + "; + + var testDirectory = Temp.CreateDirectory().Path; + var migratedProj = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[] + { + new MigrateRuntimesRule() + }, projectJson, testDirectory); + + migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(1); + migratedProj.Properties.First(p => p.Name == "RuntimeIdentifiers").Value + .Should().Be("win7-x64;win7-x86;osx.10.10-x64"); + } + + [Fact] + public void It_has_an_empty_runtime_node_to_migrate() + { + var projectJson = @" + { + ""runtimes"": { + } + } + "; + + var testDirectory = Temp.CreateDirectory().Path; + var migratedProj = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[] + { + new MigrateRuntimesRule() + }, projectJson, testDirectory); + + migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0); + } + + [Fact] + public void It_has_no_runtimes_to_migrate() + { + var projectJson = @" + { + } + "; + + var testDirectory = Temp.CreateDirectory().Path; + var migratedProj = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[] + { + new MigrateRuntimesRule() + }, projectJson, testDirectory); + + migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0); + } + } +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Publish3Command.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Publish3Command.cs index 7b0f56d06..f3a10d449 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Publish3Command.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Publish3Command.cs @@ -29,13 +29,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public override CommandResult Execute(string args = "") { - args = $"publish3 {args} {BuildArgs()}"; + args = $"publish3 {BuildArgs()} {args} "; return base.Execute(args); } public override CommandResult ExecuteWithCapturedOutput(string args = "") { - args = $"publish3 {args} {BuildArgs()}"; + args = $"publish3 {BuildArgs()} {args}"; return base.ExecuteWithCapturedOutput(args); } diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index b6496d19e..3a8514327 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -10,8 +10,8 @@ using System.IO; using Microsoft.DotNet.Tools.Migrate; using Build3Command = Microsoft.DotNet.Tools.Test.Utilities.Build3Command; using BuildCommand = Microsoft.DotNet.Tools.Test.Utilities.BuildCommand; +using Publish3Command = Microsoft.DotNet.Tools.Test.Utilities.Publish3Command; using System.Runtime.Loader; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Microsoft.DotNet.Migration.Tests @@ -346,6 +346,19 @@ namespace Microsoft.DotNet.Migration.Tests result.StdErr.Should().Contain("Migration failed."); } + [Fact] + public void It_migrates_and_publishes_projects_with_runtimes() + { + var projectName = "TestAppSimple"; + var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i") + .WithLockFiles() + .Path; + + CleanBinObj(projectDirectory); + BuildProjectJsonMigrateBuildMSBuild(projectDirectory, projectName); + PublishMSBuild(projectDirectory, projectName, "win7-x64"); + } + [WindowsOnlyTheory] [InlineData("DesktopTestProjects", "AutoAddDesktopReferencesDuringMigrate", true)] [InlineData("TestProjects", "TestAppSimple", false)] @@ -558,6 +571,25 @@ namespace Microsoft.DotNet.Migration.Tests return result.StdOut; } + private string PublishMSBuild(string projectDirectory, string projectName, string runtime, string configuration = "Debug") + { + if (projectName != null) + { + projectName = projectName + ".csproj"; + } + + DeleteXproj(projectDirectory); + + var result = new Publish3Command() + .WithRuntime(runtime) + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput($"{projectName} /p:Configuration={configuration}"); + + result.Should().Pass(); + + return result.StdOut; + } + private void DeleteXproj(string projectDirectory) { var xprojFiles = Directory.EnumerateFiles(projectDirectory, "*.xproj"); diff --git a/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs b/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs index 55e15c862..094d42f9a 100644 --- a/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs +++ b/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs @@ -25,24 +25,20 @@ namespace Microsoft.DotNet.Cli.Publish3.Tests new Restore3Command() .WithWorkingDirectory(testProjectDirectory) .Execute() - .Should() - .Pass(); + .Should().Pass(); new Publish3Command() .WithWorkingDirectory(testProjectDirectory) .Execute("--framework netcoreapp1.0") - .Should() - .Pass(); + .Should().Pass(); var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug"; var outputDll = Path.Combine(testProjectDirectory, "bin", configuration, "netcoreapp1.0", "publish", $"{testAppName}.dll"); new TestCommand("dotnet") .ExecuteWithCapturedOutput(outputDll) - .Should() - .Pass() - .And - .HaveStdOutContaining("Hello World"); + .Should().Pass() + .And.HaveStdOutContaining("Hello World"); } [Fact] @@ -55,23 +51,25 @@ namespace Microsoft.DotNet.Cli.Publish3.Tests var testProjectDirectory = testInstance.TestRoot; var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); + new Restore3Command() + .WithWorkingDirectory(testProjectDirectory) + .Execute() + .Should().Pass(); + new Publish3Command() .WithFramework("netcoreapp1.0") .WithRuntime(rid) .WithWorkingDirectory(testProjectDirectory) .Execute() - .Should() - .Pass(); + .Should().Pass(); var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug"; var outputProgram = Path.Combine(testProjectDirectory, "bin", configuration, "netcoreapp1.0", rid, "publish", $"{testAppName}{Constants.ExeSuffix}"); new TestCommand(outputProgram) .ExecuteWithCapturedOutput() - .Should() - .Pass() - .And - .HaveStdOutContaining("Hello World"); + .Should().Pass() + .And.HaveStdOutContaining("Hello World"); } } } From 43bf57531e32acb189ed56ba0c432427f651c76f Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 26 Oct 2016 15:49:00 -0700 Subject: [PATCH 4/8] Adding the MigrateAssembyInfo rule to the DefaultMigrationRuleSet. --- .../DefaultMigrationRuleSet.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs b/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs index f12f419c7..2f5a01515 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs @@ -21,6 +21,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration new MigratePackageDependenciesAndToolsRule(), new MigrateConfigurationsRule(), new MigrateScriptsRule(), + new MigrateAssemblyInfoRule(), new RemoveDefaultsFromProjectRule(), new CleanOutputProjectRule(), new SaveOutputProjectRule() From 95f49e6636954be81e0cd0c6a5baa7d2c12ef947 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 27 Oct 2016 10:56:54 -0500 Subject: [PATCH 5/8] Fix build scripts to pass architecture into the bootstrapper. --- run-build.ps1 | 2 +- run-build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/run-build.ps1 b/run-build.ps1 index 43a56d4d2..2a425e6c7 100644 --- a/run-build.ps1 +++ b/run-build.ps1 @@ -78,7 +78,7 @@ if ((Test-Path $bootStrapperPath) -eq 0) } # now execute it -& $bootStrapperPath -RepositoryRoot (Get-Location) -ToolsLocalPath $toolsLocalPath -CliLocalPath $env:DOTNET_INSTALL_DIR | Out-File (Join-Path (Get-Location) "bootstrap.log") +& $bootStrapperPath -RepositoryRoot (Get-Location) -ToolsLocalPath $toolsLocalPath -CliLocalPath $env:DOTNET_INSTALL_DIR -Architecture $Architecture | Out-File (Join-Path (Get-Location) "bootstrap.log") if ($LastExitCode -ne 0) { Write-Output "Boot-strapping failed with exit code $LastExitCode, see bootstrap.log for more information." diff --git a/run-build.sh b/run-build.sh index f02ab20e4..37504a6bb 100755 --- a/run-build.sh +++ b/run-build.sh @@ -143,7 +143,7 @@ if [ ! -f $bootStrapperPath ]; then chmod u+x $bootStrapperPath fi -$bootStrapperPath --repositoryRoot "$REPOROOT" --toolsLocalPath "$toolsLocalPath" --cliInstallPath $DOTNET_INSTALL_DIR > bootstrap.log +$bootStrapperPath --repositoryRoot "$REPOROOT" --toolsLocalPath "$toolsLocalPath" --cliInstallPath $DOTNET_INSTALL_DIR --architecture $ARCHITECTURE > bootstrap.log if [ $? != 0 ]; then echo "run-build: Error: Boot-strapping failed with exit code $?, see bootstrap.log for more information." >&2 From 550b75dd5374c7628812ee0d270f4ad69497283b Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Thu, 27 Oct 2016 16:02:05 -0700 Subject: [PATCH 6/8] [Build kick-off] Change underline to match length --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0efb18400..b840e96a5 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,6 @@ Questions & Comments For any and all feedback, please use the Issues on this repository. License --------------------- +------- By downloading the .zip you are agreeing to the terms in the project [EULA](https://aka.ms/dotnet-core-eula). From 6fcbefa4f7a0016a68d3cda52779298a5cd20837 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Thu, 27 Oct 2016 18:46:43 -0700 Subject: [PATCH 7/8] [WIP] Removes *3 verbs, making msbuild the driver (#4456) Removes *3 verbs, making msbuild the driver --- .cliversion | 2 +- .gitignore | 3 + .../project.json | 33 - .../.noautobuild | 0 .../AppWithProjTool2Fx/App.csproj | 47 + .../AppWithProjTool2Fx/NuGet.Config | 6 + .../Program.cs | 0 .../.noautobuild | 0 .../LibWithProjTool2Fx/Lib.csproj | 47 + .../LibWithProjTool2Fx/NuGet.Config | 6 + .../Program.cs | 0 .../project.json | 31 - ...ectWithUnresolvedPlatformDependency.csproj | 30 + .../project.json | 17 - .../dotnet-dependency-tool-invoker/Program.cs | 54 +- .../project.json | 6 - .../AppWithDepOnToolWithOutputName.csproj | 34 + .../NuGet.Config | 6 + .../project.json | 21 - .../AppWithDirectAndToolDep.csproj | 37 + .../AppWithDirectAndToolDep/NuGet.Config | 6 + .../AppWithDirectAndToolDep/project.json | 35 - .../AppWithDirectDep/AppWithDirectDep.csproj | 39 + .../AppWithDirectDep/NuGet.Config | 6 + .../AppWithDirectDep/project.json | 29 - .../AppWithDirectDepAndTypeBuild/NuGet.Config | 6 + .../AppWithDirectDepWithOutputName.csproj | 37 + .../NuGet.Config | 8 + .../project.json | 27 - ...ldAppWithMultipleFrameworksAndTools.csproj | 37 + .../AppWithMultipleFxAndTools/NuGet.Config | 6 + .../Program.cs | 0 .../AppWithToolDependency.csproj | 34 + .../DependencyContextFromTool.csproj | 42 + .../DependencyContextFromTool/NuGet.Config | 6 + .../DependencyContextFromTool/project.json | 28 - .../MyLibrary.csproj | 28 + .../project.json | 11 - .../TestProjects/PJTestAppSimple/Program.cs | 12 + .../project.json | 10 +- .../.noautobuild | 0 .../PJTestLibraryWithConfiguration/Helper.cs | 24 + .../project.json | 4 +- .../SingleTargetApp/SingleTargetApp.csproj | 29 + .../SingleTargetApp/project.json | 15 - .../SingleTargetP0/SingleTargetP0.csproj | 32 + .../SingleTargetP0/project.json | 18 - .../SingleTargetP1/SingleTargetP1.csproj | 31 + .../SingleTargetP1/project.json | 15 - .../SingleTargetP2/SingleTargetP2.csproj | 28 + .../SingleTargetP2/project.json | 12 - .../TwoTargetApp/TwoTargetApp.csproj | 42 + .../TwoTargetApp/project.json | 36 - .../TwoTargetP0/TwoTargetP0.csproj | 45 + .../TwoTargetGraph/TwoTargetP0/project.json | 40 - .../TwoTargetP1/TwoTargetP1.csproj | 41 + .../TwoTargetGraph/TwoTargetP1/project.json | 23 - .../TwoTargetP2/TwoTargetP2.csproj | 38 + .../TwoTargetGraph/TwoTargetP2/project.json | 19 - .../TwoTargetLargeP0/TwoTargetLargeP0.csproj | 45 + .../TwoTargetLargeP0/project.json | 40 - .../TwoTargetLargeP1/TwoTargetLargeP1.csproj | 42 + .../TwoTargetLargeP1/project.json | 26 - .../TwoTargetLargeP2/TwoTargetLargeP2.csproj | 42 + .../TwoTargetLargeP2/project.json | 26 - .../TwoTargetLargeP3/TwoTargetLargeP3.csproj | 41 + .../TwoTargetLargeP3/project.json | 23 - .../TwoTargetLargeP4/TwoTargetLargeP4.csproj | 42 + .../TwoTargetLargeP4/project.json | 26 - .../TwoTargetLargeP5/TwoTargetLargeP5.csproj | 38 + .../TwoTargetLargeP5/project.json | 19 - .../TwoTargetLargeP6/TwoTargetLargeP6.csproj | 38 + .../TwoTargetLargeP6/project.json | 19 - .../TestAppSimple/TestAppSimple.csproj | 29 + .../TestAppWithProjDepTool/NuGet.Config | 6 + .../Program.cs | 0 .../TestAppWithProjDepTool.csproj} | 0 .../TestAppWithUnicodéPath/Program.cs | 12 + .../project.json | 0 .../TestLibraryWithConfiguration.csproj | 31 + build/Microsoft.DotNet.Cli.Compile.targets | 2 +- build/Microsoft.DotNet.Cli.Prepare.targets | 1 + build/Microsoft.DotNet.Cli.Test.targets | 36 +- build/Microsoft.DotNet.Cli.tasks | 2 +- .../Microsoft.DotNet.Cli.LzmaArchive.targets | 4 +- .../Microsoft.DotNet.Cli.Installer.DEB.proj | 10 +- ...Microsoft.DotNet.Cli.Installer.MSI.targets | 2 +- .../Microsoft.DotNet.Cli.Nupkg.targets | 32 +- build/test/TestPackageProjects.targets | 54 - .../dotnet-cli-build/DotNetRestore.cs | 18 +- ...estore3.cs => DotNetRestoreProjectJson.cs} | 22 +- src/Microsoft.DotNet.Cli.Utils/Command.cs | 26 +- .../CommandContext.cs | 7 +- .../AppBaseDllCommandResolver.cs | 1 - .../DepsJsonCommandResolver.cs | 2 +- .../CommandResolution/IProject.cs | 2 + .../CommandResolution/MSBuildProject.cs | 12 + .../OutputPathCommandResolver.cs | 4 +- .../PackagedCommandSpecFactory.cs | 6 +- .../PathCommandResolverPolicy.cs | 43 + .../ProjectDependenciesCommandResolver.cs | 7 +- .../CommandResolution/ProjectFactory.cs | 23 +- .../CommandResolution/ProjectJsonProject.cs | 119 -- .../ProjectToolsCommandResolver.cs | 40 +- .../PublishPathCommandSpecFactory.cs | 1 - .../CommandResolver.cs | 20 - .../DotnetRuntimeIdentifiers.cs | 1 - .../ProjectContextCollectionExtensions.cs | 51 - .../FileNameSuffixes.cs | 4 +- .../FrameworkDependencyFile.cs | 1 + .../RuntimeConfig.cs | 56 + .../RuntimeConfigFramework.cs | 34 + .../RuntimeEnvironmentRidExtensions.cs | 84 ++ .../ScriptExecutor.cs | 100 -- src/Microsoft.DotNet.Cli.Utils/ScriptNames.cs | 10 - src/Microsoft.DotNet.Cli.Utils/project.json | 4 +- .../AssemblyInfoFileGenerator.cs | 115 -- .../AssemblyInfoOptions.cs | 129 --- .../BindingRedirectGenerator.cs | 304 ----- .../CommonCompilerOptionsExtensions.cs | 157 --- .../DefaultCompilerWarningSuppresses.cs | 15 - .../DepsFormatter.cs | 20 - .../Executable.cs | 345 ------ .../LibraryExporterExtensions.cs | 84 -- .../Microsoft.DotNet.Compiler.Common.xproj | 20 - .../OptionTemplate.cs | 42 - .../ProjectContextExtensions.cs | 67 -- .../Properties/Properties.cs | 5 - .../project.json | 27 - .../NuGetCachePrimer.cs | 2 +- src/Microsoft.DotNet.Configurer/project.json | 3 - src/Microsoft.DotNet.Files/ContentFiles.cs | 120 -- .../Microsoft.DotNet.Files.xproj | 18 - .../Properties/AssemblyInfo.cs | 3 - src/Microsoft.DotNet.Files/project.json | 24 - .../ConstantPackageNames.cs | 2 +- .../DefaultMigrationRuleSet.cs | 2 +- .../MSBuildExtensions.cs | 2 +- .../AnalyzerOptions.cs | 4 +- .../BuildWorkspace.cs | 4 +- .../CommonCompilerOptions.cs | 6 +- .../Compilation/AnalyzerAssembly.cs | 4 +- .../Compilation/LibraryAsset.cs | 4 +- .../Compilation/LibraryAssetExtension.cs | 4 +- .../Compilation/LibraryAssetGroup.cs | 4 +- .../Compilation/LibraryExport.cs | 4 +- .../Compilation/LibraryExportBuilder.cs | 4 +- .../Compilation/LibraryExporter.cs | 12 +- .../Compilation/LibraryResourceAssembly.cs | 4 +- .../Preprocessor/PPFileParameters.cs | 4 +- .../Preprocessor/PPFilePreprocessor.cs | 2 +- .../Preprocessor/PPFileTokenizer.cs | 4 +- .../CompilationOutputFiles.cs | 8 +- .../Constants.cs | 2 +- .../DependencyContextBuilder.cs | 10 +- .../DesignTimeWorkspace.cs | 4 +- .../DiagnosticMessage.cs | 4 +- .../DiagnosticMessageSeverity.cs | 2 +- .../DirectoryNames.cs | 4 +- .../EnvironmentNames.cs | 4 +- .../ErrorCodes.DotNet.cs | 4 +- .../ErrorCodes.NuGet.cs | 4 +- .../FileFormatException.cs | 2 +- .../FileNameSuffixes.cs | 73 ++ .../Abstractions/DirectoryInfoBase.cs | 4 +- .../Abstractions/DirectoryInfoWrapper.cs | 4 +- .../Abstractions/FileInfoBase.cs | 4 +- .../Abstractions/FileInfoWrapper.cs | 4 +- .../Abstractions/FileSystemInfoBase.cs | 4 +- .../FileSystemGlobbing/FilePatternMatch.cs | 2 +- .../Internal/ILinearPattern.cs | 4 +- .../Internal/IPathSegment.cs | 4 +- .../FileSystemGlobbing/Internal/IPattern.cs | 4 +- .../Internal/IPatternContext.cs | 6 +- .../Internal/IRaggedPattern.cs | 4 +- .../Internal/MatcherContext.cs | 10 +- .../PathSegments/CurrentPathSegment.cs | 4 +- .../PathSegments/LiteralPathSegment.cs | 6 +- .../PathSegments/ParentPathSegment.cs | 4 +- .../PathSegments/RecursiveWildcardSegment.cs | 4 +- .../PathSegments/WildcardPathSegment.cs | 4 +- .../PatternContexts/PatternContext.cs | 6 +- .../PatternContexts/PatternContextLinear.cs | 6 +- .../PatternContextLinearExclude.cs | 6 +- .../PatternContextLinearInclude.cs | 6 +- .../PatternContexts/PatternContextRagged.cs | 6 +- .../PatternContextRaggedExclude.cs | 6 +- .../PatternContextRaggedInclude.cs | 8 +- .../Internal/PatternTestResult.cs | 2 +- .../Internal/Patterns/PatternBuilder.cs | 8 +- .../FileSystemGlobbing/Matcher.cs | 10 +- .../FileSystemGlobbing/MatcherExtensions.cs | 6 +- .../PatternMatchingResult.cs | 4 +- .../Util/StringComparisonHelper.cs | 2 +- .../Files/IncludeContext.cs | 4 +- .../Files/IncludeEntry.cs | 4 +- .../Files/IncludeFilesResolver.cs | 10 +- .../Files/NamedResourceReader.cs | 2 +- .../Files/PackIncludeEntry.cs | 4 +- .../Files/PatternGroup.cs | 6 +- .../Files/PatternsCollectionHelper.cs | 2 +- .../Files/ProjectFilesCollection.cs | 4 +- .../GlobalSettings.cs | 4 +- .../Graph/ExportFile.cs | 4 +- .../Graph/LockFileExtensions.cs | 4 +- .../Graph/LockFileLookup.cs | 4 +- .../Graph/ProjectLibraryDependency.cs | 4 +- .../IProjectReader.cs | 4 +- .../Internal/EmptyArray.cs | 2 +- .../LibraryDescription.cs | 4 +- .../MSBuildProjectDescription.cs | 4 +- .../Microsoft.DotNet.ProjectModel.xproj | 0 .../OutputPaths.cs | 4 +- .../OutputPathsCalculator.cs | 6 +- .../PackOptions.cs | 6 +- .../PackageDescription.cs | 6 +- .../Project.cs | 10 +- .../ProjectContext.cs | 8 +- .../ProjectContextBuilder.cs | 10 +- .../ProjectContextCollection.cs | 4 +- .../ProjectContextIdentity.cs | 2 +- .../ProjectDescription.cs | 4 +- .../ProjectExtensions.cs | 4 +- .../ProjectFileDependencyGroup.cs | 4 +- .../ProjectModelPlatformExtensions.cs | 6 +- .../ProjectPathHelper.cs | 4 +- .../ProjectReader.cs | 45 +- .../ProjectReaderSettings.cs | 4 +- .../ProjectRootResolver.cs | 4 +- .../Resolution/FrameworkInformation.cs | 2 +- .../Resolution/FrameworkReferenceResolver.cs | 6 +- .../Resolution/LibraryManager.cs | 6 +- .../Resolution/MSBuildDependencyProvider.cs | 4 +- .../Resolution/PackageDependencyProvider.cs | 4 +- .../Resolution/ProjectDependencyProvider.cs | 4 +- .../ReferenceAssemblyDependencyResolver.cs | 4 +- .../UnresolvedDependencyProvider.cs | 4 +- .../ResourceFile.cs | 4 +- .../Resources/CultureInfoCache.cs | 2 +- .../Resources/ResourceUtility.cs | 6 +- .../RuntimeConfig/RuntimeConfig.cs | 4 +- .../RuntimeConfig/RuntimeConfigFramework.cs | 4 +- .../RuntimeGraphCollector.cs | 2 +- .../RuntimeOptions.cs | 4 +- .../RuntimeOutputFiles.cs | 4 +- .../TargetFrameworkInformation.cs | 4 +- .../TargetLibraryWithAssets.cs | 4 +- .../Utilities/CollectionExtensions.cs | 4 +- .../Utilities/DictionaryExtensions.cs | 4 +- .../Utilities/FrameworksExtensions.cs | 2 +- .../Utilities/PathUtility.cs | 2 +- .../Utilities/ResilientFileStreamOpener.cs | 4 +- .../Utilities/VersionUtility.cs | 4 +- .../Workspace.cs | 6 +- .../MigrationError.cs | 2 +- .../MigrationErrorCodes.cs | 2 +- .../MigrationException.cs | 2 +- .../MigrationNuGetFrameworkExtensions.cs | 2 +- .../MigrationRuleInputs.cs | 4 +- .../MigrationSettings.cs | 2 +- .../MigrationTrace.cs | 2 +- .../Models/DefaultProjectItemInfo.cs | 2 +- .../Models/DefaultProjectPropertyInfo.cs | 2 +- .../Models/ItemMetadataValue.cs | 2 +- .../SerializableMigrationDefaultsInfo.cs | 2 +- .../ProjectContextExtensions.cs | 4 +- .../ProjectDependency.cs | 2 +- .../ProjectDependencyComparer.cs | 2 +- .../ProjectDependencyFinder.cs | 4 +- .../ProjectMigrator.cs | 6 +- .../Report/MigrationReport.cs | 2 +- .../Report/ProjectMigrationReport.cs | 2 +- .../Rules/AddDefaultsToProjectRule.cs | 2 +- .../Rules/CleanOutputProjectRule.cs | 2 +- .../Rules/IMigrationRule.cs | 2 +- .../Rules/MigrateAssemblyInfoRule.cs | 6 +- .../Rules/MigrateBuildOptionsRule.cs | 6 +- .../Rules/MigrateConfigurationsRule.cs | 4 +- .../Rules/MigrateJsonPropertiesRule.cs | 2 +- .../Rules/MigratePackOptionsRule.cs | 6 +- .../MigratePackageDependenciesAndToolsRule.cs | 4 +- .../Rules/MigrateProjectDependenciesRule.cs | 4 +- .../Rules/MigratePublishOptionsRule.cs | 2 +- .../Rules/MigrateRootOptionsRule.cs | 4 +- .../Rules/MigrateRuntimeOptionsRule.cs | 2 +- .../Rules/MigrateRuntimesRule.cs | 2 +- .../Rules/MigrateScriptsRule.cs | 4 +- .../Rules/MigrateTFMRule.cs | 2 +- .../Rules/RemoveDefaultsFromProjectRule.cs | 2 +- .../Rules/SaveOutputProjectRule.cs | 2 +- .../Transforms/ItemTransformApplicator.cs | 2 +- .../Transforms/PropertyTransformApplicator.cs | 2 +- .../project.json | 6 - .../transforms/AddItemTransform.cs | 2 +- .../transforms/AddPropertyTransform.cs | 2 +- .../transforms/ConditionalTransform.cs | 2 +- .../transforms/ITransform.cs | 2 +- .../transforms/ITransformApplicator.cs | 2 +- .../transforms/IncludeContextTransform.cs | 4 +- .../transforms/TransformApplicator.cs | 2 +- .../LoaderProjectContextExtensions.cs | 127 --- ...Microsoft.DotNet.ProjectModel.Loader.xproj | 18 - .../ProjectLoadContext.cs | 101 -- .../Properties/AssemblyInfo.cs | 3 - .../project.json | 17 - ...osoft.DotNet.ProjectModel.Workspaces.xproj | 19 - .../ProjectJsonWorkspace.cs | 251 ---- .../Properties/AssemblyInfo.cs | 3 - .../SnkUtils.cs | 87 -- .../WorkspaceProjectContextExtensions.cs | 9 - .../project.json | 24 - .../Properties/AssemblyInfo.cs | 34 - .../RuntimeEnvironmentRidExtensions.cs | 84 -- .../project.json | 33 - .../Extensions/DirectoryInfoExtensions.cs | 25 + .../TestAssetInfo.cs | 229 ++++ .../TestAssetInstance.cs | 87 ++ .../TestAssetInventoryFiles.cs | 76 ++ .../TestAssetKinds.cs | 20 + .../TestAssets.cs | 40 + .../TestInstance.cs | 17 +- .../AssemblyTestRunnerDecorator.cs | 32 - .../AssemblyUnderTest.cs | 33 - .../CommandTestRunnerExtensions.cs | 19 - .../ConsoleTestRunner.cs | 55 - .../DesignTimeRunner.cs | 69 -- src/Microsoft.DotNet.Tools.Test/DotnetTest.cs | 108 -- .../DotnetTestExtensions.cs | 63 -- .../DotnetTestParams.cs | 189 ---- .../DotnetTestRunnerFactory.cs | 56 - .../DotnetTestState.cs | 18 - .../IDotnetTest.cs | 27 - .../IDotnetTestRunner.cs | 10 - .../IDotnetTestRunnerFactory.cs | 10 - .../ITestMessagesCollection.cs | 17 - ...estRunnerProcessStartInfoMessageHandler.cs | 72 -- .../IDotnetTestMessageHandler.cs | 12 - .../TestDiscoveryStartMessageHandler.cs | 81 -- .../MessageHandlers/TestMessageTypes.cs | 26 - .../TestRunnerResultMessageHandler.cs | 47 - .../TestRunnerTestCompletedMessageHandler.cs | 67 -- .../TestRunnerTestFoundMessageHandler.cs | 21 - .../TestRunnerTestResultMessageHandler.cs | 21 - .../TestRunnerTestStartedMessageHandler.cs | 27 - .../TestRunnerWaitingCommandMessageHandler.cs | 73 -- .../TestSessionTerminateMessageHandler.cs | 30 - .../MessageHandlers/UnknownMessageHandler.cs | 30 - .../VersionCheckMessageHandler.cs | 56 - .../Microsoft.DotNet.Tools.Test.xproj | 20 - .../ProjectJsonTestRunnerDecorator.cs | 148 --- .../Properties/AssemblyInfo.cs | 5 - src/Microsoft.DotNet.Tools.Test/README.md | 104 -- .../AdapterReportingChannel.cs | 43 - .../ReportingChannels/IReportingChannel.cs | 24 - .../IReportingChannelFactory.cs | 16 - .../ReportingChannels/ReportingChannel.cs | 130 --- .../ReportingChannelFactory.cs | 26 - .../TestRunnerReportingChannel.cs | 42 - .../TestCommand.cs | 100 -- .../TestHostTracing.cs | 29 - .../TestMessagesCollection.cs | 73 -- .../TestProjectBuilder.cs | 52 - .../AssemblyTestRunnerNameResolver.cs | 34 - .../DiscoverTestsArgumentsBuilder.cs | 34 - .../DotnetTestRunnerResolverFactory.cs | 48 - .../TestRunners/ITestRunner.cs | 12 - .../ITestRunnerArgumentsBuilder.cs | 12 - .../TestRunners/ITestRunnerFactory.cs | 12 - .../TestRunners/ITestRunnerNameResolver.cs | 10 - .../ParameterTestRunnerNameResolver.cs | 20 - .../ProjectJsonTestRunnerNameResolver.cs | 22 - .../TestRunners/RunTestsArgumentsBuilder.cs | 36 - .../TestRunners/TestRunner.cs | 60 - .../TestRunners/TestRunnerFactory.cs | 24 - .../TestRunnerOperationFailedException.cs | 20 - .../TestStartInfo.cs | 12 - src/Microsoft.DotNet.Tools.Test/project.json | 39 - .../ComStreamWrapper.cs | 98 -- .../FullPdbReader.cs | 90 -- .../IPdbReader.cs | 13 - .../IPdbReaderFactory.cs | 21 - .../ISourceInformationProvider.cs | 13 - .../ITestDiscoverySink.cs | 10 - .../ITestExecutionSink.cs | 12 - .../ITestSink.cs | 12 - .../LineDelimitedJsonStream.cs | 25 - .../Messages/ErrorMessage.cs | 10 - .../Messages/Message.cs | 20 - .../Messages/ProtocolVersionMessage.cs | 10 - .../Messages/RunTestsMessage.cs | 12 - .../MetadataExtensions.cs | 27 - ...soft.Extensions.Testing.Abstractions.xproj | 18 - .../MissingPdbReader.cs | 12 - .../PdbReaderFactory.cs | 105 -- .../PortablePdbReader.cs | 90 -- .../Properties/AssemblyInfo.cs | 8 - .../SourceInformation.cs | 18 - .../SourceInformationProvider.cs | 104 -- .../StreamingTestDiscoverySink.cs | 27 - .../StreamingTestExecutionSink.cs | 72 -- .../StreamingTestSink.cs | 34 - .../SymUnmanagedReaderExtensions.cs | 116 -- .../Test.cs | 28 - .../TestHostServices.cs | 14 - .../TestOutcome.cs | 14 - .../TestResult.cs | 42 - .../project.json | 37 - src/dotnet/ForwardingApp.cs | 1 - src/dotnet/Program.cs | 27 +- src/dotnet/ProjectGlobbingResolver.cs | 6 +- .../commands/dotnet-build/BuildCommandApp.cs | 143 --- .../dotnet-build/CompilationResult.cs | 10 - .../commands/dotnet-build/CompilerIO.cs | 44 - .../dotnet-build/CompilerIOManager.cs | 183 --- .../dotnet-build/DotnetProjectBuilder.cs | 218 ---- .../commands/dotnet-build/IncrementalCache.cs | 114 -- .../dotnet-build/IncrementalManager.cs | 220 ---- .../IncrementalPreconditionManager.cs | 101 -- .../dotnet-build/IncrementalPreconditions.cs | 84 -- .../dotnet-build/IncrementalResult.cs | 34 - src/dotnet/commands/dotnet-build/Program.cs | 141 +-- .../commands/dotnet-build/ProjectBuilder.cs | 132 --- .../dotnet-build/ProjectGraphCollector.cs | 97 -- .../commands/dotnet-build/ProjectGraphNode.cs | 39 - src/dotnet/commands/dotnet-build/README.md | 81 -- src/dotnet/commands/dotnet-build3/Program.cs | 88 -- .../Program.cs | 6 +- .../AssemblyInfoOptionsCommandLine.cs | 78 -- .../CommonCompilerOptionsCommandLine.cs | 110 -- .../commands/dotnet-compile-csc/Program.cs | 232 ---- .../dotnet-compile-native/ArgValues.cs | 114 -- .../dotnet-compile-native/ArgumentsParser.cs | 124 -- .../DirectoryExtensions.cs | 29 - .../dotnet-compile-native/EnumExtensions.cs | 13 - .../ILCompilerInvoker.cs | 105 -- .../IPlatformNativeStep.cs | 9 - .../IntermediateCompiler.cs | 124 -- .../Linux/LinuxCppCompileStep.cs | 124 -- .../Linux/LinuxRyuJitCompileStep.cs | 124 -- .../Mac/MacCppCompileStep.cs | 135 --- .../Mac/MacRyuJitCompileStep.cs | 126 --- .../Windows/WindowsCommon.cs | 32 - .../Windows/WindowsCppCompileStep.cs | 131 --- .../Windows/WindowsLinkStep.cs | 157 --- .../NativeCompileSettings.cs | 234 ---- .../dotnet-compile-native/NativeCompiler.cs | 41 - .../commands/dotnet-compile-native/Program.cs | 83 -- .../RuntimeExtensions.cs | 16 - .../RuntimeInformationExtensions.cs | 29 - .../enums/ArchitectureMode.cs | 11 - .../enums/BuildConfiguration.cs | 11 - .../enums/NativeIntermediateMode.cs | 12 - .../dotnet-compile-native/enums/OSMode.cs | 12 - .../commands/dotnet-compile/CanonicalError.cs | 418 ------- .../dotnet-compile/CompilationDriver.cs | 37 - .../commands/dotnet-compile/Compiler.cs | 213 ---- .../commands/dotnet-compile/CompilerUtil.cs | 181 --- .../commands/dotnet-compile/ICompiler.cs | 12 - .../commands/dotnet-compile/IScriptRunner.cs | 13 - .../dotnet-compile/ManagedCompiler.cs | 236 ---- .../dotnet-compile/ResourceManifestName.cs | 199 ---- .../commands/dotnet-compile/ScriptRunner.cs | 24 - .../commands/dotnet-migrate/MigrateCommand.cs | 2 +- .../dotnet-new/CSharp_nunittest/Tests.cs | 18 - .../CSharp_nunittest/project.json.template | 22 - .../dotnet-new/CSharp_xunittest/Tests.cs | 14 - .../CSharp_xunittest/project.json.template | 26 - .../dotnet-new/FSharp_Console/Program.fs | 8 - .../FSharp_Console/project.json.template | 27 - .../commands/dotnet-new/FSharp_Lib/Library.fs | 5 - .../FSharp_Lib/project.json.template | 23 - src/dotnet/commands/dotnet-new/Program.cs | 16 +- .../dotnet-pack/ArtifactPathsCalculator.cs | 69 -- .../dotnet-pack/BuildProjectCommand.cs | 74 -- .../commands/dotnet-pack/NuGet/Constants.cs | 64 -- .../NuGet/EmptyFrameworkFolderFile.cs | 26 - .../NuGet/FrameworkAssemblyReference.cs | 32 - .../dotnet-pack/NuGet/IPackageFile.cs | 20 - .../commands/dotnet-pack/NuGet/Manifest.cs | 130 --- .../dotnet-pack/NuGet/ManifestContentFiles.cs | 18 - .../dotnet-pack/NuGet/ManifestFile.cs | 21 - .../dotnet-pack/NuGet/ManifestMetadata.cs | 90 -- .../dotnet-pack/NuGet/ManifestReader.cs | 313 ----- .../NuGet/ManifestSchemaUtility.cs | 77 -- .../NuGet/ManifestVersionAttribute.cs | 18 - .../NuGet/ManifestVersionUtility.cs | 112 -- .../dotnet-pack/NuGet/PackageBuilder.cs | 485 -------- .../dotnet-pack/NuGet/PackageDependencySet.cs | 39 - .../dotnet-pack/NuGet/PackageIdValidator.cs | 40 - .../NuGet/PackageMetadataXmlExtensions.cs | 273 ----- .../dotnet-pack/NuGet/PackageReferenceSet.cs | 39 - .../dotnet-pack/NuGet/PathResolver.cs | 304 ----- .../commands/dotnet-pack/NuGet/PathUtility.cs | 33 - .../dotnet-pack/NuGet/PhysicalPackageFile.cs | 80 -- .../PackCommand.cs} | 8 +- .../commands/dotnet-pack/PackageGenerator.cs | 420 ------- .../commands/dotnet-pack/PackagesGenerator.cs | 41 - src/dotnet/commands/dotnet-pack/Program.cs | 95 -- .../Properties/launchSettings.json | 7 - src/dotnet/commands/dotnet-pack/README.md | 76 -- .../dotnet-pack/SymbolPackageGenerator.cs | 72 -- .../ConnectionContext.cs | 62 - .../Helpers/DependencyTypeChangeFinder.cs | 101 -- .../Helpers/JTokenExtensions.cs | 26 - .../Helpers/NuGetFrameworkExtensions.cs | 22 - .../Helpers/ProjectExtensions.cs | 59 - .../InternalModels/ProjectContextSnapshot.cs | 93 -- .../InternalModels/ProjectSnapshot.cs | 51 - .../MessageTypes.cs | 27 - .../Messengers/CompilerOptionsMessenger.cs | 42 - .../Messengers/DependenciesMessenger.cs | 47 - .../DependencyDiagnosticsMessenger.cs | 34 - .../Messengers/GlobalErrorMessenger.cs | 43 - .../Messengers/Messenger.cs | 34 - .../Messengers/ProjectDiagnosticsMessenger.cs | 32 - .../Messengers/ProjectInformationMessenger.cs | 68 -- .../Messengers/ReferencesMessenger.cs | 48 - .../Messengers/SourcesMessenger.cs | 45 - .../Models/DependencyDescription.cs | 94 -- .../Models/DependencyItem.cs | 27 - .../Models/DiagnosticMessageGroup.cs | 25 - .../Models/DiagnosticMessageView.cs | 74 -- .../Models/DiagnosticsListMessage.cs | 69 -- .../Models/ErrorMessage.cs | 30 - .../Models/FrameworkData.cs | 28 - .../Models/Message.cs | 39 - .../Models/ProjectReferenceDescription.cs | 57 - .../ProcessingQueue.cs | 88 -- .../dotnet-projectmodel-server/Program.cs | 161 --- .../ProjectManager.cs | 327 ------ .../ProtocolManager.cs | 107 -- src/dotnet/commands/dotnet-publish/Program.cs | 85 +- .../commands/dotnet-publish/PublishCommand.cs | 414 +------ src/dotnet/commands/dotnet-publish/README.md | 79 -- .../commands/dotnet-publish3/Program.cs | 65 -- .../dotnet-publish3/Publish3Command.cs | 68 -- .../commands/dotnet-repl-csi/Program.cs | 184 --- src/dotnet/commands/dotnet-repl/Program.cs | 90 -- src/dotnet/commands/dotnet-resgen/Program.cs | 45 - .../commands/dotnet-resgen/ResgenCommand.cs | 82 -- .../ResourceAssemblyGenerator.cs | 83 -- .../commands/dotnet-resgen/ResourceFile.cs | 44 - .../dotnet-resgen/ResourceFileType.cs | 12 - .../commands/dotnet-resgen/ResourceSource.cs | 18 - .../dotnet-resgen/ResourcesFileGenerator.cs | 38 - .../NuGet3.cs | 2 +- .../dotnet-restore-projectjson/Program.cs | 21 + .../README.md | 0 src/dotnet/commands/dotnet-restore/Program.cs | 113 +- .../commands/dotnet-restore3/Program.cs | 131 --- src/dotnet/commands/dotnet-run/Program.cs | 29 +- src/dotnet/commands/dotnet-run/README.md | 69 -- src/dotnet/commands/dotnet-run/RunCommand.cs | 265 ++--- src/dotnet/commands/dotnet-run3/Program.cs | 54 - .../commands/dotnet-run3/Run3Command.cs | 169 --- .../{dotnet-test3 => dotnet-test}/Program.cs | 8 +- src/dotnet/project.json | 14 +- test/ArgumentForwardingTests/project.json | 3 - test/EndToEnd/GivenDotNetUsesMSBuild.cs | 71 +- test/EndToEnd/project.json | 3 - ...GivenAProjectDependenciesCommandFactory.cs | 163 ++- .../GivenAProjectDependencyCommandResolver.cs | 321 ++---- ...encyCommandResolverBeingUsedWithMSBuild.cs | 163 --- .../GivenAProjectToolsCommandResolver.cs | 84 +- .../StreamForwarderTests.cs | 10 +- .../project.json | 3 - .../GivenCommonCompilerOptions.cs | 35 - .../GivenThatICopyLibraryAssets.cs | 75 -- ...crosoft.DotNet.Compiler.Common.Tests.xproj | 18 - .../project.json | 30 - .../GivenANuGetCachePrimer.cs | 6 +- .../GivenAProjectMigrator.cs | 6 +- .../GivenThatIWantToMigrateAssemblyInfo.cs | 2 +- .../GivenThatIWantToMigrateBuildOptions.cs | 4 +- .../GivenThatIWantToMigrateConfigurations.cs | 2 +- ...enThatIWantToMigrateProjectDependencies.cs | 2 +- .../GivenThatIWantToMigratePublishOptions.cs | 4 +- .../GivenThatIWantToMigrateRuntimeOptions.cs | 4 +- .../Rules/GivenThatIWantToMigrateTFMs.cs | 2 +- .../TemporaryProjectFileRuleRunner.cs | 4 +- ...oft.DotNet.ProjectModel.Loader.Tests.xproj | 21 - .../ProjectLoadContextTest.cs | 34 - .../Properties/AssemblyInfo.cs | 19 - .../project.json | 29 - .../FileAbstractionsTests.cs | 100 -- .../FileSystemGlobbing/FunctionalTests.cs | 469 -------- .../PatternContextLinearTests.cs | 168 --- .../PatternContextRaggedTests.cs | 80 -- .../PatternMatchingTests.cs | 472 -------- .../CurrentPathSegmentTests.cs | 21 - .../LiteralPathSegmentTests.cs | 42 - .../PatternSegments/ParentPathSegmentTests.cs | 21 - .../RecursiveWildcardSegmentTests.cs | 18 - .../WildcardPathSegmentTests.cs | 166 --- .../Patterns/PatternTests.cs | 139 --- .../TestUtility/DisposableFileSystem.cs | 61 - .../FileSystemGlobbingTestContext.cs | 85 -- .../FileSystemOperationRecorder.cs | 28 - .../TestUtility/MockDirectoryInfo.cs | 116 -- .../TestUtility/MockFileInfoStub.cs | 29 - .../TestUtility/MockLinearPatternBuilder.cs | 64 -- .../MockNonRecursivePathSegment.cs | 32 - .../TestUtility/MockRaggedPatternBuilder.cs | 104 -- .../TestUtility/MockRecursivePathSegment.cs | 18 - .../TestUtility/PatternContextHelper.cs | 19 - ...hatIWantToCreateFileCollectionsFromJson.cs | 89 -- ...ThatIWantToCreateIncludeEntriesFromJson.cs | 306 ----- .../GivenThatIWantToLoadAProjectJsonFile.cs | 1005 ----------------- ...ivenThatIWantToReadFilePatternsFromJson.cs | 125 -- ...enThatIWantToReadGlobalSettingsFromJson.cs | 159 --- .../GivenThatIWantToReadNamedResources.cs | 84 -- .../LibraryExporterPackageTests.cs | 366 ------ .../LibraryExporterTests.cs | 31 - .../LockFilePatchingTests.cs | 85 -- .../Microsoft.DotNet.ProjectModel.Tests.xproj | 21 - .../PackageDependencyProviderTests.cs | 227 ---- .../PreprocessorTests.cs | 53 - .../ProjectContextBuilderTests.cs | 85 -- .../project.json | 41 - .../Assertions/CommandResultAssertions.cs | 5 +- .../Assertions/DirectoryInfoExtensions.cs | 15 + .../Assertions/FileInfoAssertions.cs | 55 + .../Assertions/FileInfoExtensions.cs | 24 + .../Commands/Build3Command.cs | 30 - .../Commands/BuildCommand.cs | 396 +++---- .../Commands/BuildPJCommand.cs | 164 +++ .../{Clean3Command.cs => CleanCommand.cs} | 8 +- .../Commands/DependencyToolInvokerCommand.cs | 1 - .../Commands/PackCommand.cs | 9 +- .../Commands/Publish3Command.cs | 52 - .../Commands/PublishCommand.cs | 123 +- .../Commands/Restore3Command.cs | 27 - .../Commands/RestoreCommand.cs | 6 +- ...ommand.cs => RestoreProjectJsonCommand.cs} | 12 +- .../Commands/Run3Command.cs | 30 - .../Commands/RunCommand.cs | 52 +- .../Commands/TestCommand.cs | 59 +- .../Commands/TestCommandExtensions.cs | 45 + .../RepoDirectoriesProvider.cs | 16 +- .../TestBase.cs | 17 +- .../project.json | 1 - test/Performance/BuildPerformanceTest.cs | 163 ++- test/Performance/HelloWorld.cs | 4 +- test/Performance/project.json | 3 - test/ScriptExecutorTests/project.json | 3 - ...antToUseFullPdbsToFindMethodInformation.cs | 85 -- ...oUsePortablePdbsToFindMethodInformation.cs | 85 -- ...xtensions.Testing.Abstractions.Tests.xproj | 21 - .../project.json | 34 - ...formationProviderToGetSourceInformation.cs | 63 -- ...sions.Testing.Abstractions.UnitTests.xproj | 21 - .../project.json | 30 - .../TestAppWithFullPdbs/ClassForFullPdbs.cs | 13 - .../TestAppWithFullPdbs.xproj | 18 - .../TestAppWithFullPdbs/project.json | 12 - .../ClassForPortablePdbs.cs | 13 - .../TestAppWithPortablePdbs.xproj | 18 - .../TestAppWithPortablePdbs/project.json | 12 - .../BindingRedirectTests.cs | 22 +- .../TestSetupFixture.cs | 24 +- test/binding-redirects.Tests/project.json | 1 + .../GivenDotnetBuildBuildsCsproj.cs} | 10 +- .../dotnet-build.Tests.xproj} | 0 .../project.json | 0 test/dotnet-compile.Tests/CompilerTests.cs | 237 ---- .../dotnet-compile.Tests.xproj | 21 - test/dotnet-compile.Tests/project.json | 49 - .../BindingRedirectGeneratorTests.cs | 59 - .../GivenACompilationDriver.cs | 84 -- ...boutScriptVariablesFromAManagedCompiler.cs | 236 ---- .../dotnet-compile.UnitTests.xproj | 21 - test/dotnet-compile.UnitTests/project.json | 59 - .../GivenThatIWantToMigrateTestApps.cs | 45 +- .../GivenDotnetMSBuildBuildsProjects.cs | 20 +- .../GivenThatIWantANewCSApp.cs | 10 +- .../GivenThatIWantANewCSLIbrary.cs | 8 +- .../GivenThatIWantANewCSnUnitProject.cs | 49 - .../GivenThatIWantANewCSxUnitProject.cs | 54 - test/dotnet-pack.Tests/PackTests.cs | 229 ++-- .../GivenDotnetPublishPublishesProjects.cs} | 40 +- .../PublishAppWithBuildDependency.cs | 49 - .../PublishAppWithDependencies.cs | 86 -- .../PublishDesktopTests.cs | 158 --- .../PublishPortableTests.cs | 117 -- .../PublishStandaloneTests.cs | 60 - test/dotnet-publish.Tests/PublishTests.cs | 386 ------- .../dotnet-publish.Tests.xproj | 9 +- test/dotnet-publish.Tests/project.json | 7 +- .../dotnet-publish3.Tests.xproj | 21 - test/dotnet-publish3.Tests/project.json | 34 - .../Microsoft.DotNet.Tools.Resgen.Tests.cs | 43 - .../dotnet-resgen.Tests.xproj | 19 - test/dotnet-resgen.Tests/project.json | 40 - .../GivenDotnetRunRunsCsProj.cs | 118 ++ test/dotnet-run.Tests/RunTests.cs | 192 ---- test/dotnet-run.Tests/dotnet-run.Tests.xproj | 19 - test/dotnet-run.Tests/project.json | 3 - test/dotnet-run.UnitTests/GivenARunCommand.cs | 53 - .../dotnet-run.UnitTests.xproj | 18 - test/dotnet-run.UnitTests/project.json | 38 - .../GivenDotnetRun3RunsCsProj.cs | 172 --- .../dotnet-run3.Tests/dotnet-run3.Tests.xproj | 18 - test/dotnet-run3.Tests/project.json | 24 - test/dotnet-test.Tests/Adapter.cs | 177 --- test/dotnet-test.Tests/AssemblyInfo.cs | 4 - ...nDotnetTestBuildsAndRunsTestfromCsproj.cs} | 12 +- .../GivenThatWeWantToRunTests.cs | 29 - ...ntToRunTestsForMultipleTFMsInTheConsole.cs | 155 --- .../GivenThatWeWantToRunTestsInTheConsole.cs | 158 --- ...hatWeWantToUseDotnetTestE2EInDesignTime.cs | 77 -- ...otnetTestE2EInDesignTimeForMultipleTFms.cs | 135 --- .../dotnet-test.Tests/dotnet-test.Tests.xproj | 10 +- test/dotnet-test.Tests/project.json | 39 +- .../DotnetTestMessageScenario.cs | 79 -- .../GivenADiscoverTestsArgumentsBuilder.cs | 25 - .../GivenADotnetTestApp.cs | 157 --- .../GivenAParameterTestRunnerNameResolver.cs | 24 - ...GivenAProjectJsonTestRunnerNameResolver.cs | 43 - .../GivenARunTestsArgumentsBuilder.cs | 38 - .../GivenATestCommand.cs | 73 -- .../GivenATestDiscoveryStartMessageHandler.cs | 174 --- ...estRunnerProcessStartInfoMessageHandler.cs | 202 ---- .../dotnet-test.UnitTests/GivenATestRunner.cs | 106 -- ...NameResolverFactoryAndADotnetTestParams.cs | 79 -- ...nATestRunnerTestCompletedMessageHandler.cs | 122 -- ...GivenATestRunnerTestFoundMessageHandler.cs | 84 -- ...ivenATestRunnerTestResultMessageHandler.cs | 84 -- ...venATestRunnerTestStartedMessageHandler.cs | 112 -- ...ATestRunnerWaitingCommandMessageHandler.cs | 145 --- ...ivenATestSessionTerminateMessageHandler.cs | 42 - .../GivenAUnknownMessageHandler.cs | 39 - .../GivenAVersionCheckMessageHandler.cs | 83 -- .../GivenAnAssemblyTestRunnerNameResolver.cs | 100 -- .../GivenThatWeWantToDiscoverTests.cs | 67 -- ...ThatWeWantToParseArgumentsForDotnetTest.cs | 281 ----- .../GivenThatWeWantToRunTests.cs | 98 -- .../dotnet-test.UnitTests.xproj | 21 - test/dotnet-test.UnitTests/project.json | 47 - .../dotnet-test3.Tests.xproj | 21 - test/dotnet-test3.Tests/project.json | 24 - test/dotnet-vstest.Tests/VSTestTests.cs | 4 +- .../GivenThatDotNetRunsCommands.cs | 13 +- .../GivenThatIWantToManageMulticoreJIT.cs | 14 +- test/dotnet.Tests/PackagedCommandTests.cs | 211 ++-- test/dotnet.Tests/VersionTest.cs | 1 + test/dotnet.Tests/project.json | 1 + 746 files changed, 4256 insertions(+), 32434 deletions(-) delete mode 100644 TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/project.json rename TestAssets/DesktopTestProjects/{AppWithDirectDepDesktopAndPortable => AppWithProjTool2Fx}/.noautobuild (100%) create mode 100644 TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj create mode 100644 TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config rename TestAssets/DesktopTestProjects/{AppWithDirectDepDesktopAndPortable => AppWithProjTool2Fx}/Program.cs (100%) rename TestAssets/DesktopTestProjects/{LibraryWithDirectDependencyDesktopAndPortable => LibWithProjTool2Fx}/.noautobuild (100%) create mode 100644 TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj create mode 100644 TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config rename TestAssets/DesktopTestProjects/{LibraryWithDirectDependencyDesktopAndPortable => LibWithProjTool2Fx}/Program.cs (100%) delete mode 100644 TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/project.json create mode 100755 TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/TestProjectWithUnresolvedPlatformDependency.csproj delete mode 100644 TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/project.json create mode 100755 TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj create mode 100644 TestAssets/TestProjects/AppWithDepOnToolWithOutputName/NuGet.Config delete mode 100644 TestAssets/TestProjects/AppWithDepOnToolWithOutputName/project.json create mode 100755 TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj create mode 100644 TestAssets/TestProjects/AppWithDirectAndToolDep/NuGet.Config delete mode 100644 TestAssets/TestProjects/AppWithDirectAndToolDep/project.json create mode 100755 TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj create mode 100644 TestAssets/TestProjects/AppWithDirectDep/NuGet.Config delete mode 100644 TestAssets/TestProjects/AppWithDirectDep/project.json create mode 100644 TestAssets/TestProjects/AppWithDirectDepAndTypeBuild/NuGet.Config create mode 100755 TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj create mode 100644 TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config delete mode 100644 TestAssets/TestProjects/AppWithDirectDepWithOutputName/project.json create mode 100644 TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj create mode 100644 TestAssets/TestProjects/AppWithMultipleFxAndTools/NuGet.Config rename TestAssets/TestProjects/{MSBuildAppWithMultipleFrameworksAndTools => AppWithMultipleFxAndTools}/Program.cs (100%) create mode 100755 TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj create mode 100755 TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj create mode 100644 TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config delete mode 100644 TestAssets/TestProjects/DependencyContextFromTool/project.json create mode 100755 TestAssets/TestProjects/LibraryWithOutputAssemblyName/MyLibrary.csproj delete mode 100644 TestAssets/TestProjects/LibraryWithOutputAssemblyName/project.json create mode 100644 TestAssets/TestProjects/PJTestAppSimple/Program.cs rename TestAssets/TestProjects/{AppWithToolDependency => PJTestAppSimple}/project.json (81%) mode change 100644 => 100755 create mode 100644 TestAssets/TestProjects/PJTestLibraryWithConfiguration/.noautobuild create mode 100644 TestAssets/TestProjects/PJTestLibraryWithConfiguration/Helper.cs rename TestAssets/TestProjects/{TestLibraryWithConfiguration => PJTestLibraryWithConfiguration}/project.json (98%) mode change 100644 => 100755 create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/SingleTargetApp.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/SingleTargetP0.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/SingleTargetP1.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/SingleTargetP2.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/TwoTargetApp.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/TwoTargetP0.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/TwoTargetP1.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/TwoTargetP2.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/TwoTargetLargeP0.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/TwoTargetLargeP1.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/TwoTargetLargeP2.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/TwoTargetLargeP3.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/TwoTargetLargeP4.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/TwoTargetLargeP5.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/project.json create mode 100755 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/TwoTargetLargeP6.csproj delete mode 100644 TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/project.json create mode 100755 TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj create mode 100644 TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config rename TestAssets/TestProjects/{MSBuildTestAppWithToolInDependencies => TestAppWithProjDepTool}/Program.cs (100%) rename TestAssets/TestProjects/{MSBuildTestAppWithToolInDependencies/MSBuildTestAppWithToolInDependencies.csproj => TestAppWithProjDepTool/TestAppWithProjDepTool.csproj} (100%) create mode 100644 TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs rename TestAssets/TestProjects/{TestAppSimple => TestAppWithUnicodéPath}/project.json (100%) create mode 100755 TestAssets/TestProjects/TestLibraryWithConfiguration/TestLibraryWithConfiguration.csproj rename build_projects/dotnet-cli-build/{DotNetRestore3.cs => DotNetRestoreProjectJson.cs} (56%) create mode 100644 src/Microsoft.DotNet.Cli.Utils/CommandResolution/PathCommandResolverPolicy.cs delete mode 100644 src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectJsonProject.cs delete mode 100644 src/Microsoft.DotNet.Cli.Utils/Extensions/ProjectContextCollectionExtensions.cs rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.Cli.Utils}/FileNameSuffixes.cs (98%) create mode 100644 src/Microsoft.DotNet.Cli.Utils/RuntimeConfig.cs create mode 100644 src/Microsoft.DotNet.Cli.Utils/RuntimeConfigFramework.cs create mode 100644 src/Microsoft.DotNet.Cli.Utils/RuntimeEnvironmentRidExtensions.cs delete mode 100644 src/Microsoft.DotNet.Cli.Utils/ScriptExecutor.cs delete mode 100644 src/Microsoft.DotNet.Cli.Utils/ScriptNames.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/BindingRedirectGenerator.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/DefaultCompilerWarningSuppresses.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/DepsFormatter.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/Executable.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/Microsoft.DotNet.Compiler.Common.xproj delete mode 100644 src/Microsoft.DotNet.Compiler.Common/OptionTemplate.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/ProjectContextExtensions.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/Properties/Properties.cs delete mode 100644 src/Microsoft.DotNet.Compiler.Common/project.json delete mode 100644 src/Microsoft.DotNet.Files/ContentFiles.cs delete mode 100644 src/Microsoft.DotNet.Files/Microsoft.DotNet.Files.xproj delete mode 100644 src/Microsoft.DotNet.Files/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.DotNet.Files/project.json rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/AnalyzerOptions.cs (92%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/BuildWorkspace.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/CommonCompilerOptions.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/AnalyzerAssembly.cs (92%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryAsset.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryAssetExtension.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryAssetGroup.cs (91%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryExport.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryExportBuilder.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryExporter.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/LibraryResourceAssembly.cs (80%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/Preprocessor/PPFileParameters.cs (83%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/Preprocessor/PPFilePreprocessor.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Compilation/Preprocessor/PPFileTokenizer.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/CompilationOutputFiles.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Constants.cs (91%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/DependencyContextBuilder.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/DesignTimeWorkspace.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/DiagnosticMessage.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/DiagnosticMessageSeverity.cs (88%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/DirectoryNames.cs (52%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/EnvironmentNames.cs (80%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ErrorCodes.DotNet.cs (91%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ErrorCodes.NuGet.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileFormatException.cs (98%) create mode 100644 src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileNameSuffixes.cs rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs (74%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Abstractions/FileInfoBase.cs (57%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs (84%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs (73%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/FilePatternMatch.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/ILinearPattern.cs (68%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/IPathSegment.cs (69%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/IPattern.cs (73%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/IPatternContext.cs (70%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/IRaggedPattern.cs (76%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/MatcherContext.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs (71%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs (85%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs (76%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs (70%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs (79%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs (75%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs (84%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs (82%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs (82%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/PatternTestResult.cs (90%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Matcher.cs (80%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/MatcherExtensions.cs (87%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/PatternMatchingResult.cs (79%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/FileSystemGlobbing/Util/StringComparisonHelper.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/IncludeContext.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/IncludeEntry.cs (91%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/IncludeFilesResolver.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/NamedResourceReader.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/PackIncludeEntry.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/PatternGroup.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/PatternsCollectionHelper.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Files/ProjectFilesCollection.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/GlobalSettings.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Graph/ExportFile.cs (87%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Graph/LockFileExtensions.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Graph/LockFileLookup.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Graph/ProjectLibraryDependency.cs (76%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/IProjectReader.cs (76%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Internal/EmptyArray.cs (88%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/LibraryDescription.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/MSBuildProjectDescription.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Microsoft.DotNet.ProjectModel.xproj (100%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/OutputPaths.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/OutputPathsCalculator.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/PackOptions.cs (84%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/PackageDescription.cs (91%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Project.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectContext.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectContextBuilder.cs (99%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectContextCollection.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectContextIdentity.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectDescription.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectExtensions.cs (90%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectFileDependencyGroup.cs (85%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectModelPlatformExtensions.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectPathHelper.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectReader.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectReaderSettings.cs (85%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ProjectRootResolver.cs (89%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/FrameworkInformation.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/FrameworkReferenceResolver.cs (99%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/LibraryManager.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/MSBuildDependencyProvider.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/PackageDependencyProvider.cs (98%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/ProjectDependencyProvider.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/ReferenceAssemblyDependencyResolver.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resolution/UnresolvedDependencyProvider.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/ResourceFile.cs (79%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resources/CultureInfoCache.cs (99%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Resources/ResourceUtility.cs (94%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/RuntimeConfig/RuntimeConfig.cs (95%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/RuntimeConfig/RuntimeConfigFramework.cs (92%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/RuntimeGraphCollector.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/RuntimeOptions.cs (77%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/RuntimeOutputFiles.cs (96%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/TargetFrameworkInformation.cs (88%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/TargetLibraryWithAssets.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Utilities/CollectionExtensions.cs (93%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Utilities/DictionaryExtensions.cs (90%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Utilities/FrameworksExtensions.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Utilities/PathUtility.cs (99%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Utilities/ResilientFileStreamOpener.cs (91%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Utilities/VersionUtility.cs (97%) rename src/{Microsoft.DotNet.ProjectModel => Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel}/Workspace.cs (98%) delete mode 100644 src/Microsoft.DotNet.ProjectModel.Loader/LoaderProjectContextExtensions.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Loader/Microsoft.DotNet.ProjectModel.Loader.xproj delete mode 100644 src/Microsoft.DotNet.ProjectModel.Loader/ProjectLoadContext.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Loader/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Loader/project.json delete mode 100644 src/Microsoft.DotNet.ProjectModel.Workspaces/Microsoft.DotNet.ProjectModel.Workspaces.xproj delete mode 100644 src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Workspaces/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Workspaces/SnkUtils.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Workspaces/WorkspaceProjectContextExtensions.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel.Workspaces/project.json delete mode 100644 src/Microsoft.DotNet.ProjectModel/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel/RuntimeEnvironmentRidExtensions.cs delete mode 100644 src/Microsoft.DotNet.ProjectModel/project.json create mode 100644 src/Microsoft.DotNet.TestFramework/Extensions/DirectoryInfoExtensions.cs create mode 100644 src/Microsoft.DotNet.TestFramework/TestAssetInfo.cs create mode 100644 src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs create mode 100644 src/Microsoft.DotNet.TestFramework/TestAssetInventoryFiles.cs create mode 100644 src/Microsoft.DotNet.TestFramework/TestAssetKinds.cs create mode 100644 src/Microsoft.DotNet.TestFramework/TestAssets.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/AssemblyTestRunnerDecorator.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/AssemblyUnderTest.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/CommandTestRunnerExtensions.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ConsoleTestRunner.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/DesignTimeRunner.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/DotnetTest.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/DotnetTestExtensions.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/DotnetTestParams.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/DotnetTestRunnerFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/DotnetTestState.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/IDotnetTest.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/IDotnetTestRunner.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/IDotnetTestRunnerFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ITestMessagesCollection.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/GetTestRunnerProcessStartInfoMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/IDotnetTestMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestDiscoveryStartMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestMessageTypes.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerResultMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestCompletedMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestFoundMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestResultMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestStartedMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerWaitingCommandMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestSessionTerminateMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/UnknownMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/MessageHandlers/VersionCheckMessageHandler.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/Microsoft.DotNet.Tools.Test.xproj delete mode 100644 src/Microsoft.DotNet.Tools.Test/ProjectJsonTestRunnerDecorator.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/README.md delete mode 100644 src/Microsoft.DotNet.Tools.Test/ReportingChannels/AdapterReportingChannel.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannel.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannelFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannel.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannelFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/ReportingChannels/TestRunnerReportingChannel.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestCommand.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestHostTracing.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestMessagesCollection.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestProjectBuilder.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/AssemblyTestRunnerNameResolver.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/DiscoverTestsArgumentsBuilder.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/DotnetTestRunnerResolverFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunner.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerArgumentsBuilder.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerNameResolver.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/ParameterTestRunnerNameResolver.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/ProjectJsonTestRunnerNameResolver.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/RunTestsArgumentsBuilder.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunner.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerFactory.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerOperationFailedException.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/TestStartInfo.cs delete mode 100644 src/Microsoft.DotNet.Tools.Test/project.json delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/ComStreamWrapper.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/FullPdbReader.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/IPdbReader.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/IPdbReaderFactory.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/ISourceInformationProvider.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/ITestDiscoverySink.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/ITestExecutionSink.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/ITestSink.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/LineDelimitedJsonStream.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Messages/ErrorMessage.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Messages/Message.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Messages/ProtocolVersionMessage.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Messages/RunTestsMessage.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/MetadataExtensions.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Microsoft.Extensions.Testing.Abstractions.xproj delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/MissingPdbReader.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/PdbReaderFactory.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/PortablePdbReader.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/SourceInformation.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/SourceInformationProvider.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/StreamingTestDiscoverySink.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/StreamingTestExecutionSink.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/StreamingTestSink.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/SymUnmanagedReaderExtensions.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/Test.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/TestHostServices.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/TestOutcome.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/TestResult.cs delete mode 100644 src/Microsoft.Extensions.Testing.Abstractions/project.json delete mode 100644 src/dotnet/commands/dotnet-build/BuildCommandApp.cs delete mode 100644 src/dotnet/commands/dotnet-build/CompilationResult.cs delete mode 100644 src/dotnet/commands/dotnet-build/CompilerIO.cs delete mode 100644 src/dotnet/commands/dotnet-build/CompilerIOManager.cs delete mode 100644 src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs delete mode 100644 src/dotnet/commands/dotnet-build/IncrementalCache.cs delete mode 100644 src/dotnet/commands/dotnet-build/IncrementalManager.cs delete mode 100644 src/dotnet/commands/dotnet-build/IncrementalPreconditionManager.cs delete mode 100644 src/dotnet/commands/dotnet-build/IncrementalPreconditions.cs delete mode 100644 src/dotnet/commands/dotnet-build/IncrementalResult.cs delete mode 100644 src/dotnet/commands/dotnet-build/ProjectBuilder.cs delete mode 100644 src/dotnet/commands/dotnet-build/ProjectGraphCollector.cs delete mode 100644 src/dotnet/commands/dotnet-build/ProjectGraphNode.cs delete mode 100644 src/dotnet/commands/dotnet-build/README.md delete mode 100644 src/dotnet/commands/dotnet-build3/Program.cs rename src/dotnet/commands/{dotnet-clean3 => dotnet-clean}/Program.cs (96%) delete mode 100644 src/dotnet/commands/dotnet-compile-csc/AssemblyInfoOptionsCommandLine.cs delete mode 100644 src/dotnet/commands/dotnet-compile-csc/CommonCompilerOptionsCommandLine.cs delete mode 100644 src/dotnet/commands/dotnet-compile-csc/Program.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/ArgValues.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/ArgumentsParser.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/DirectoryExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/EnumExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/ILCompilerInvoker.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IPlatformNativeStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IntermediateCompiler.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxCppCompileStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxRyuJitCompileStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacCppCompileStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacRyuJitCompileStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCommon.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCppCompileStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsLinkStep.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/NativeCompileSettings.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/NativeCompiler.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/Program.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/RuntimeExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/RuntimeInformationExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/enums/ArchitectureMode.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/enums/BuildConfiguration.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/enums/NativeIntermediateMode.cs delete mode 100644 src/dotnet/commands/dotnet-compile-native/enums/OSMode.cs delete mode 100644 src/dotnet/commands/dotnet-compile/CanonicalError.cs delete mode 100644 src/dotnet/commands/dotnet-compile/CompilationDriver.cs delete mode 100644 src/dotnet/commands/dotnet-compile/Compiler.cs delete mode 100644 src/dotnet/commands/dotnet-compile/CompilerUtil.cs delete mode 100644 src/dotnet/commands/dotnet-compile/ICompiler.cs delete mode 100644 src/dotnet/commands/dotnet-compile/IScriptRunner.cs delete mode 100644 src/dotnet/commands/dotnet-compile/ManagedCompiler.cs delete mode 100644 src/dotnet/commands/dotnet-compile/ResourceManifestName.cs delete mode 100644 src/dotnet/commands/dotnet-compile/ScriptRunner.cs delete mode 100644 src/dotnet/commands/dotnet-new/CSharp_nunittest/Tests.cs delete mode 100644 src/dotnet/commands/dotnet-new/CSharp_nunittest/project.json.template delete mode 100644 src/dotnet/commands/dotnet-new/CSharp_xunittest/Tests.cs delete mode 100644 src/dotnet/commands/dotnet-new/CSharp_xunittest/project.json.template delete mode 100644 src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs delete mode 100644 src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template delete mode 100644 src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs delete mode 100644 src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template delete mode 100644 src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs delete mode 100644 src/dotnet/commands/dotnet-pack/BuildProjectCommand.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/Constants.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/EmptyFrameworkFolderFile.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/FrameworkAssemblyReference.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/IPackageFile.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/Manifest.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestContentFiles.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestFile.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestMetadata.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestReader.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestSchemaUtility.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionAttribute.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionUtility.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PackageBuilder.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PackageDependencySet.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PackageIdValidator.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PackageMetadataXmlExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PackageReferenceSet.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PathResolver.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PathUtility.cs delete mode 100644 src/dotnet/commands/dotnet-pack/NuGet/PhysicalPackageFile.cs rename src/dotnet/commands/{dotnet-pack3/Pack3Command.cs => dotnet-pack/PackCommand.cs} (96%) delete mode 100644 src/dotnet/commands/dotnet-pack/PackageGenerator.cs delete mode 100644 src/dotnet/commands/dotnet-pack/PackagesGenerator.cs delete mode 100644 src/dotnet/commands/dotnet-pack/Program.cs delete mode 100644 src/dotnet/commands/dotnet-pack/Properties/launchSettings.json delete mode 100644 src/dotnet/commands/dotnet-pack/README.md delete mode 100644 src/dotnet/commands/dotnet-pack/SymbolPackageGenerator.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/ConnectionContext.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Helpers/DependencyTypeChangeFinder.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Helpers/JTokenExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Helpers/NuGetFrameworkExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Helpers/ProjectExtensions.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectContextSnapshot.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectSnapshot.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/MessageTypes.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/CompilerOptionsMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependenciesMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependencyDiagnosticsMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/GlobalErrorMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/Messenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectDiagnosticsMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectInformationMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/ReferencesMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Messengers/SourcesMessenger.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyItem.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageGroup.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageView.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticsListMessage.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/ErrorMessage.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/FrameworkData.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/Message.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/ProcessingQueue.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/Program.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/ProjectManager.cs delete mode 100644 src/dotnet/commands/dotnet-projectmodel-server/ProtocolManager.cs delete mode 100644 src/dotnet/commands/dotnet-publish/README.md delete mode 100644 src/dotnet/commands/dotnet-publish3/Program.cs delete mode 100644 src/dotnet/commands/dotnet-publish3/Publish3Command.cs delete mode 100644 src/dotnet/commands/dotnet-repl-csi/Program.cs delete mode 100644 src/dotnet/commands/dotnet-repl/Program.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/Program.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/ResgenCommand.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/ResourceAssemblyGenerator.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/ResourceFile.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/ResourceFileType.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/ResourceSource.cs delete mode 100644 src/dotnet/commands/dotnet-resgen/ResourcesFileGenerator.cs rename src/dotnet/commands/{dotnet-restore => dotnet-restore-projectjson}/NuGet3.cs (95%) create mode 100644 src/dotnet/commands/dotnet-restore-projectjson/Program.cs rename src/dotnet/commands/{dotnet-restore => dotnet-restore-projectjson}/README.md (100%) delete mode 100644 src/dotnet/commands/dotnet-restore3/Program.cs delete mode 100644 src/dotnet/commands/dotnet-run/README.md delete mode 100644 src/dotnet/commands/dotnet-run3/Program.cs delete mode 100644 src/dotnet/commands/dotnet-run3/Run3Command.cs rename src/dotnet/commands/{dotnet-test3 => dotnet-test}/Program.cs (97%) delete mode 100644 test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectDependencyCommandResolverBeingUsedWithMSBuild.cs delete mode 100644 test/Microsoft.DotNet.Compiler.Common.Tests/GivenCommonCompilerOptions.cs delete mode 100644 test/Microsoft.DotNet.Compiler.Common.Tests/GivenThatICopyLibraryAssets.cs delete mode 100644 test/Microsoft.DotNet.Compiler.Common.Tests/Microsoft.DotNet.Compiler.Common.Tests.xproj delete mode 100644 test/Microsoft.DotNet.Compiler.Common.Tests/project.json delete mode 100644 test/Microsoft.DotNet.ProjectModel.Loader.Tests/Microsoft.DotNet.ProjectModel.Loader.Tests.xproj delete mode 100644 test/Microsoft.DotNet.ProjectModel.Loader.Tests/ProjectLoadContextTest.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Loader.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Loader.Tests/project.json delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/FileAbstractionsTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/FunctionalTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternContexts/PatternContextLinearTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternContexts/PatternContextRaggedTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternMatchingTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternSegments/CurrentPathSegmentTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternSegments/LiteralPathSegmentTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternSegments/ParentPathSegmentTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternSegments/RecursiveWildcardSegmentTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/PatternSegments/WildcardPathSegmentTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/Patterns/PatternTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/DisposableFileSystem.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/FileSystemGlobbingTestContext.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/FileSystemOperationRecorder.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/MockDirectoryInfo.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/MockFileInfoStub.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/MockLinearPatternBuilder.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/MockNonRecursivePathSegment.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/MockRaggedPatternBuilder.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/MockRecursivePathSegment.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/FileSystemGlobbing/TestUtility/PatternContextHelper.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/GivenThatIWantToCreateFileCollectionsFromJson.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/GivenThatIWantToCreateIncludeEntriesFromJson.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/GivenThatIWantToLoadAProjectJsonFile.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/GivenThatIWantToReadFilePatternsFromJson.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/GivenThatIWantToReadGlobalSettingsFromJson.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/GivenThatIWantToReadNamedResources.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/LibraryExporterPackageTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/LibraryExporterTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/LockFilePatchingTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/Microsoft.DotNet.ProjectModel.Tests.xproj delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/PreprocessorTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/ProjectContextBuilderTests.cs delete mode 100644 test/Microsoft.DotNet.ProjectModel.Tests/project.json create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.cs delete mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Build3Command.cs create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildPJCommand.cs rename test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/{Clean3Command.cs => CleanCommand.cs} (81%) delete mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Publish3Command.cs delete mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Restore3Command.cs rename test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/{Test3Command.cs => RestoreProjectJsonCommand.cs} (66%) delete mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Run3Command.cs create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommandExtensions.cs delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.Tests/GivenThatIWantToUseFullPdbsToFindMethodInformation.cs delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.Tests/GivenThatIWantToUsePortablePdbsToFindMethodInformation.cs delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.Tests/Microsoft.Extensions.Testing.Abstractions.Tests.xproj delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.Tests/project.json delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.UnitTests/GivenThatWeWantToUseSourceInformationProviderToGetSourceInformation.cs delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.UnitTests/Microsoft.Extensions.Testing.Abstractions.UnitTests.xproj delete mode 100644 test/TestingAbstractions/Microsoft.Extensions.Testing.Abstractions.UnitTests/project.json delete mode 100644 test/TestingAbstractions/TestAppWithFullPdbs/ClassForFullPdbs.cs delete mode 100644 test/TestingAbstractions/TestAppWithFullPdbs/TestAppWithFullPdbs.xproj delete mode 100644 test/TestingAbstractions/TestAppWithFullPdbs/project.json delete mode 100644 test/TestingAbstractions/TestAppWithPortablePdbs/ClassForPortablePdbs.cs delete mode 100644 test/TestingAbstractions/TestAppWithPortablePdbs/TestAppWithPortablePdbs.xproj delete mode 100644 test/TestingAbstractions/TestAppWithPortablePdbs/project.json rename test/{dotnet-build3.Tests/GivenDotnetBuild3BuildsCsproj.cs => dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs} (85%) rename test/{dotnet-build3.Tests/dotnet-build3.Tests.xproj => dotnet-build.Tests/dotnet-build.Tests.xproj} (100%) rename test/{dotnet-build3.Tests => dotnet-build.Tests}/project.json (100%) delete mode 100644 test/dotnet-compile.Tests/CompilerTests.cs delete mode 100644 test/dotnet-compile.Tests/dotnet-compile.Tests.xproj delete mode 100644 test/dotnet-compile.Tests/project.json delete mode 100644 test/dotnet-compile.UnitTests/BindingRedirectGeneratorTests.cs delete mode 100644 test/dotnet-compile.UnitTests/GivenACompilationDriver.cs delete mode 100644 test/dotnet-compile.UnitTests/GivenThatICareAboutScriptVariablesFromAManagedCompiler.cs delete mode 100644 test/dotnet-compile.UnitTests/dotnet-compile.UnitTests.xproj delete mode 100644 test/dotnet-compile.UnitTests/project.json delete mode 100644 test/dotnet-new.Tests/GivenThatIWantANewCSnUnitProject.cs delete mode 100644 test/dotnet-new.Tests/GivenThatIWantANewCSxUnitProject.cs rename test/{dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs => dotnet-publish.Tests/GivenDotnetPublishPublishesProjects.cs} (64%) delete mode 100644 test/dotnet-publish.Tests/PublishAppWithBuildDependency.cs delete mode 100644 test/dotnet-publish.Tests/PublishAppWithDependencies.cs delete mode 100644 test/dotnet-publish.Tests/PublishDesktopTests.cs delete mode 100644 test/dotnet-publish.Tests/PublishPortableTests.cs delete mode 100644 test/dotnet-publish.Tests/PublishStandaloneTests.cs delete mode 100644 test/dotnet-publish.Tests/PublishTests.cs delete mode 100644 test/dotnet-publish3.Tests/dotnet-publish3.Tests.xproj delete mode 100644 test/dotnet-publish3.Tests/project.json delete mode 100644 test/dotnet-resgen.Tests/Microsoft.DotNet.Tools.Resgen.Tests.cs delete mode 100644 test/dotnet-resgen.Tests/dotnet-resgen.Tests.xproj delete mode 100644 test/dotnet-resgen.Tests/project.json create mode 100644 test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs delete mode 100644 test/dotnet-run.Tests/RunTests.cs delete mode 100644 test/dotnet-run.Tests/dotnet-run.Tests.xproj delete mode 100644 test/dotnet-run.UnitTests/GivenARunCommand.cs delete mode 100644 test/dotnet-run.UnitTests/dotnet-run.UnitTests.xproj delete mode 100644 test/dotnet-run.UnitTests/project.json delete mode 100644 test/dotnet-run3.Tests/GivenDotnetRun3RunsCsProj.cs delete mode 100644 test/dotnet-run3.Tests/dotnet-run3.Tests.xproj delete mode 100644 test/dotnet-run3.Tests/project.json delete mode 100644 test/dotnet-test.Tests/Adapter.cs delete mode 100644 test/dotnet-test.Tests/AssemblyInfo.cs rename test/{dotnet-test3.Tests/GivenDotnetTest3BuildsAndRunsTestfromCsproj.cs => dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs} (75%) delete mode 100644 test/dotnet-test.Tests/GivenThatWeWantToRunTests.cs delete mode 100644 test/dotnet-test.Tests/GivenThatWeWantToRunTestsForMultipleTFMsInTheConsole.cs delete mode 100644 test/dotnet-test.Tests/GivenThatWeWantToRunTestsInTheConsole.cs delete mode 100644 test/dotnet-test.Tests/GivenThatWeWantToUseDotnetTestE2EInDesignTime.cs delete mode 100644 test/dotnet-test.Tests/GivenThatWeWantToUseDotnetTestE2EInDesignTimeForMultipleTFms.cs delete mode 100644 test/dotnet-test.UnitTests/DotnetTestMessageScenario.cs delete mode 100644 test/dotnet-test.UnitTests/GivenADiscoverTestsArgumentsBuilder.cs delete mode 100644 test/dotnet-test.UnitTests/GivenADotnetTestApp.cs delete mode 100644 test/dotnet-test.UnitTests/GivenAParameterTestRunnerNameResolver.cs delete mode 100644 test/dotnet-test.UnitTests/GivenAProjectJsonTestRunnerNameResolver.cs delete mode 100644 test/dotnet-test.UnitTests/GivenARunTestsArgumentsBuilder.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestCommand.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestDiscoveryStartMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestExecutionGetTestRunnerProcessStartInfoMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunner.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunnerNameResolverFactoryAndADotnetTestParams.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunnerTestCompletedMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunnerTestFoundMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunnerTestResultMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunnerTestStartedMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestRunnerWaitingCommandMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenATestSessionTerminateMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenAUnknownMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenAVersionCheckMessageHandler.cs delete mode 100644 test/dotnet-test.UnitTests/GivenAnAssemblyTestRunnerNameResolver.cs delete mode 100644 test/dotnet-test.UnitTests/GivenThatWeWantToDiscoverTests.cs delete mode 100644 test/dotnet-test.UnitTests/GivenThatWeWantToParseArgumentsForDotnetTest.cs delete mode 100644 test/dotnet-test.UnitTests/GivenThatWeWantToRunTests.cs delete mode 100644 test/dotnet-test.UnitTests/dotnet-test.UnitTests.xproj delete mode 100644 test/dotnet-test.UnitTests/project.json delete mode 100644 test/dotnet-test3.Tests/dotnet-test3.Tests.xproj delete mode 100644 test/dotnet-test3.Tests/project.json diff --git a/.cliversion b/.cliversion index a0f9a4b4b..70482ffac 100644 --- a/.cliversion +++ b/.cliversion @@ -1 +1 @@ -latest +1.0.0-preview3-003930 diff --git a/.gitignore b/.gitignore index 9af9fe15f..27def2cb6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ # Multicore JIT Optimization profiles **/optimizationdata/dotnet +# Test Asset Manager files +.tam/ + # NuGet keeps dropping Library/ diff --git a/TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/project.json b/TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/project.json deleted file mode 100644 index 699fa2cc3..000000000 --- a/TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "dotnet-desktop-and-portable": "1.0.0-*" - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - }, - "imports": [ - "portable-net45+win8", - "dnxcore50" - ] - }, - "net451": {} - }, - "tools": { - "dotnet-dependency-tool-invoker": { - "version": "1.0.0-*", - "imports": [ - "dnxcore50", - "portable-net45+win8" - ] - } - } -} diff --git a/TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/.noautobuild b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/.noautobuild similarity index 100% rename from TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/.noautobuild rename to TestAssets/DesktopTestProjects/AppWithProjTool2Fx/.noautobuild diff --git a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj new file mode 100644 index 000000000..110929efb --- /dev/null +++ b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj @@ -0,0 +1,47 @@ + + + + + netcoreapp1.0;net451 + Exe + $(PackageTargetFallback);portable-net45+win8;dnxcore50 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.0-* + + + + + 1.0.1 + + + + + + + + + 1.0.0-* + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NET451 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/Program.cs b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/Program.cs similarity index 100% rename from TestAssets/DesktopTestProjects/AppWithDirectDepDesktopAndPortable/Program.cs rename to TestAssets/DesktopTestProjects/AppWithProjTool2Fx/Program.cs diff --git a/TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/.noautobuild b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/.noautobuild similarity index 100% rename from TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/.noautobuild rename to TestAssets/DesktopTestProjects/LibWithProjTool2Fx/.noautobuild diff --git a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj new file mode 100644 index 000000000..cecdf152a --- /dev/null +++ b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj @@ -0,0 +1,47 @@ + + + + + netstandard1.6;net451 + Library + $(PackageTargetFallback);portable-net45+win8;dnxcore50;netcoreapp1.0 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.0-* + + + + + 1.6.0 + + + + + + + + + 1.0.0-* + + + + $(DefineConstants);NETSTANDARD1_6 + + + $(DefineConstants);NET451 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/Program.cs b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Program.cs similarity index 100% rename from TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/Program.cs rename to TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Program.cs diff --git a/TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/project.json b/TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/project.json deleted file mode 100644 index 1d8d8a92c..000000000 --- a/TestAssets/DesktopTestProjects/LibraryWithDirectDependencyDesktopAndPortable/project.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": false - }, - "dependencies": { - "dotnet-desktop-and-portable": "1.0.0-*" - }, - "frameworks": { - "netstandard1.6": { - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - "imports": [ - "portable-net45+win8", - "dnxcore50", - "netcoreapp1.0" - ] - }, - "net451": {} - }, - "tools": { - "dotnet-dependency-tool-invoker": { - "version": "1.0.0-*", - "imports": [ - "dnxcore50", - "portable-net45+win8" - ] - } - } -} diff --git a/TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/TestProjectWithUnresolvedPlatformDependency.csproj b/TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/TestProjectWithUnresolvedPlatformDependency.csproj new file mode 100755 index 000000000..0983f08f8 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/TestProjectWithUnresolvedPlatformDependency.csproj @@ -0,0 +1,30 @@ + + + + + netcoreapp1.0 + Exe + $(PackageTargetFallback);dnxcore50 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/project.json b/TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/project.json deleted file mode 100644 index 555dd25f4..000000000 --- a/TestAssets/NonRestoredTestProjects/TestProjectWithUnresolvedPlatformDependency/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "ThisIsNotARealDependencyAndIfSomeoneGoesAndAddsAProjectWithThisNameIWillFindThemAndPunishThem": { - "type": "platform", - "version": "1.0.0" - } - }, - "frameworks": { - "netcoreapp1.0": { - "imports": "dnxcore50" - } - } -} diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs index 9db2e07b3..17b66d125 100644 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs +++ b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs @@ -2,7 +2,6 @@ using System.IO; using System.Collections.Generic; using System.Linq; -using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.Cli.Utils; using NuGet.Frameworks; @@ -24,13 +23,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker return 1; } - - var projectContexts = - CreateProjectContexts(dotnetParams.ProjectPath) - .Where(p => dotnetParams.Framework == null || - dotnetParams.Framework.GetShortFolderName() - .Equals(p.TargetFramework.GetShortFolderName())); - + var commandFactory = new ProjectDependenciesCommandFactory( dotnetParams.Framework, @@ -39,15 +32,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker dotnetParams.BuildBasePath, dotnetParams.ProjectPath); - var result = 0; - if(projectContexts.Any()) - { - result = InvokeDependencyToolForProjectJson(projectContexts, commandFactory, dotnetParams); - } - else - { - result = InvokeDependencyToolForMSBuild(commandFactory, dotnetParams); - } + var result = InvokeDependencyToolForMSBuild(commandFactory, dotnetParams); return result; } @@ -61,24 +46,6 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker return InvokeDependencyTool(commandFactory, dotnetParams, dotnetParams.Framework); } - private static int InvokeDependencyToolForProjectJson( - IEnumerable projectContexts, - ProjectDependenciesCommandFactory commandFactory, - DotnetBaseParams dotnetParams) - { - foreach (var projectContext in projectContexts) - { - Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{projectContext.TargetFramework}'."); - - if (InvokeDependencyTool(commandFactory, dotnetParams, projectContext.TargetFramework) != 0) - { - return 1; - } - } - - return 0; - } - private static int InvokeDependencyTool( ProjectDependenciesCommandFactory commandFactory, DotnetBaseParams dotnetParams, @@ -106,22 +73,5 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker return 0; } - - private static IEnumerable CreateProjectContexts(string projectPath = null) - { - projectPath = projectPath ?? Directory.GetCurrentDirectory(); - - if (!projectPath.EndsWith(Project.FileName)) - { - projectPath = Path.Combine(projectPath, Project.FileName); - } - - if (!File.Exists(projectPath)) - { - return Enumerable.Empty(); - } - - return ProjectContext.CreateContextForEachFramework(projectPath); - } } } diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/project.json b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/project.json index 5540f2d1d..1297d1b12 100644 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/project.json +++ b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/project.json @@ -17,12 +17,6 @@ "Microsoft.DotNet.Cli.Utils": { "target": "project" }, - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "Microsoft.DotNet.Compiler.Common": { - "target": "project" - }, "NuGet.Frameworks": "3.6.0-rc-1984" }, "frameworks": { diff --git a/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj new file mode 100755 index 000000000..0c47bdf3f --- /dev/null +++ b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj @@ -0,0 +1,34 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + + 1.0.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/NuGet.Config b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/project.json b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/project.json deleted file mode 100644 index d514ca588..000000000 --- a/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.1", - "type": "platform" - } - }, - "frameworks": { - "netcoreapp1.0": {} - }, - "tools": { - "ToolWithOutputName": { - "version": "1.0.0", - "target": "package" - } - } -} diff --git a/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj b/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj new file mode 100755 index 000000000..f37b2dba6 --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj @@ -0,0 +1,37 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + 1.0.0 + + + + + 1.0.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithDirectAndToolDep/NuGet.Config b/TestAssets/TestProjects/AppWithDirectAndToolDep/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectAndToolDep/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/AppWithDirectAndToolDep/project.json b/TestAssets/TestProjects/AppWithDirectAndToolDep/project.json deleted file mode 100644 index 403ebe73d..000000000 --- a/TestAssets/TestProjects/AppWithDirectAndToolDep/project.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.NETCore.App": "1.0.1", - "dotnet-hello": { - "version": "1.0.0", - "target": "package" - } - }, - "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": {} - }, - "tools": { - "dotnet-portable": { - "version": "1.0.0", - "target": "package" - } - } -} diff --git a/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj b/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj new file mode 100755 index 000000000..87e79722c --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj @@ -0,0 +1,39 @@ + + + + + 1.0.0 + netcoreapp1.0 + AppWithDirectDep + Exe + false + + + + 1.0.1 + + + 1.0.0 + + + + + + + + 1.0.0-alpha-20161012-3 + All + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);DEBUG;TRACE + + + $(DefineConstants);RELEASE;TRACE + true + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithDirectDep/NuGet.Config b/TestAssets/TestProjects/AppWithDirectDep/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectDep/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/AppWithDirectDep/project.json b/TestAssets/TestProjects/AppWithDirectDep/project.json deleted file mode 100644 index f18b8124b..000000000 --- a/TestAssets/TestProjects/AppWithDirectDep/project.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.NETCore.App": "1.0.1", - "dotnet-hello": { - "version": "1.0.0", - "target": "package" - } - }, - "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/TestProjects/AppWithDirectDepAndTypeBuild/NuGet.Config b/TestAssets/TestProjects/AppWithDirectDepAndTypeBuild/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectDepAndTypeBuild/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj new file mode 100755 index 000000000..a1803c769 --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj @@ -0,0 +1,37 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.0 + + + 1.0.1 + + + + + 1.0.0-* + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config new file mode 100644 index 000000000..4da396ac8 --- /dev/null +++ b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/project.json b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/project.json deleted file mode 100644 index 4d050093e..000000000 --- a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/project.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "ToolWithOutputName": { - "version": "1.0.0", - "target": "package" - }, - "Microsoft.NETCore.App": { - "version": "1.0.1", - "type": "platform" - } - }, - "frameworks": { - "netcoreapp1.0": {} - }, - "tools": { - "dotnet-dependency-tool-invoker": { - "version": "1.0.0-*", - "imports": [ - "dnxcore50", - "portable-net45+win8" - ] - } - } -} diff --git a/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj b/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj new file mode 100644 index 000000000..a7fad9b20 --- /dev/null +++ b/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj @@ -0,0 +1,37 @@ + + + + + + Exe + net451;netcoreapp1.0 + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.0-* + + + + + 1.0.1 + + + + + + 1.0.0-* + + + + + + + + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithMultipleFxAndTools/NuGet.Config b/TestAssets/TestProjects/AppWithMultipleFxAndTools/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/AppWithMultipleFxAndTools/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/Program.cs b/TestAssets/TestProjects/AppWithMultipleFxAndTools/Program.cs similarity index 100% rename from TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/Program.cs rename to TestAssets/TestProjects/AppWithMultipleFxAndTools/Program.cs diff --git a/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj b/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj new file mode 100755 index 000000000..28f991567 --- /dev/null +++ b/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj @@ -0,0 +1,34 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + + 1.0.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj new file mode 100755 index 000000000..7b91a326c --- /dev/null +++ b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj @@ -0,0 +1,42 @@ + + + + + 1.0.0 + netcoreapp1.0 + DependencyContextFromTool + Exe + false + $(PackageTargetFallback);dnxcore50;portable-net45+win8 + + + + + + + 1.0.0-alpha-20161012-3 + All + + + + + 1.0.1 + + + + + 1.0.0-* + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);DEBUG;TRACE + + + $(DefineConstants);RELEASE;TRACE + true + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config b/TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/DependencyContextFromTool/project.json b/TestAssets/TestProjects/DependencyContextFromTool/project.json deleted file mode 100644 index cbc889a43..000000000 --- a/TestAssets/TestProjects/DependencyContextFromTool/project.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": {}, - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dnxcore50", - "portable-net45+win8" - ], - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - } - }, - "tools": { - "dotnet-dependency-context-test": { - "version": "1.0.0-*", - "imports": [ - "dnxcore50" - ] - } - } -} diff --git a/TestAssets/TestProjects/LibraryWithOutputAssemblyName/MyLibrary.csproj b/TestAssets/TestProjects/LibraryWithOutputAssemblyName/MyLibrary.csproj new file mode 100755 index 000000000..f32fd4d2e --- /dev/null +++ b/TestAssets/TestProjects/LibraryWithOutputAssemblyName/MyLibrary.csproj @@ -0,0 +1,28 @@ + + + + + netstandard1.5 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.6.0 + + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/LibraryWithOutputAssemblyName/project.json b/TestAssets/TestProjects/LibraryWithOutputAssemblyName/project.json deleted file mode 100644 index c2d11ff89..000000000 --- a/TestAssets/TestProjects/LibraryWithOutputAssemblyName/project.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "buildOptions": { - "outputName": "MyLibrary" - }, - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - "frameworks": { - "netstandard1.5": {} - } -} diff --git a/TestAssets/TestProjects/PJTestAppSimple/Program.cs b/TestAssets/TestProjects/PJTestAppSimple/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/TestProjects/PJTestAppSimple/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/TestProjects/AppWithToolDependency/project.json b/TestAssets/TestProjects/PJTestAppSimple/project.json old mode 100644 new mode 100755 similarity index 81% rename from TestAssets/TestProjects/AppWithToolDependency/project.json rename to TestAssets/TestProjects/PJTestAppSimple/project.json index 61268b24e..5f8329deb --- a/TestAssets/TestProjects/AppWithToolDependency/project.json +++ b/TestAssets/TestProjects/PJTestAppSimple/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true @@ -9,12 +9,6 @@ "frameworks": { "netcoreapp1.0": {} }, - "tools": { - "dotnet-portable": { - "version": "1.0.0", - "target": "package" - } - }, "runtimes": { "win7-x64": {}, "win7-x86": {}, @@ -28,4 +22,4 @@ "fedora.23-x64": {}, "opensuse.13.2-x64": {} } -} +} \ No newline at end of file diff --git a/TestAssets/TestProjects/PJTestLibraryWithConfiguration/.noautobuild b/TestAssets/TestProjects/PJTestLibraryWithConfiguration/.noautobuild new file mode 100644 index 000000000..e69de29bb diff --git a/TestAssets/TestProjects/PJTestLibraryWithConfiguration/Helper.cs b/TestAssets/TestProjects/PJTestLibraryWithConfiguration/Helper.cs new file mode 100644 index 000000000..8c643796b --- /dev/null +++ b/TestAssets/TestProjects/PJTestLibraryWithConfiguration/Helper.cs @@ -0,0 +1,24 @@ +// 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; + +namespace TestLibrary +{ + public static class Helper + { + /// + /// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it. + /// + /// A message + public static string GetMessage() + { + return "This string came from the test library!"; + } + + public static void SayHi() + { + Console.WriteLine("Hello there!"); + } + } +} diff --git a/TestAssets/TestProjects/TestLibraryWithConfiguration/project.json b/TestAssets/TestProjects/PJTestLibraryWithConfiguration/project.json old mode 100644 new mode 100755 similarity index 98% rename from TestAssets/TestProjects/TestLibraryWithConfiguration/project.json rename to TestAssets/TestProjects/PJTestLibraryWithConfiguration/project.json index d979400d2..23c4b5057 --- a/TestAssets/TestProjects/TestLibraryWithConfiguration/project.json +++ b/TestAssets/TestProjects/PJTestLibraryWithConfiguration/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "buildOptions": { "nowarn": [ @@ -18,4 +18,4 @@ "frameworks": { "netstandard1.5": {} } -} +} \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/SingleTargetApp.csproj b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/SingleTargetApp.csproj new file mode 100755 index 000000000..9fa2cfbb5 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/SingleTargetApp.csproj @@ -0,0 +1,29 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/project.json b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/project.json deleted file mode 100644 index 6b8b96058..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetApp/project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - }, - "frameworks": { - "netcoreapp1.0": {} - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/SingleTargetP0.csproj b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/SingleTargetP0.csproj new file mode 100755 index 000000000..4a2c908b0 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/SingleTargetP0.csproj @@ -0,0 +1,32 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/project.json b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/project.json deleted file mode 100644 index cb916d694..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP0/project.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "SingleTargetP1": { - "target": "project" - }, - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - }, - "frameworks": { - "netcoreapp1.0": {} - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/SingleTargetP1.csproj b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/SingleTargetP1.csproj new file mode 100755 index 000000000..8023a259e --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/SingleTargetP1.csproj @@ -0,0 +1,31 @@ + + + + + netcoreapp1.0 + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/project.json b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/project.json deleted file mode 100644 index 2b9ba42f4..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP1/project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "SingleTargetP2": { - "target": "project" - }, - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - }, - "frameworks": { - "netcoreapp1.0": {} - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/SingleTargetP2.csproj b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/SingleTargetP2.csproj new file mode 100755 index 000000000..eb9a36f2a --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/SingleTargetP2.csproj @@ -0,0 +1,28 @@ + + + + + netcoreapp1.0 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/project.json b/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/project.json deleted file mode 100644 index 2f496524b..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/SingleTargetGraph/SingleTargetP2/project.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - }, - "frameworks": { - "netcoreapp1.0": {} - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/TwoTargetApp.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/TwoTargetApp.csproj new file mode 100755 index 000000000..fd24d6330 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/TwoTargetApp.csproj @@ -0,0 +1,42 @@ + + + + + netcoreapp1.0;netstandard1.6 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + 1.0.4 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_6 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/project.json deleted file mode 100644 index 300a13690..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetApp/project.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": {}, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.6": { - "dependencies": { - "NETStandard.Library": "1.6.0", - "Microsoft.NETCore.Runtime.CoreCLR": "1.0.4" - } - } - }, - "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/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/TwoTargetP0.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/TwoTargetP0.csproj new file mode 100755 index 000000000..b122fd66d --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/TwoTargetP0.csproj @@ -0,0 +1,45 @@ + + + + + netcoreapp1.0;netstandard1.6 + Exe + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + 1.0.4 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_6 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/project.json deleted file mode 100644 index 13516bc65..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP0/project.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "TwoTargetP1": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.6": { - "dependencies": { - "NETStandard.Library": "1.6.0", - "Microsoft.NETCore.Runtime.CoreCLR": "1.0.4" - } - } - }, - "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/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/TwoTargetP1.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/TwoTargetP1.csproj new file mode 100755 index 000000000..3419f1079 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/TwoTargetP1.csproj @@ -0,0 +1,41 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/project.json deleted file mode 100644 index 0cfbc0831..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP1/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "TwoTargetP2": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/TwoTargetP2.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/TwoTargetP2.csproj new file mode 100755 index 000000000..cab6d299d --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/TwoTargetP2.csproj @@ -0,0 +1,38 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/project.json deleted file mode 100644 index 2f0604e40..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraph/TwoTargetP2/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": {}, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/TwoTargetLargeP0.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/TwoTargetLargeP0.csproj new file mode 100755 index 000000000..27bd030ab --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/TwoTargetLargeP0.csproj @@ -0,0 +1,45 @@ + + + + + netcoreapp1.0;netstandard1.6 + Exe + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + 1.0.4 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_6 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/project.json deleted file mode 100644 index 3d60903c8..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP0/project.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "TwoTargetLargeP1": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.6": { - "dependencies": { - "NETStandard.Library": "1.6.0", - "Microsoft.NETCore.Runtime.CoreCLR": "1.0.4" - } - } - }, - "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/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/TwoTargetLargeP1.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/TwoTargetLargeP1.csproj new file mode 100755 index 000000000..2e21d189f --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/TwoTargetLargeP1.csproj @@ -0,0 +1,42 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/project.json deleted file mode 100644 index 948c96804..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP1/project.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "TwoTargetLargeP2": { - "target": "project" - }, - "TwoTargetLargeP4": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/TwoTargetLargeP2.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/TwoTargetLargeP2.csproj new file mode 100755 index 000000000..60e434ad8 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/TwoTargetLargeP2.csproj @@ -0,0 +1,42 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/project.json deleted file mode 100644 index cbb339ed3..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP2/project.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "TwoTargetLargeP3": { - "target": "project" - }, - "TwoTargetLargeP4": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/TwoTargetLargeP3.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/TwoTargetLargeP3.csproj new file mode 100755 index 000000000..9fed861a4 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/TwoTargetLargeP3.csproj @@ -0,0 +1,41 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/project.json deleted file mode 100644 index e43f21551..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP3/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "TwoTargetLargeP4": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/TwoTargetLargeP4.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/TwoTargetLargeP4.csproj new file mode 100755 index 000000000..d0adfb1b1 --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/TwoTargetLargeP4.csproj @@ -0,0 +1,42 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/project.json deleted file mode 100644 index 4e413c82b..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP4/project.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "TwoTargetLargeP5": { - "target": "project" - }, - "TwoTargetLargeP6": { - "target": "project" - } - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/TwoTargetLargeP5.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/TwoTargetLargeP5.csproj new file mode 100755 index 000000000..cab6d299d --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/TwoTargetLargeP5.csproj @@ -0,0 +1,38 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/project.json deleted file mode 100644 index 2f0604e40..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP5/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": {}, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/TwoTargetLargeP6.csproj b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/TwoTargetLargeP6.csproj new file mode 100755 index 000000000..cab6d299d --- /dev/null +++ b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/TwoTargetLargeP6.csproj @@ -0,0 +1,38 @@ + + + + + netcoreapp1.0;netstandard1.5 + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + + + 1.0.1 + + + + + 1.6.0 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/project.json b/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/project.json deleted file mode 100644 index 2f0604e40..000000000 --- a/TestAssets/TestProjects/PerformanceTestProjects/TwoTargetGraphLarge/TwoTargetLargeP6/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": {}, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - } - }, - "netstandard1.5": { - "dependencies": { - "NETStandard.Library": "1.6.0" - } - } - } -} diff --git a/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj b/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj new file mode 100755 index 000000000..9fa2cfbb5 --- /dev/null +++ b/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj @@ -0,0 +1,29 @@ + + + + + netcoreapp1.0 + Exe + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.0.1 + + + + $(DefineConstants);NETCOREAPP1_0 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config b/TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config new file mode 100644 index 000000000..b8e876fcb --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestAssets/TestProjects/MSBuildTestAppWithToolInDependencies/Program.cs b/TestAssets/TestProjects/TestAppWithProjDepTool/Program.cs similarity index 100% rename from TestAssets/TestProjects/MSBuildTestAppWithToolInDependencies/Program.cs rename to TestAssets/TestProjects/TestAppWithProjDepTool/Program.cs diff --git a/TestAssets/TestProjects/MSBuildTestAppWithToolInDependencies/MSBuildTestAppWithToolInDependencies.csproj b/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj similarity index 100% rename from TestAssets/TestProjects/MSBuildTestAppWithToolInDependencies/MSBuildTestAppWithToolInDependencies.csproj rename to TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj diff --git a/TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs b/TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs new file mode 100644 index 000000000..dcdd3eaa1 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hélló Wórld!"); + } + } +} diff --git a/TestAssets/TestProjects/TestAppSimple/project.json b/TestAssets/TestProjects/TestAppWithUnicodéPath/project.json similarity index 100% rename from TestAssets/TestProjects/TestAppSimple/project.json rename to TestAssets/TestProjects/TestAppWithUnicodéPath/project.json diff --git a/TestAssets/TestProjects/TestLibraryWithConfiguration/TestLibraryWithConfiguration.csproj b/TestAssets/TestProjects/TestLibraryWithConfiguration/TestLibraryWithConfiguration.csproj new file mode 100755 index 000000000..c69ce99dd --- /dev/null +++ b/TestAssets/TestProjects/TestLibraryWithConfiguration/TestLibraryWithConfiguration.csproj @@ -0,0 +1,31 @@ + + + + + netstandard1.5 + $(NoWarn);CS1591 + true + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml + + + + + + + + + 1.0.0-alpha-20161019-1 + All + + + 1.6.0 + + + + $(DefineConstants);NETSTANDARD1_5 + + + $(DefineConstants);RELEASE + + + \ No newline at end of file diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index 037253813..d80737214 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -41,7 +41,7 @@ @(CompileStageInputs) $(Stage2Directory) $(Stage2SymbolsDirectory) - $(Stage1Directory) + $(Stage0Directory) diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index d5311419d..22a03036f 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -188,6 +188,7 @@ Outputs="@(RestorePackagesInput->'%(RelativeDir)/project.lock.json')"> + diff --git a/build/Microsoft.DotNet.Cli.Test.targets b/build/Microsoft.DotNet.Cli.Test.targets index b8de69a9c..45d6db400 100644 --- a/build/Microsoft.DotNet.Cli.Test.targets +++ b/build/Microsoft.DotNet.Cli.Test.targets @@ -39,7 +39,7 @@ EnvironmentVariables=$(RunTestEnvironmentVariables); TestProjectName=%(TestProjects.OutputName); TestResultXmlDir=$(TestResultXmlDir); - ToolPath=$(Stage2Directory); + ToolPath=$(Stage0Directory); WorkingDirectory=%(TestProjects.ProjectDir) @@ -55,7 +55,7 @@ DependsOnTargets="Init"> $(CommitCount) - $(BaseOutputDirectory)/tests/ + $(RepoRoot)/artifacts/testpackages/ $(TestOutputDir)/packagesBuild/ $(TestOutputDir)/packages/ $(TestOutputDir)/artifacts/ @@ -72,7 +72,7 @@ Outputs="%(TestProjects.BuildOutput)"> @@ -84,9 +84,9 @@ Outputs="@(RestoreTestsInputs->'%(RelativeDir)project.lock.json')"> - + @@ -136,9 +136,9 @@ Inputs="@(RestoreTestAssetProjectsInputs)" Outputs="@(RestoreTestAssetProjectsInputs->'%(RelativeDir)/project.lock.json')"> - + @@ -177,7 +177,7 @@ @@ -188,9 +188,9 @@ Inputs="@(RestoreDesktopTestAssetProjectsInputs)" Outputs="@(RestoreDesktopTestAssetProjectsInputs->'%(RelativeDir)/project.lock.json')"> - + @@ -209,7 +209,7 @@ NoBuild="True" Output="$(TestPackagesDir)" ProjectPath="%(TestPackageProject.FullPath)" - ToolPath="$(DotnetUnderTest)" + ToolPath="$(Stage0Directory)" VersionSuffix="%(TestPackageProject.VersionSuffix)" /> @@ -222,7 +222,7 @@ @@ -232,8 +232,8 @@ Inputs="@(RestoreTestAssetPackageProjectsInputs)" Outputs="@(RestoreTestAssetPackageProjectsInputs->'%(RelativeDir)/project.lock.json')"> - + - + diff --git a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets index 056d0e6ee..eb048d8a2 100644 --- a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets +++ b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets @@ -16,7 +16,7 @@ - @@ -25,7 +25,7 @@ - diff --git a/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj b/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj index 0c13f7029..a14369b3e 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj +++ b/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj @@ -49,7 +49,7 @@ ReplacementStrings="@(DebianConfigTokenValues -> '%(ReplacementString)')" /> - @@ -135,9 +135,9 @@ - + + -DotnetDir '$(Stage0Directory)'" /> Microsoft.DotNet.Cli.Utils $(SdkNugetVersion) - - Microsoft.DotNet.Compiler.Common - $(SdkNugetVersion) - - - Microsoft.DotNet.Files - $(SdkNugetVersion) - Microsoft.DotNet.InternalAbstractions $(DependencyModelAndInternalAbstractionsNugetVersion) - - Microsoft.DotNet.ProjectModel - $(ProjectModelNugetVersion) - - - Microsoft.DotNet.ProjectModel.Loader - $(SdkNugetVersion) - - - Microsoft.DotNet.ProjectModel.Workspaces - $(SdkNugetVersion) - - - Microsoft.Extensions.Testing.Abstractions - $(SdkNugetVersion) - - - Microsoft.DotNet.Tools.Test - $(SdkNugetVersion) - Microsoft.DotNet.ProjectJsonMigration $(SdkNugetVersion) @@ -71,7 +43,7 @@ NoBuild="True" Output="$(NupkgOutputDirectory)" ProjectPath="%(ProjectsToPack.Identity)" - ToolPath="$(Stage2Directory)" + ToolPath="$(Stage0Directory)" VersionSuffix="$(NupkgVersionSuffix)" Configuration="$(Configuration)" /> @@ -82,7 +54,7 @@ Condition=" '$(OS)' == 'Windows_NT' "> - diff --git a/build/test/TestPackageProjects.targets b/build/test/TestPackageProjects.targets index a22571df6..ddf129f79 100644 --- a/build/test/TestPackageProjects.targets +++ b/build/test/TestPackageProjects.targets @@ -161,33 +161,6 @@ False netstandard1.5 - - Microsoft.DotNet.ProjectModel - True - True - 1.0.0-rc4- - $(TestPackageBuildVersionSuffix) - False - netstandard1.3 - - - Microsoft.DotNet.ProjectModel.Loader - True - True - 1.0.0-preview3- - $(TestPackageBuildVersionSuffix) - False - netstandard1.6 - - - Microsoft.DotNet.ProjectModel.Workspaces - True - True - 1.0.0-preview3- - $(TestPackageBuildVersionSuffix) - False - netstandard1.5 - Microsoft.DotNet.InternalAbstractions True @@ -197,33 +170,6 @@ False netstandard1.3 - - Microsoft.Extensions.Testing.Abstractions - True - True - 1.0.0-preview3- - $(TestPackageBuildVersionSuffix) - False - netstandard1.3 - - - Microsoft.DotNet.Compiler.Common - True - True - 1.0.0-preview3- - $(TestPackageBuildVersionSuffix) - False - netstandard1.5 - - - Microsoft.DotNet.Files - True - True - 1.0.0-preview3- - $(TestPackageBuildVersionSuffix) - False - netstandard1.5 - diff --git a/build_projects/dotnet-cli-build/DotNetRestore.cs b/build_projects/dotnet-cli-build/DotNetRestore.cs index 234bb5835..cb75d513a 100644 --- a/build_projects/dotnet-cli-build/DotNetRestore.cs +++ b/build_projects/dotnet-cli-build/DotNetRestore.cs @@ -12,20 +12,20 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetVerbosity()} {GetFallbackSource()} {GetPackages()}"; } + get { return $"{GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()}"; } } - public string FallbackSource { get; set; } + public string Source { get; set; } public string Packages { get; set; } - public string Verbosity { get; set; } + public bool SkipInvalidConfigurations { get; set; } - private string GetFallbackSource() + private string GetSource() { - if (!string.IsNullOrEmpty(FallbackSource)) + if (!string.IsNullOrEmpty(Source)) { - return $"--fallbacksource {FallbackSource}"; + return $"--source {Source}"; } return null; @@ -41,11 +41,11 @@ namespace Microsoft.DotNet.Cli.Build return null; } - private string GetVerbosity() + private string GetSkipInvalidConfigurations() { - if (!string.IsNullOrEmpty(Verbosity)) + if (SkipInvalidConfigurations) { - return $"--verbosity {Verbosity}"; + return "/p:SkipInvalidConfigurations=true"; } return null; diff --git a/build_projects/dotnet-cli-build/DotNetRestore3.cs b/build_projects/dotnet-cli-build/DotNetRestoreProjectJson.cs similarity index 56% rename from build_projects/dotnet-cli-build/DotNetRestore3.cs rename to build_projects/dotnet-cli-build/DotNetRestoreProjectJson.cs index 571ccc16e..d22982093 100644 --- a/build_projects/dotnet-cli-build/DotNetRestore3.cs +++ b/build_projects/dotnet-cli-build/DotNetRestoreProjectJson.cs @@ -3,29 +3,29 @@ namespace Microsoft.DotNet.Cli.Build { - public class DotNetRestore3 : DotNetTool + public class DotNetRestoreProjectJson : DotNetTool { protected override string Command { - get { return "restore3"; } + get { return "restore-projectjson"; } } protected override string Args { - get { return $"{GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()}"; } + get { return $"{GetVerbosity()} {GetFallbackSource()} {GetPackages()}"; } } - public string Source { get; set; } + public string FallbackSource { get; set; } public string Packages { get; set; } - public bool SkipInvalidConfigurations { get; set; } + public string Verbosity { get; set; } - private string GetSource() + private string GetFallbackSource() { - if (!string.IsNullOrEmpty(Source)) + if (!string.IsNullOrEmpty(FallbackSource)) { - return $"--source {Source}"; + return $"--fallbacksource {FallbackSource}"; } return null; @@ -41,11 +41,11 @@ namespace Microsoft.DotNet.Cli.Build return null; } - private string GetSkipInvalidConfigurations() + private string GetVerbosity() { - if (SkipInvalidConfigurations) + if (!string.IsNullOrEmpty(Verbosity)) { - return "/p:SkipInvalidConfigurations=true"; + return $"--verbosity {Verbosity}"; } return null; diff --git a/src/Microsoft.DotNet.Cli.Utils/Command.cs b/src/Microsoft.DotNet.Cli.Utils/Command.cs index 67cec543e..212f8e138 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Command.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Command.cs @@ -7,7 +7,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; -using Microsoft.DotNet.ProjectModel; using NuGet.Frameworks; namespace Microsoft.DotNet.Cli.Utils @@ -15,7 +14,9 @@ namespace Microsoft.DotNet.Cli.Utils public class Command : ICommand { private readonly Process _process; + private StreamForwarder _stdOut; + private StreamForwarder _stdErr; private bool _running = false; @@ -114,39 +115,20 @@ namespace Microsoft.DotNet.Cli.Utils return new Command(commandSpec); } - public static Command CreateForScript( - string commandName, - IEnumerable args, - Project project, - string[] inferredExtensionList) - { - var commandSpec = CommandResolver.TryResolveScriptCommandSpec(commandName, - args, - project, - inferredExtensionList); - - if (commandSpec == null) - { - throw new CommandUnknownException(commandName); - } - - var command = new Command(commandSpec); - - return command; - } - public CommandResult Execute() { Reporter.Verbose.WriteLine($"Running {_process.StartInfo.FileName} {_process.StartInfo.Arguments}"); ThrowIfRunning(); + _running = true; _process.EnableRaisingEvents = true; #if DEBUG var sw = Stopwatch.StartNew(); + Reporter.Verbose.WriteLine($"> {FormatProcessInfo(_process.StartInfo)}".White()); #endif using (PerfTrace.Current.CaptureTiming($"{Path.GetFileNameWithoutExtension(_process.StartInfo.FileName)} {_process.StartInfo.Arguments}")) diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandContext.cs b/src/Microsoft.DotNet.Cli.Utils/CommandContext.cs index 8209dd2f7..9913cde73 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandContext.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandContext.cs @@ -25,6 +25,11 @@ namespace Microsoft.DotNet.Cli.Utils public static bool ShouldPassAnsiCodesThrough() { return _ansiPassThru.Value; - } + } + + public static void SetVerbose(bool value) + { + _verbose = new Lazy(() => value); + } } } diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/AppBaseDllCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/AppBaseDllCommandResolver.cs index 50e2020a2..eb495c103 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/AppBaseDllCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/AppBaseDllCommandResolver.cs @@ -1,7 +1,6 @@ using System.IO; using System.Linq; using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel; namespace Microsoft.DotNet.Cli.Utils { diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonCommandResolver.cs index 6c67bd2b1..201a3eecd 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonCommandResolver.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel; + using Microsoft.Extensions.DependencyModel; namespace Microsoft.DotNet.Cli.Utils diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs index 206c0bcde..d0d43dc57 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs @@ -14,6 +14,8 @@ namespace Microsoft.DotNet.Cli.Utils string DepsJsonPath { get; } + string ProjectRoot { get; } + string RuntimeConfigJsonPath { get; } string FullOutputPath { get; } diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs index e1a81e787..8be1d4bd0 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs @@ -15,6 +15,8 @@ namespace Microsoft.DotNet.Cli.Utils { private Project _project; + private string _projectRoot; + private string _msBuildExePath; public string DepsJsonPath @@ -50,6 +52,14 @@ namespace Microsoft.DotNet.Cli.Utils } } + public string ProjectRoot + { + get + { + return _projectRoot; + } + } + public Dictionary EnvironmentVariables { get @@ -68,6 +78,8 @@ namespace Microsoft.DotNet.Cli.Utils string outputPath, string msBuildExePath) { + _projectRoot = msBuildExePath; + var globalProperties = new Dictionary() { { "MSBuildExtensionsPath", Path.GetDirectoryName(msBuildExePath) } diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/OutputPathCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/OutputPathCommandResolver.cs index cdf3aec58..33998f0e3 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/OutputPathCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/OutputPathCommandResolver.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; -using Microsoft.DotNet.InternalAbstractions; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Cli.Utils; using NuGet.Frameworks; namespace Microsoft.DotNet.Cli.Utils @@ -43,6 +42,7 @@ namespace Microsoft.DotNet.Cli.Utils string buildBasePath) { var projectFactory = new ProjectFactory(_environment); + var project = projectFactory.GetProject( projectDirectory, framework, diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs index bb12b14f1..18aefdebf 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.Tools.Common; using NuGet.Packaging; using NuGet.ProjectModel; @@ -21,12 +20,15 @@ namespace Microsoft.DotNet.Cli.Utils string depsFilePath, string runtimeConfigPath) { + Reporter.Verbose.WriteLine($"packagedcommandspecfactory: attempting to find command {commandName} in {toolLibrary.Name}"); var toolAssembly = toolLibrary?.RuntimeAssemblies .FirstOrDefault(r => Path.GetFileNameWithoutExtension(r.Path) == commandName); if (toolAssembly == null) { + Reporter.Verbose.WriteLine($"packagedcommandspecfactory: failed to find toolAssembly for {commandName}"); + return null; } @@ -34,6 +36,8 @@ namespace Microsoft.DotNet.Cli.Utils if (!File.Exists(commandPath)) { + Reporter.Verbose.WriteLine($"packagedcommandspecfactory: failed to find commandPath {commandPath}"); + return null; } diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PathCommandResolverPolicy.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PathCommandResolverPolicy.cs new file mode 100644 index 000000000..874c79639 --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PathCommandResolverPolicy.cs @@ -0,0 +1,43 @@ +using Microsoft.DotNet.PlatformAbstractions; + +namespace Microsoft.DotNet.Cli.Utils +{ + public class PathCommandResolverPolicy : ICommandResolverPolicy + { + public CompositeCommandResolver CreateCommandResolver() + { + return Create(); + } + + public static CompositeCommandResolver Create() + { + var environment = new EnvironmentProvider(); + + var platformCommandSpecFactory = default(IPlatformCommandSpecFactory); + if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) + { + platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory(); + } + else + { + platformCommandSpecFactory = new GenericPlatformCommandSpecFactory(); + } + + return CreatePathCommandResolverPolicy( + environment, + platformCommandSpecFactory); + } + + public static CompositeCommandResolver CreatePathCommandResolverPolicy( + IEnvironmentProvider environment, + IPlatformCommandSpecFactory platformCommandSpecFactory) + { + var compositeCommandResolver = new CompositeCommandResolver(); + + compositeCommandResolver.AddCommandResolver( + new PathCommandResolver(environment, platformCommandSpecFactory)); + + return compositeCommandResolver; + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs index 29d40a042..b2a06ec29 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs @@ -2,9 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.InternalAbstractions; -using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.Tools.Common; using NuGet.Frameworks; using NuGet.ProjectModel; @@ -39,11 +36,15 @@ namespace Microsoft.DotNet.Cli.Utils public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { + Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: attempting to resolve {commandResolverArguments.CommandName}"); + if (commandResolverArguments.Framework == null || commandResolverArguments.ProjectDirectory == null || commandResolverArguments.Configuration == null || commandResolverArguments.CommandName == null) { + Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: invalid commandResolverArguments"); + return null; } diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectFactory.cs index 80bdc5e7f..4a7cf2c64 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectFactory.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Build.Exceptions; -using Microsoft.DotNet.ProjectModel; using NuGet.Frameworks; namespace Microsoft.DotNet.Cli.Utils @@ -27,13 +26,13 @@ namespace Microsoft.DotNet.Cli.Utils string buildBasePath, string outputPath) { - return GetMSBuildProj(projectDirectory, framework, configuration, outputPath) ?? - GetProjectJsonProject(projectDirectory, framework, configuration, buildBasePath, outputPath); + return GetMSBuildProj(projectDirectory, framework, configuration, outputPath); } private IProject GetMSBuildProj(string projectDirectory, NuGetFramework framework, string configuration, string outputPath) { var msBuildExePath = _environment.GetEnvironmentVariable(Constants.MSBUILD_EXE_PATH); + msBuildExePath = string.IsNullOrEmpty(msBuildExePath) ? Path.Combine(AppContext.BaseDirectory, "MSBuild.dll") : msBuildExePath; @@ -41,7 +40,9 @@ namespace Microsoft.DotNet.Cli.Utils Reporter.Verbose.WriteLine($"projetfactory: MSBUILD_EXE_PATH = {msBuildExePath}"); string msBuildProjectPath = GetMSBuildProjPath(projectDirectory); + Reporter.Verbose.WriteLine($"projetfactory: MSBuild project path = {msBuildProjectPath}"); + if(msBuildProjectPath == null) { return null; @@ -54,25 +55,11 @@ namespace Microsoft.DotNet.Cli.Utils catch (InvalidProjectFileException ex) { Reporter.Verbose.WriteLine(ex.ToString().Red()); + return null; } } - private IProject GetProjectJsonProject( - string projectDirectory, - NuGetFramework framework, - string configuration, - string buildBasePath, - string outputPath) - { - if (!File.Exists(Path.Combine(projectDirectory, Project.FileName))) - { - return null; - } - - return new ProjectJsonProject(projectDirectory, framework, configuration, buildBasePath, outputPath); - } - private string GetMSBuildProjPath(string projectDirectory) { IEnumerable projectFiles = Directory diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectJsonProject.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectJsonProject.cs deleted file mode 100644 index 10ea486fe..000000000 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectJsonProject.cs +++ /dev/null @@ -1,119 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.InternalAbstractions; -using Microsoft.DotNet.ProjectModel; -using NuGet.Frameworks; -using NuGet.ProjectModel; - -namespace Microsoft.DotNet.Cli.Utils -{ - internal class ProjectJsonProject : IProject - { - private LockFile _lockFile; - - private ProjectContext _projectContext; - - private string _projectDirectory; - - private string _configuration; - - private string _outputPath; - - private string _buildBasePath; - - private NuGetFramework _framework; - - private ProjectContext ProjectContext - { - get - { - if(_projectContext == null) - { - _projectContext = ProjectContext.Create( - _projectDirectory, - _framework, - RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); - } - - return _projectContext; - } - } - - public string DepsJsonPath - { - get - { - return ProjectContext.GetOutputPaths( - _configuration, - _buildBasePath, - _outputPath).RuntimeFiles.DepsJson; - } - } - - public string RuntimeConfigJsonPath - { - get - { - return ProjectContext.GetOutputPaths( - _configuration, - _buildBasePath, - _outputPath).RuntimeFiles.RuntimeConfigJson; - } - } - - public string FullOutputPath - { - get - { - return - ProjectContext.GetOutputPaths(_configuration, _buildBasePath, _outputPath).RuntimeFiles.BasePath; - } - } - - public Dictionary EnvironmentVariables - { - get - { - return new Dictionary(); - } - } - - public ProjectJsonProject( - string projectDirectory, - NuGetFramework framework, - string configuration, - string buildBasePath, - string outputPath) - { - var lockFilePath = Path.Combine(projectDirectory, LockFileFormat.LockFileName); - _lockFile = new LockFileFormat().Read(lockFilePath); - - _projectDirectory = projectDirectory; - _framework = framework; - _configuration = configuration; - _buildBasePath = buildBasePath; - _outputPath = outputPath; - } - - public LockFile GetLockFile() - { - return _lockFile; - } - - public IEnumerable GetTools() - { - var tools = _lockFile.Tools.Where(t => t.Name.Contains(".NETCoreApp")).SelectMany(t => t.Libraries); - - return tools.Select(t => new SingleProjectInfo( - t.Name, - t.Version.ToFullString(), - Enumerable.Empty())); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs index fce36d55e..2e5b3263f 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs @@ -5,13 +5,12 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.Tools.Common; using Microsoft.Extensions.DependencyModel; +using NuGet.Configuration; using NuGet.Frameworks; using NuGet.ProjectModel; using NuGet.Versioning; -using FileFormatException = Microsoft.DotNet.ProjectModel.FileFormatException; namespace Microsoft.DotNet.Cli.Utils { @@ -45,6 +44,8 @@ namespace Microsoft.DotNet.Cli.Utils if (commandResolverArguments.CommandName == null || commandResolverArguments.ProjectDirectory == null) { + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: Invalid CommandResolverArguments"); + return null; } @@ -54,12 +55,21 @@ namespace Microsoft.DotNet.Cli.Utils private CommandSpec ResolveFromProjectTools(CommandResolverArguments commandResolverArguments) { var projectFactory = new ProjectFactory(_environment); + var project = projectFactory.GetProject( commandResolverArguments.ProjectDirectory, commandResolverArguments.Framework, commandResolverArguments.Configuration, commandResolverArguments.BuildBasePath, commandResolverArguments.OutputPath); + + if (project == null) + { + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: ProjectFactory did not find Project."); + + return null; + } + var tools = project.GetTools(); return ResolveCommandSpecFromAllToolLibraries( @@ -77,6 +87,8 @@ namespace Microsoft.DotNet.Cli.Utils LockFile lockFile, IProject project) { + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: resolving commandspec from {toolsLibraries.Count()} Tool Libraries."); + foreach (var toolLibrary in toolsLibraries) { var commandSpec = ResolveCommandSpecFromToolLibrary( @@ -92,6 +104,8 @@ namespace Microsoft.DotNet.Cli.Utils } } + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: failed to resolve commandspec from library."); + return null; } @@ -102,10 +116,18 @@ namespace Microsoft.DotNet.Cli.Utils LockFile lockFile, IProject project) { - var nugetPackagesRoot = lockFile.PackageFolders.First().Path; + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: Attempting to resolve command spec from tool {toolLibraryRange.Name}"); + + var nuGetPathContext = NuGetPathContext.Create(project.ProjectRoot); + + var nugetPackagesRoot = nuGetPathContext.UserPackageFolder; + + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: nuget packages root:\n{nugetPackagesRoot}"); var toolLockFile = GetToolLockFile(toolLibraryRange, nugetPackagesRoot); + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: found tool lockfile at : {toolLockFile.Path}"); + var toolLibrary = toolLockFile.Targets .FirstOrDefault( t => t.TargetFramework.GetShortFolderName().Equals(s_toolPackageFramework.GetShortFolderName())) @@ -113,14 +135,19 @@ namespace Microsoft.DotNet.Cli.Utils if (toolLibrary == null) { + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: library not found in lock file."); + return null; } var depsFileRoot = Path.GetDirectoryName(toolLockFile.Path); + var depsFilePath = GetToolDepsFilePath(toolLibraryRange, toolLockFile, depsFileRoot); var normalizedNugetPackagesRoot = PathUtility.EnsureNoTrailingDirectorySeparator(nugetPackagesRoot); + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: attempting to create commandspec"); + var commandSpec = _packagedCommandSpecFactory.CreateCommandSpecFromLibrary( toolLibrary, commandName, @@ -131,6 +158,11 @@ namespace Microsoft.DotNet.Cli.Utils depsFilePath, null); + if (commandSpec == null) + { + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: commandSpec is null."); + } + commandSpec?.AddEnvironmentVariablesFromProject(project); return commandSpec; @@ -182,6 +214,8 @@ namespace Microsoft.DotNet.Cli.Utils depsPathRoot, toolLibrary.Name + FileNameSuffixes.DepsJson); + Reporter.Verbose.WriteLine($"projecttoolscommandresolver: expect deps.json at: {depsJsonPath}"); + EnsureToolJsonDepsFileExists(toolLockFile, depsJsonPath, toolLibrary); return depsJsonPath; diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PublishPathCommandSpecFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PublishPathCommandSpecFactory.cs index 54a9c68f2..4de59a1eb 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PublishPathCommandSpecFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PublishPathCommandSpecFactory.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using Microsoft.DotNet.ProjectModel; namespace Microsoft.DotNet.Cli.Utils { diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolver.cs index 8b2b7db97..a740278b3 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolver.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.IO; -using Microsoft.DotNet.ProjectModel; using NuGet.Frameworks; namespace Microsoft.DotNet.Cli.Utils @@ -49,25 +48,6 @@ namespace Microsoft.DotNet.Cli.Utils return defaultCommandResolver.Resolve(commandResolverArgs); } - - public static CommandSpec TryResolveScriptCommandSpec( - string commandName, - IEnumerable args, - Project project, - string[] inferredExtensionList) - { - var commandResolverArgs = new CommandResolverArguments - { - CommandName = commandName, - CommandArguments = args, - ProjectDirectory = project.ProjectDirectory, - InferredExtensions = inferredExtensionList - }; - - var scriptCommandResolver = ScriptCommandResolverPolicy.Create(); - - return scriptCommandResolver.Resolve(commandResolverArgs); - } } } diff --git a/src/Microsoft.DotNet.Cli.Utils/DotnetRuntimeIdentifiers.cs b/src/Microsoft.DotNet.Cli.Utils/DotnetRuntimeIdentifiers.cs index 00427a890..747fa8901 100644 --- a/src/Microsoft.DotNet.Cli.Utils/DotnetRuntimeIdentifiers.cs +++ b/src/Microsoft.DotNet.Cli.Utils/DotnetRuntimeIdentifiers.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using Microsoft.DotNet.InternalAbstractions; namespace Microsoft.DotNet.Cli.Utils { diff --git a/src/Microsoft.DotNet.Cli.Utils/Extensions/ProjectContextCollectionExtensions.cs b/src/Microsoft.DotNet.Cli.Utils/Extensions/ProjectContextCollectionExtensions.cs deleted file mode 100644 index 249df0e2c..000000000 --- a/src/Microsoft.DotNet.Cli.Utils/Extensions/ProjectContextCollectionExtensions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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; -using System.Text; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Cli.Utils -{ - public static class ProjectContextCollectionExtensions - { - public static ProjectContextCollection EnsureValid(this ProjectContextCollection contextCollection, string projectFilePath) - { - IEnumerable errors; - - if (contextCollection == null) - { - errors = new[] - { - new DiagnosticMessage( - ErrorCodes.DOTNET1017, - $"Project file does not exist '{ProjectPathHelper.NormalizeProjectFilePath(projectFilePath)}'.", - projectFilePath, - DiagnosticMessageSeverity.Error) - }; - } - else - { - errors = contextCollection - .ProjectDiagnostics - .Where(d => d.Severity == DiagnosticMessageSeverity.Error); - } - - if (errors.Any()) - { - StringBuilder errorMessage = new StringBuilder($"The current project is not valid because of the following errors:{Environment.NewLine}"); - - foreach (DiagnosticMessage message in errors) - { - errorMessage.AppendLine(message.FormattedMessage); - } - - throw new GracefulException(errorMessage.ToString()); - } - - return contextCollection; - } - } -} diff --git a/src/Microsoft.DotNet.ProjectModel/FileNameSuffixes.cs b/src/Microsoft.DotNet.Cli.Utils/FileNameSuffixes.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/FileNameSuffixes.cs rename to src/Microsoft.DotNet.Cli.Utils/FileNameSuffixes.cs index 231162a31..86d1d6407 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileNameSuffixes.cs +++ b/src/Microsoft.DotNet.Cli.Utils/FileNameSuffixes.cs @@ -1,7 +1,7 @@ using System; using Microsoft.DotNet.PlatformAbstractions; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Cli.Utils { public static class FileNameSuffixes { @@ -70,4 +70,4 @@ namespace Microsoft.DotNet.ProjectModel public string StaticLib { get; internal set; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Cli.Utils/FrameworkDependencyFile.cs b/src/Microsoft.DotNet.Cli.Utils/FrameworkDependencyFile.cs index f783e9c15..5393df880 100644 --- a/src/Microsoft.DotNet.Cli.Utils/FrameworkDependencyFile.cs +++ b/src/Microsoft.DotNet.Cli.Utils/FrameworkDependencyFile.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using Microsoft.DotNet.PlatformAbstractions; + using Microsoft.Extensions.DependencyModel; namespace Microsoft.DotNet.Cli.Utils diff --git a/src/Microsoft.DotNet.Cli.Utils/RuntimeConfig.cs b/src/Microsoft.DotNet.Cli.Utils/RuntimeConfig.cs new file mode 100644 index 000000000..5b0c8fcc5 --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/RuntimeConfig.cs @@ -0,0 +1,56 @@ +// 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 Newtonsoft.Json.Linq; +using System.IO; + +namespace Microsoft.DotNet.Cli.Utils +{ + public class RuntimeConfig + { + public bool IsPortable { get; } + public RuntimeConfigFramework Framework { get; } + + public RuntimeConfig(string runtimeConfigPath) + { + var runtimeConfigJson = OpenRuntimeConfig(runtimeConfigPath); + + Framework = ParseFramework(runtimeConfigJson); + + IsPortable = Framework != null; + } + + public static bool IsApplicationPortable(string entryAssemblyPath) + { + var runtimeConfigFile = Path.ChangeExtension(entryAssemblyPath, FileNameSuffixes.RuntimeConfigJson); + if (File.Exists(runtimeConfigFile)) + { + var runtimeConfig = new RuntimeConfig(runtimeConfigFile); + return runtimeConfig.IsPortable; + } + return false; + } + + private JObject OpenRuntimeConfig(string runtimeConfigPath) + { + return JObject.Parse(File.ReadAllText(runtimeConfigPath)); + } + + private RuntimeConfigFramework ParseFramework(JObject runtimeConfigRoot) + { + var runtimeOptionsRoot = runtimeConfigRoot["runtimeOptions"]; + if (runtimeOptionsRoot == null) + { + return null; + } + + var framework = (JObject) runtimeOptionsRoot["framework"]; + if (framework == null) + { + return null; + } + + return RuntimeConfigFramework.ParseFromFrameworkRoot(framework); + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/RuntimeConfigFramework.cs b/src/Microsoft.DotNet.Cli.Utils/RuntimeConfigFramework.cs new file mode 100644 index 000000000..b8f8dcea5 --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/RuntimeConfigFramework.cs @@ -0,0 +1,34 @@ +// 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.Linq; +using Newtonsoft.Json.Linq; + +namespace Microsoft.DotNet.Cli.Utils +{ + public class RuntimeConfigFramework + { + public string Name { get; set; } + public string Version { get; set; } + + public static RuntimeConfigFramework ParseFromFrameworkRoot(JObject framework) + { + var properties = framework.Properties(); + + var name = properties.FirstOrDefault(p => p.Name.Equals("name", StringComparison.OrdinalIgnoreCase)); + var version = properties.FirstOrDefault(p => p.Name.Equals("version", StringComparison.OrdinalIgnoreCase)); + + if (name == null || version == null) + { + return null; + } + + return new RuntimeConfigFramework + { + Name = name.Value.ToString(), + Version = version.Value.ToString() + }; + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/RuntimeEnvironmentRidExtensions.cs b/src/Microsoft.DotNet.Cli.Utils/RuntimeEnvironmentRidExtensions.cs new file mode 100644 index 000000000..073e1407e --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/RuntimeEnvironmentRidExtensions.cs @@ -0,0 +1,84 @@ + +using System; +using System.Collections.Generic; +using Microsoft.DotNet.PlatformAbstractions; + +namespace Microsoft.DotNet.Cli.Utils +{ + // This is to support some legacy stuff. + // dnu restore (and thus dotnet restore) always uses win7-x64 as the Windows restore target, + // so, when picking targets out of the lock file, we need to do version fallback since the + // active RID might be higher than the RID in the lock file. + // + // We should clean this up. Filed #619 to track. + public static class RuntimeEnvironmentRidExtensions + { + // Gets the identfier that is used for restore by default (this is different from the actual RID, but only on Windows) + public static string GetLegacyRestoreRuntimeIdentifier() + { + if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) + { + return RuntimeEnvironment.GetRuntimeIdentifier(); + } + else + { + var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant(); + return "win7-" + arch; + } + } + + public static IEnumerable GetAllCandidateRuntimeIdentifiers() + { + return GetAllCandidateRuntimeIdentifiers(null); + } + + public static IEnumerable GetAllCandidateRuntimeIdentifiers(IEnumerable fallbackIdentifiers = null) + { + List result = new List(); + + if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) + { + result.Add(RuntimeEnvironment.GetRuntimeIdentifier()); + } + else + { + var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant(); + if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.1", StringComparison.Ordinal)) + { + result.Add("win7-" + arch); + } + else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.2", StringComparison.Ordinal)) + { + result.Add("win8-" + arch); + result.Add("win7-" + arch); + } + else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.3", StringComparison.Ordinal)) + { + result.Add("win81-" + arch); + result.Add("win8-" + arch); + result.Add("win7-" + arch); + } + else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("10.0", StringComparison.Ordinal)) + { + result.Add("win10-" + arch); + result.Add("win81-" + arch); + result.Add("win8-" + arch); + result.Add("win7-" + arch); + } + } + + if (fallbackIdentifiers != null) + { + foreach (string fallbackIdentifier in fallbackIdentifiers) + { + if (!result.Contains(fallbackIdentifier)) + { + result.Add(fallbackIdentifier); + } + } + } + + return result; + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/ScriptExecutor.cs b/src/Microsoft.DotNet.Cli.Utils/ScriptExecutor.cs deleted file mode 100644 index 31d822134..000000000 --- a/src/Microsoft.DotNet.Cli.Utils/ScriptExecutor.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.Cli.Utils.CommandParsing; -using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Cli.Utils -{ - public static class ScriptExecutor - { - public static ICommand CreateCommandForScript(Project project, string scriptCommandLine, IDictionary variables) - { - return CreateCommandForScript(project, scriptCommandLine, WrapVariableDictionary(variables)); - } - - public static ICommand CreateCommandForScript(Project project, string scriptCommandLine, Func getVariable) - { - var scriptArguments = ParseScriptArguments(project, scriptCommandLine, getVariable); - if (scriptArguments == null) - { - throw new Exception($"ScriptExecutor: failed to parse script \"{scriptCommandLine}\""); - } - - var inferredExtensions = DetermineInferredScriptExtensions(); - - return Command - .CreateForScript(scriptArguments.First(), scriptArguments.Skip(1), project, inferredExtensions) - .WorkingDirectory(project.ProjectDirectory); - } - - private static IEnumerable ParseScriptArguments(Project project, string scriptCommandLine, Func getVariable) - { - var scriptArguments = CommandGrammar.Process( - scriptCommandLine, - GetScriptVariable(project, getVariable), - preserveSurroundingQuotes: false); - - scriptArguments = scriptArguments.Where(argument => !string.IsNullOrEmpty(argument)).ToArray(); - if (scriptArguments.Length == 0) - { - return null; - } - - return scriptArguments; - } - - private static string[] DetermineInferredScriptExtensions() - { - if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) - { - return new string[] { "", ".cmd" }; - } - else - { - return new string[] { "", ".sh" }; - } - } - - private static Func WrapVariableDictionary(IDictionary contextVariables) - { - return key => - { - string value; - contextVariables.TryGetValue(key, out value); - return value; - }; - } - - private static Func GetScriptVariable(Project project, Func getVariable) - { - var keys = new Dictionary>(StringComparer.OrdinalIgnoreCase) - { - { "project:Directory", () => project.ProjectDirectory }, - { "project:Name", () => project.Name }, - { "project:Version", () => project.Version.ToString() }, - }; - - return key => - { - // try returning key from dictionary - Func valueFactory; - if (keys.TryGetValue(key, out valueFactory)) - { - return valueFactory(); - } - - // try returning command-specific key - var value = getVariable(key); - if (!string.IsNullOrEmpty(value)) - { - return value; - } - - // try returning environment variable - return Environment.GetEnvironmentVariable(key); - }; - } - } -} diff --git a/src/Microsoft.DotNet.Cli.Utils/ScriptNames.cs b/src/Microsoft.DotNet.Cli.Utils/ScriptNames.cs deleted file mode 100644 index 18ac76f3e..000000000 --- a/src/Microsoft.DotNet.Cli.Utils/ScriptNames.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Microsoft.DotNet.Cli.Utils -{ - public static class ScriptNames - { - public const string PreCompile = "precompile"; - public const string PostCompile = "postcompile"; - public const string PrePublish = "prepublish"; - public const string PostPublish = "postpublish"; - } -} diff --git a/src/Microsoft.DotNet.Cli.Utils/project.json b/src/Microsoft.DotNet.Cli.Utils/project.json index 31e76e28c..961dd507a 100644 --- a/src/Microsoft.DotNet.Cli.Utils/project.json +++ b/src/Microsoft.DotNet.Cli.Utils/project.json @@ -5,9 +5,7 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, + "Microsoft.Extensions.DependencyModel": "1.0.1-beta-000933", "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933", "NuGet.Versioning": "3.6.0-rc-1984", diff --git a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs deleted file mode 100644 index acf511e27..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs +++ /dev/null @@ -1,115 +0,0 @@ -// 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; -using System.Reflection; -using System.Resources; -using Microsoft.CodeAnalysis.CSharp; -using System.IO; -using System.Runtime.Versioning; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public class AssemblyInfoFileGenerator - { - public static string GenerateCSharp(AssemblyInfoOptions metadata, IEnumerable sourceFiles) - { - var projectAttributes = GetProjectAttributes(metadata); - - var existingAttributes = new List(); - foreach (var sourceFile in sourceFiles) - { - var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile)); - var root = tree.GetRoot(); - - // assembly attributes can be only on first level - foreach (var attributeListSyntax in root.ChildNodes().OfType()) - { - if (attributeListSyntax.Target.Identifier.Kind() == SyntaxKind.AssemblyKeyword) - { - foreach (var attributeSyntax in attributeListSyntax.Attributes) - { - var projectAttribute = projectAttributes.FirstOrDefault(attribute => IsSameAttribute(attribute.Key, attributeSyntax)); - if (projectAttribute.Key != null) - { - existingAttributes.Add(projectAttribute.Key); - } - } - } - } - } - - string autoGeneratedHeader = "// This file has been auto generated. \r\n"; - return autoGeneratedHeader + string.Join(Environment.NewLine, projectAttributes - .Where(projectAttribute => projectAttribute.Value != null && !existingAttributes.Contains(projectAttribute.Key)) - .Select(projectAttribute => $"[assembly:{projectAttribute.Key.FullName}(\"{projectAttribute.Value}\")]")); - } - - public static string GenerateFSharp(AssemblyInfoOptions metadata) - { - var projectAttributes = GetProjectAttributes(metadata); - - return string.Join(Environment.NewLine, - new[] { "namespace System", Environment.NewLine, Environment.NewLine } - .Concat(projectAttributes.Select(projectAttribute => $"[]")) - .Concat(new[] { "do ()", Environment.NewLine })); - } - - private static Dictionary GetProjectAttributes(AssemblyInfoOptions metadata) - { - var attributes = new Dictionary() - { - [typeof(AssemblyTitleAttribute)] = EscapeCharacters(metadata.Title), - [typeof(AssemblyDescriptionAttribute)] = EscapeCharacters(metadata.Description), - [typeof(AssemblyCopyrightAttribute)] = EscapeCharacters(metadata.Copyright), - [typeof(AssemblyFileVersionAttribute)] = EscapeCharacters(metadata.AssemblyFileVersion?.ToString()), - [typeof(AssemblyVersionAttribute)] = EscapeCharacters(metadata.AssemblyVersion?.ToString()), - [typeof(AssemblyInformationalVersionAttribute)] = EscapeCharacters(metadata.InformationalVersion), - [typeof(AssemblyCultureAttribute)] = EscapeCharacters(metadata.Culture), - [typeof(NeutralResourcesLanguageAttribute)] = EscapeCharacters(metadata.NeutralLanguage) - }; - - if (SupportsTargetFrameworkAttribute(metadata)) - { - // TargetFrameworkAttribute only exists since .NET 4.0 - attributes[typeof(TargetFrameworkAttribute)] = EscapeCharacters(metadata.TargetFramework); - }; - - return attributes; - } - - private static bool SupportsTargetFrameworkAttribute(AssemblyInfoOptions metadata) - { - if (string.IsNullOrEmpty(metadata.TargetFramework)) - { - // target framework is unknown. to be on the safe side, return false. - return false; - } - - var targetFramework = NuGetFramework.Parse(metadata.TargetFramework); - if (!targetFramework.IsDesktop()) - { - // assuming .NET Core, which should support .NET 4.0 attributes - return true; - } - - return targetFramework.Version >= new Version(4, 0); - } - - private static bool IsSameAttribute(Type attributeType, AttributeSyntax attributeSyntax) - { - var name = attributeSyntax.Name.ToString(); - // This check is quite stupid but we can not do more without semantic model - return attributeType.FullName.StartsWith(name) || attributeType.Name.StartsWith(name); - } - - private static string EscapeCharacters(string str) - { - return str != null ? SymbolDisplay.FormatLiteral(str, quote: false) : null; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs deleted file mode 100644 index 251d0f48f..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs +++ /dev/null @@ -1,129 +0,0 @@ -// 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.ProjectModel; -using System.Collections.Generic; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public class AssemblyInfoOptions - { - public static readonly string TitleOptionName = "title"; - - public static readonly string DescriptionOptionName = "description"; - - public static readonly string CopyrightOptionName = "copyright"; - - public static readonly string AssemblyFileVersionOptionName = "file-version"; - - public static readonly string AssemblyVersionOptionName = "version"; - - public static readonly string InformationalVersionOptionName = "informational-version"; - - public static readonly string CultureOptionName = "culture"; - - public static readonly string NeutralCultureOptionName = "neutral-language"; - - public static readonly string TargetFrameworkOptionName = "target-framework"; - - public string Title { get; set; } - - public string Description { get; set; } - - public string Copyright { get; set; } - - public string AssemblyFileVersion { get; set; } - - public string AssemblyVersion { get; set; } - - public string InformationalVersion { get; set; } - - public string Culture { get; set; } - - public string NeutralLanguage { get; set; } - - public string TargetFramework { get; set; } - - public static AssemblyInfoOptions CreateForProject(ProjectContext context) - { - var project = context.ProjectFile; - NuGetFramework targetFramework = null; - // force .NETFramework instead of DNX - if (context.TargetFramework.IsDesktop()) - { - targetFramework = new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Net, context.TargetFramework.Version); - } - else - { - targetFramework = context.TargetFramework; - } - - return new AssemblyInfoOptions() - { - AssemblyVersion = project.Version?.Version.ToString(), - AssemblyFileVersion = project.AssemblyFileVersion.ToString(), - InformationalVersion = project.Version.ToString(), - Copyright = project.Copyright, - Description = project.Description, - Title = project.Title, - NeutralLanguage = project.Language, - TargetFramework = targetFramework.DotNetFrameworkName - }; - } - - public static IEnumerable SerializeToArgs(AssemblyInfoOptions assemblyInfoOptions) - { - var options = new List(); - - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.Title)) - { - options.Add(FormatOption(TitleOptionName, assemblyInfoOptions.Title)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.Description)) - { - options.Add(FormatOption(DescriptionOptionName, assemblyInfoOptions.Description)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.Copyright)) - { - options.Add(FormatOption(CopyrightOptionName, assemblyInfoOptions.Copyright)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.AssemblyFileVersion)) - { - options.Add(FormatOption(AssemblyFileVersionOptionName, assemblyInfoOptions.AssemblyFileVersion)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.AssemblyVersion)) - { - options.Add(FormatOption(AssemblyVersionOptionName, assemblyInfoOptions.AssemblyVersion)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.InformationalVersion)) - { - options.Add(FormatOption(InformationalVersionOptionName, assemblyInfoOptions.InformationalVersion)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.Culture)) - { - options.Add(FormatOption(CultureOptionName, assemblyInfoOptions.Culture)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.NeutralLanguage)) - { - options.Add(FormatOption(NeutralCultureOptionName, assemblyInfoOptions.NeutralLanguage)); - } - if (!string.IsNullOrWhiteSpace(assemblyInfoOptions.TargetFramework)) - { - options.Add(FormatOption(TargetFrameworkOptionName, assemblyInfoOptions.TargetFramework)); - } - - return options; - } - - private static string FormatOption(string optionName, string value) - { - return $"--{optionName}:{EscapeNewlines(value)}"; - } - - private static string EscapeNewlines(string text) - { - return text.Replace("\r", "\\r").Replace("\n", "\\n"); - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/BindingRedirectGenerator.cs b/src/Microsoft.DotNet.Compiler.Common/BindingRedirectGenerator.cs deleted file mode 100644 index 1227c9866..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/BindingRedirectGenerator.cs +++ /dev/null @@ -1,304 +0,0 @@ -// 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.IO; -using System.Linq; -using System.Reflection.Metadata; -using System.Reflection.PortableExecutable; -using System.Security.Cryptography; -using System.Text; -using System.Xml.Linq; -using Microsoft.DotNet.ProjectModel.Compilation; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public static class BindingRedirectGenerator - { - private const int TokenLength = 8; - private const string Namespace = "urn:schemas-microsoft-com:asm.v1"; - - private static readonly XName ConfigurationElementName = XName.Get("configuration"); - private static readonly XName RuntimeElementName = XName.Get("runtime"); - private static readonly XName AssemblyBindingElementName = XName.Get("assemblyBinding", Namespace); - private static readonly XName DependentAssemblyElementName = XName.Get("dependentAssembly", Namespace); - private static readonly XName AssemblyIdentityElementName = XName.Get("assemblyIdentity", Namespace); - private static readonly XName BindingRedirectElementName = XName.Get("bindingRedirect", Namespace); - - private static readonly XName NameAttributeName = XName.Get("name"); - private static readonly XName PublicKeyTokenAttributeName = XName.Get("publicKeyToken"); - private static readonly XName CultureAttributeName = XName.Get("culture"); - private static readonly XName OldVersionAttributeName = XName.Get("oldVersion"); - private static readonly XName NewVersionAttributeName = XName.Get("newVersion"); - - private static SHA1 Sha1 { get; } = SHA1.Create(); - - public static void GenerateBindingRedirects(this IEnumerable dependencies, IEnumerable configFiles) - { - var redirects = CollectRedirects(dependencies); - - if (!redirects.Any()) - { - // No redirects required - return; - } - - foreach (var configFile in configFiles) - { - GenerateBindingRedirects(configFile, redirects); - } - } - - internal static void GenerateBindingRedirects(string configFile, AssemblyRedirect[] bindingRedirects) - { - XDocument configRoot = File.Exists(configFile) ? XDocument.Load(configFile) : new XDocument(); - var configuration = GetOrAddElement(configRoot, ConfigurationElementName); - var runtime = GetOrAddElement(configuration, RuntimeElementName); - var assemblyBindings = GetOrAddElement(runtime, AssemblyBindingElementName); - - foreach (var redirect in bindingRedirects) - { - AddDependentAssembly(redirect, assemblyBindings); - } - - using (var fileStream = File.Open(configFile, FileMode.OpenOrCreate, FileAccess.ReadWrite)) - { - configRoot.Save(fileStream); - } - } - - private static void AddDependentAssembly(AssemblyRedirect redirect, XElement assemblyBindings) - { - var dependencyElement = assemblyBindings.Elements(DependentAssemblyElementName) - .FirstOrDefault(element => IsSameAssembly(redirect, element)); - - if (dependencyElement == null) - { - dependencyElement = new XElement(DependentAssemblyElementName, - new XElement(AssemblyIdentityElementName, - new XAttribute(NameAttributeName, redirect.From.Name), - new XAttribute(PublicKeyTokenAttributeName, redirect.From.PublicKeyToken), - new XAttribute(CultureAttributeName, redirect.From.Culture) - ) - ); - assemblyBindings.Add(dependencyElement); - } - - bool redirectExists = dependencyElement.Elements(BindingRedirectElementName).Any(element => IsSameRedirect(redirect, element)); - - if (!redirectExists) - { - dependencyElement.Add(new XElement(BindingRedirectElementName, - new XAttribute(OldVersionAttributeName, redirect.From.Version), - new XAttribute(NewVersionAttributeName, redirect.To.Version) - )); - } - } - - private static bool IsSameAssembly(AssemblyRedirect redirect, XElement dependentAssemblyElement) - { - var identity = dependentAssemblyElement.Element(AssemblyIdentityElementName); - if (identity == null) - { - return false; - } - return (string)identity.Attribute(NameAttributeName) == redirect.From.Name && - (string)identity.Attribute(PublicKeyTokenAttributeName) == redirect.From.PublicKeyToken && - (string)identity.Attribute(CultureAttributeName) == redirect.From.Culture; - } - - private static bool IsSameRedirect(AssemblyRedirect redirect, XElement bindingRedirectElement) - { - if (bindingRedirectElement == null) - { - return false; - } - return (string)bindingRedirectElement.Attribute(OldVersionAttributeName) == redirect.From.Version.ToString() && - (string)bindingRedirectElement.Attribute(NewVersionAttributeName) == redirect.To.Version.ToString(); - } - - private static XElement GetOrAddElement(XContainer parent, XName elementName) - { - XElement element; - if (parent.Element(elementName) != null) - { - element = parent.Element(elementName); - } - else - { - element = new XElement(elementName); - parent.Add(element); - } - return element; - } - - internal static AssemblyRedirect[] CollectRedirects(IEnumerable dependencies) - { - var runtimeAssemblies = dependencies - .SelectMany(d => d.RuntimeAssemblyGroups.GetDefaultAssets()) - .Select(GetAssemblyInfo); - - return CollectRedirects(runtimeAssemblies); - } - - internal static AssemblyRedirect[] CollectRedirects(IEnumerable runtimeAssemblies) - { - var assemblyLookup = runtimeAssemblies.ToLookup(r => r.Identity.ToLookupKey()); - - var redirectAssemblies = new HashSet(); - foreach (var assemblyReferenceInfo in assemblyLookup) - { - // Using .First here is not exactly valid, but we don't know which one gets copied to - // output so we just use first - var references = assemblyReferenceInfo.First().References; - foreach (var referenceIdentity in references) - { - var targetAssemblies = assemblyLookup[referenceIdentity.ToLookupKey()]; - if (!targetAssemblies.Any()) - { - continue; - } - var targetAssemblyIdentity = targetAssemblies.First(); - if (targetAssemblyIdentity.Identity.Version != referenceIdentity.Version) - { - if (targetAssemblyIdentity.Identity.PublicKeyToken != null) - { - redirectAssemblies.Add(new AssemblyRedirect() - { - From = referenceIdentity, - To = targetAssemblyIdentity.Identity - }); - } - } - } - } - - return redirectAssemblies.ToArray(); - } - - private static AssemblyReferenceInfo GetAssemblyInfo(LibraryAsset arg) - { - try - { - using (var peReader = new PEReader(File.OpenRead(arg.ResolvedPath))) - { - var metadataReader = peReader.GetMetadataReader(); - - var definition = metadataReader.GetAssemblyDefinition(); - - var identity = new AssemblyIdentity( - metadataReader.GetString(definition.Name), - definition.Version, - metadataReader.GetString(definition.Culture), - GetPublicKeyToken(metadataReader.GetBlobBytes(definition.PublicKey)) - ); - - var references = new List(metadataReader.AssemblyReferences.Count); - - foreach (var assemblyReferenceHandle in metadataReader.AssemblyReferences) - { - var assemblyReference = metadataReader.GetAssemblyReference(assemblyReferenceHandle); - references.Add(new AssemblyIdentity( - metadataReader.GetString(assemblyReference.Name), - assemblyReference.Version, - metadataReader.GetString(assemblyReference.Culture), - GetPublicKeyToken(metadataReader.GetBlobBytes(assemblyReference.PublicKeyOrToken)) - )); - } - - return new AssemblyReferenceInfo(identity, references.ToArray()); - } - } - catch (Exception e) - { - throw new InvalidDataException($"Could not read assembly info for {arg.ResolvedPath}", e); - } - } - - private static string GetPublicKeyToken(byte[] bytes) - { - if (bytes.Length == 0) - { - return null; - } - - byte[] token; - if (bytes.Length == TokenLength) - { - token = bytes; - } - else - { - token = new byte[TokenLength]; - var sha1 = Sha1.ComputeHash(bytes); - Array.Copy(sha1, sha1.Length - TokenLength, token, 0, TokenLength); - Array.Reverse(token); - } - - var hex = new StringBuilder(TokenLength * 2); - foreach (var b in token) - { - hex.AppendFormat("{0:x2}", b); - } - return hex.ToString(); - } - - internal struct AssemblyRedirect - { - public AssemblyRedirect(AssemblyIdentity from, AssemblyIdentity to) - { - From = from; - To = to; - } - - public AssemblyIdentity From { get; set; } - - public AssemblyIdentity To { get; set; } - } - - internal struct AssemblyIdentity - { - public AssemblyIdentity(string name, Version version, string culture, string publicKeyToken) - { - Name = name; - Version = version; - Culture = string.IsNullOrEmpty(culture) ? "neutral" : culture; - PublicKeyToken = publicKeyToken; - } - - public string Name { get; } - - public Version Version { get; } - - public string Culture { get; } - - public string PublicKeyToken { get; } - - public Tuple ToLookupKey() => Tuple.Create(Name, Culture, PublicKeyToken); - - public override string ToString() - { - return $"{Name} {Version} {Culture} {PublicKeyToken}"; - } - } - - internal struct AssemblyReferenceInfo - { - public AssemblyReferenceInfo(AssemblyIdentity identity, AssemblyIdentity[] references) - { - Identity = identity; - References = references; - } - - public AssemblyIdentity Identity { get; } - - public AssemblyIdentity[] References { get; } - - public override string ToString() - { - return $"{Identity} Reference count: {References.Length}"; - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs deleted file mode 100644 index 0c47686c1..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs +++ /dev/null @@ -1,157 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; - -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public static class CommonCompilerOptionsExtensions - { - public static readonly string DefineOptionName = "define"; - public static readonly string SuppressWarningOptionName = "suppress-warning"; - public static readonly string LanguageVersionOptionName = "language-version"; - public static readonly string PlatformOptionName = "platform"; - public static readonly string AllowUnsafeOptionName = "allow-unsafe"; - public static readonly string WarningsAsErrorsOptionName = "warnings-as-errors"; - public static readonly string OptimizeOptionName = "optimize"; - public static readonly string KeyFileOptionName = "key-file"; - public static readonly string DelaySignOptionName = "delay-sign"; - public static readonly string PublicSignOptionName = "public-sign"; - public static readonly string DebugTypeOptionName = "debug-type"; - public static readonly string EmitEntryPointOptionName = "emit-entry-point"; - public static readonly string GenerateXmlDocumentationOptionName = "generate-xml-documentation"; - public static readonly string AdditionalArgumentsOptionName = "additional-argument"; - public static readonly string OutputNameOptionName = "output-name"; - - internal static readonly OptionTemplate s_definesTemplate = new OptionTemplate(DefineOptionName); - - internal static readonly OptionTemplate s_suppressWarningTemplate = new OptionTemplate(SuppressWarningOptionName); - - internal static readonly OptionTemplate s_languageVersionTemplate = new OptionTemplate(LanguageVersionOptionName); - - internal static readonly OptionTemplate s_platformTemplate = new OptionTemplate(PlatformOptionName); - - internal static readonly OptionTemplate s_allowUnsafeTemplate = new OptionTemplate(AllowUnsafeOptionName); - - internal static readonly OptionTemplate s_warningsAsErrorsTemplate = new OptionTemplate(WarningsAsErrorsOptionName); - - internal static readonly OptionTemplate s_optimizeTemplate = new OptionTemplate(OptimizeOptionName); - - internal static readonly OptionTemplate s_keyFileTemplate = new OptionTemplate(KeyFileOptionName); - - internal static readonly OptionTemplate s_delaySignTemplate = new OptionTemplate(DelaySignOptionName); - - internal static readonly OptionTemplate s_publicSignTemplate = new OptionTemplate(PublicSignOptionName); - - internal static readonly OptionTemplate s_debugTypeTemplate = new OptionTemplate(DebugTypeOptionName); - - internal static readonly OptionTemplate s_emitEntryPointTemplate = new OptionTemplate(EmitEntryPointOptionName); - - internal static readonly OptionTemplate s_generateXmlDocumentation = new OptionTemplate(GenerateXmlDocumentationOptionName); - - internal static readonly OptionTemplate s_additionalArgumentsTemplate = new OptionTemplate(AdditionalArgumentsOptionName); - - internal static readonly OptionTemplate s_outputNameTemplate = new OptionTemplate(OutputNameOptionName); - - public static IEnumerable SerializeToArgs(this CommonCompilerOptions options) - { - var defines = options.Defines; - var suppressWarnings = options.SuppressWarnings; - var languageVersion = options.LanguageVersion; - var debugType = options.DebugType; - var platform = options.Platform; - var allowUnsafe = options.AllowUnsafe; - var warningsAsErrors = options.WarningsAsErrors; - var optimize = options.Optimize; - var keyFile = options.KeyFile; - var delaySign = options.DelaySign; - var publicSign = options.PublicSign; - var emitEntryPoint = options.EmitEntryPoint; - var generateXmlDocumentation = options.GenerateXmlDocumentation; - var outputName = options.OutputName; - var additionalArguments = options.AdditionalArguments; - - var args = new List(); - - if (defines != null) - { - args.AddRange(defines.Select(def => s_definesTemplate.ToLongArg(def))); - } - - if (suppressWarnings != null) - { - args.AddRange(suppressWarnings.Select(def => s_suppressWarningTemplate.ToLongArg(def))); - } - - if (additionalArguments != null) - { - args.AddRange(additionalArguments.Select(arg => s_additionalArgumentsTemplate.ToLongArg(arg))); - } - - if (languageVersion != null) - { - args.Add(s_languageVersionTemplate.ToLongArg(languageVersion)); - } - - if (platform != null) - { - args.Add(s_platformTemplate.ToLongArg(platform)); - } - - if (allowUnsafe != null) - { - args.Add(s_allowUnsafeTemplate.ToLongArg(allowUnsafe)); - } - - if (warningsAsErrors != null) - { - args.Add(s_warningsAsErrorsTemplate.ToLongArg(warningsAsErrors)); - } - - if (optimize != null) - { - args.Add(s_optimizeTemplate.ToLongArg(optimize)); - } - - if (keyFile != null) - { - args.Add(s_keyFileTemplate.ToLongArg(keyFile)); - } - - if (delaySign != null) - { - args.Add(s_delaySignTemplate.ToLongArg(delaySign)); - } - - if (publicSign != null) - { - args.Add(s_publicSignTemplate.ToLongArg(publicSign)); - } - - if (debugType != null) - { - args.Add(s_debugTypeTemplate.ToLongArg(debugType)); - } - - if (emitEntryPoint != null) - { - args.Add(s_emitEntryPointTemplate.ToLongArg(emitEntryPoint)); - } - - if (generateXmlDocumentation != null) - { - args.Add(s_generateXmlDocumentation.ToLongArg(generateXmlDocumentation)); - } - - if (outputName != null) - { - args.Add(s_outputNameTemplate.ToLongArg(outputName)); - } - - return args; - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/DefaultCompilerWarningSuppresses.cs b/src/Microsoft.DotNet.Compiler.Common/DefaultCompilerWarningSuppresses.cs deleted file mode 100644 index 7c430d88e..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/DefaultCompilerWarningSuppresses.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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.Collections.Generic; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public class DefaultCompilerWarningSuppresses - { - public static IReadOnlyDictionary> Suppresses { get; } = new Dictionary> - { - { "csc", new string[] {"CS1701", "CS1702", "CS1705" } } - }; - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/DepsFormatter.cs b/src/Microsoft.DotNet.Compiler.Common/DepsFormatter.cs deleted file mode 100644 index 3406c9e3f..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/DepsFormatter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - internal static class DepsFormatter - { - internal static string EscapeRow(IEnumerable values) - { - return values - .Select(EscapeValue) - .Aggregate((a, v) => a + "," + v); - } - - internal static string EscapeValue(string value) - { - return "\"" + value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\""; - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/Executable.cs b/src/Microsoft.DotNet.Compiler.Common/Executable.cs deleted file mode 100644 index 591cbf25e..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/Executable.cs +++ /dev/null @@ -1,345 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Files; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.Tools.Common; -using Microsoft.Extensions.DependencyModel; -using NuGet.Frameworks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public class Executable - { - private readonly ProjectContext _context; - - private readonly LibraryExporter _exporter; - - private readonly string _configuration; - - private readonly OutputPaths _outputPaths; - - private readonly string _runtimeOutputPath; - - private readonly string _intermediateOutputPath; - - private readonly CommonCompilerOptions _compilerOptions; - - public Executable(ProjectContext context, OutputPaths outputPaths, LibraryExporter exporter, string configuration) - : this(context, outputPaths, outputPaths.RuntimeOutputPath, outputPaths.IntermediateOutputDirectoryPath, exporter, configuration) { } - - public Executable(ProjectContext context, OutputPaths outputPaths, string runtimeOutputPath, string intermediateOutputDirectoryPath, LibraryExporter exporter, string configuration) - { - _context = context; - _outputPaths = outputPaths; - _runtimeOutputPath = runtimeOutputPath; - _intermediateOutputPath = intermediateOutputDirectoryPath; - _exporter = exporter; - _configuration = configuration; - _compilerOptions = _context.ProjectFile.GetCompilerOptions(_context.TargetFramework, configuration); - } - - public void MakeCompilationOutputRunnable() - { - CopyContentFiles(); - ExportRuntimeAssets(); - } - - private void VerifyCoreClrPresenceInPackageGraph() - { - var isCoreClrPresent = _exporter - .GetAllExports() - .SelectMany(e => e.NativeLibraryGroups) - .SelectMany(g => g.Assets) - .Select(a => a.FileName) - .Where(f => Constants.LibCoreClrBinaryNames.Contains(f)) - .Any(); - - // coreclr should be present for standalone apps - if (!isCoreClrPresent) - { - throw new InvalidOperationException("Expected coreclr library not found in package graph. Please try running dotnet restore again."); - } - } - - private void ExportRuntimeAssets() - { - if (_context.TargetFramework.IsDesktop()) - { - MakeCompilationOutputRunnableForFullFramework(); - } - else - { - MakeCompilationOutputRunnableForCoreCLR(); - } - } - - private void MakeCompilationOutputRunnableForFullFramework() - { - var dependencies = _exporter.GetDependencies(); - CopyAssemblies(dependencies); - CopyAssets(dependencies); - GenerateBindingRedirects(_exporter); - } - - private void MakeCompilationOutputRunnableForCoreCLR() - { - WriteDepsFileAndCopyProjectDependencies(_exporter); - - var isRunnable = _compilerOptions.EmitEntryPoint ?? false; - - if (isRunnable && !_context.IsPortable) - { - // TODO: Pick a host based on the RID - VerifyCoreClrPresenceInPackageGraph(); - CoreHost.CopyTo(_runtimeOutputPath, _compilerOptions.OutputName + Constants.ExeSuffix); - } - } - - private void CopyContentFiles() - { - var contentFiles = new ContentFiles(_context); - - if (_compilerOptions.CopyToOutputInclude != null) - { - var includeEntries = IncludeFilesResolver.GetIncludeFiles( - _compilerOptions.CopyToOutputInclude, - PathUtility.EnsureTrailingSlash(_runtimeOutputPath), - diagnostics: null); - - contentFiles.StructuredCopyTo(_runtimeOutputPath, includeEntries); - } - else - { - contentFiles.StructuredCopyTo(_runtimeOutputPath); - } - } - - private void CopyAssemblies(IEnumerable libraryExports) - { - foreach (var libraryExport in libraryExports) - { - libraryExport.RuntimeAssemblyGroups.GetDefaultAssets().CopyTo(_runtimeOutputPath); - libraryExport.NativeLibraryGroups.GetDefaultAssets().CopyTo(_runtimeOutputPath); - - foreach (var group in libraryExport.ResourceAssemblies.GroupBy(r => r.Locale)) - { - var localeSpecificDir = Path.Combine(_runtimeOutputPath, group.Key); - if (!Directory.Exists(localeSpecificDir)) - { - Directory.CreateDirectory(localeSpecificDir); - } - group.Select(r => r.Asset).CopyTo(localeSpecificDir); - } - } - } - - private void CopyAssets(IEnumerable libraryExports) - { - foreach (var libraryExport in libraryExports) - { - libraryExport.RuntimeAssets.StructuredCopyTo( - _runtimeOutputPath, - _intermediateOutputPath); - } - } - - private void WriteDepsFileAndCopyProjectDependencies(LibraryExporter exporter) - { - var exports = exporter.GetAllExports().ToList(); - var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name, StringComparer.OrdinalIgnoreCase); - var platformExclusionList = _context.GetPlatformExclusionList(exportsLookup); - var filteredExports = exports.FilterExports(platformExclusionList); - - WriteConfigurationFiles(exports, filteredExports, exports, includeDevConfig: true); - - var projectExports = exporter.GetAllProjectTypeDependencies(); - CopyAssemblies(projectExports); - CopyAssets(projectExports); - - var packageExports = exporter.GetDependencies(LibraryType.Package); - CopyAssets(packageExports); - } - - public void WriteConfigurationFiles( - IEnumerable allExports, - IEnumerable depsRuntimeExports, - IEnumerable depsCompilationExports, - bool includeDevConfig) - { - WriteDeps(depsRuntimeExports, depsCompilationExports); - if (_context.ProjectFile.HasRuntimeOutput(_configuration)) - { - WriteRuntimeConfig(allExports); - if (includeDevConfig) - { - WriteDevRuntimeConfig(); - } - } - } - - private void WriteRuntimeConfig(IEnumerable allExports) - { - if (!_context.TargetFramework.IsDesktop()) - { - // TODO: Suppress this file if there's nothing to write? RuntimeOutputFiles would have to be updated - // in order to prevent breaking incremental compilation... - - var json = new JObject(); - var runtimeOptions = new JObject(); - json.Add("runtimeOptions", runtimeOptions); - - WriteFramework(runtimeOptions, allExports); - WriteRuntimeOptions(runtimeOptions); - - var runtimeConfigJsonFile = - Path.Combine(_runtimeOutputPath, _compilerOptions.OutputName + FileNameSuffixes.RuntimeConfigJson); - - using (var writer = new JsonTextWriter(new StreamWriter(File.Create(runtimeConfigJsonFile)))) - { - writer.Formatting = Formatting.Indented; - json.WriteTo(writer); - } - } - } - - private void WriteFramework(JObject runtimeOptions, IEnumerable allExports) - { - var redistPackage = _context.PlatformLibrary; - if (redistPackage != null) - { - var packageName = redistPackage.Identity.Name; - - var redistExport = allExports.FirstOrDefault(e => e.Library.Identity.Name.Equals(packageName)); - if (redistExport == null) - { - throw new InvalidOperationException($"Platform package '{packageName}' was not present in the graph."); - } - else - { - var framework = new JObject( - new JProperty("name", redistExport.Library.Identity.Name), - new JProperty("version", redistExport.Library.Identity.Version.ToNormalizedString())); - runtimeOptions.Add("framework", framework); - } - } - } - - private void WriteRuntimeOptions(JObject runtimeOptions) - { - if (string.IsNullOrEmpty(_context.ProjectFile.RawRuntimeOptions)) - { - return; - } - - var runtimeOptionsFromProjectJson = JObject.Parse(_context.ProjectFile.RawRuntimeOptions); - foreach (var runtimeOption in runtimeOptionsFromProjectJson) - { - runtimeOptions.Add(runtimeOption.Key, runtimeOption.Value); - } - } - - private void WriteDevRuntimeConfig() - { - if (_context.TargetFramework.IsDesktop()) - { - return; - } - - var json = new JObject(); - var runtimeOptions = new JObject(); - json.Add("runtimeOptions", runtimeOptions); - - AddAdditionalProbingPaths(runtimeOptions); - - var runtimeConfigDevJsonFile = - Path.Combine(_runtimeOutputPath, _compilerOptions.OutputName + FileNameSuffixes.RuntimeConfigDevJson); - - using (var writer = new JsonTextWriter(new StreamWriter(File.Create(runtimeConfigDevJsonFile)))) - { - writer.Formatting = Formatting.Indented; - json.WriteTo(writer); - } - } - - private void AddAdditionalProbingPaths(JObject runtimeOptions) - { - if (_context.LockFile != null) - { - var additionalProbingPaths = new JArray(); - foreach (var packageFolder in _context.LockFile.PackageFolders) - { - // DotNetHost doesn't handle additional probing paths with a trailing slash - additionalProbingPaths.Add(PathUtility.EnsureNoTrailingDirectorySeparator(packageFolder.Path)); - } - - runtimeOptions.Add("additionalProbingPaths", additionalProbingPaths); - } - } - - private void WriteDeps(IEnumerable runtimeExports, IEnumerable compilationExports) - { - Directory.CreateDirectory(_runtimeOutputPath); - - var includeCompile = _compilerOptions.PreserveCompilationContext == true; - - var dependencyContext = new DependencyContextBuilder().Build( - compilerOptions: includeCompile ? _compilerOptions : null, - compilationExports: includeCompile ? compilationExports : null, - runtimeExports: runtimeExports, - portable: _context.IsPortable, - target: _context.TargetFramework, - runtime: _context.RuntimeIdentifier ?? string.Empty); - - var writer = new DependencyContextWriter(); - var depsJsonFilePath = Path.Combine(_runtimeOutputPath, _compilerOptions.OutputName + FileNameSuffixes.DepsJson); - using (var fileStream = File.Create(depsJsonFilePath)) - { - writer.Write(dependencyContext, fileStream); - } - } - - private void GenerateBindingRedirects(LibraryExporter exporter) - { - var outputName = _outputPaths.RuntimeFiles.Assembly; - var configFile = outputName + Constants.ConfigSuffix; - - var existingConfig = new DirectoryInfo(_context.ProjectDirectory) - .EnumerateFiles() - .FirstOrDefault(f => f.Name.Equals("app.config", StringComparison.OrdinalIgnoreCase)); - - if (existingConfig != null) - { - File.Copy(existingConfig.FullName, configFile, true); - } - - List configFiles = new List(); - configFiles.Add(configFile); - - foreach (var export in exporter.GetDependencies()) - { - var dependencyExecutables = export.RuntimeAssemblyGroups.GetDefaultAssets() - .Where(asset => asset.FileName.ToLower().EndsWith(FileNameSuffixes.DotNet.Exe)) - .Select(asset => Path.Combine(_runtimeOutputPath, asset.FileName)); - - foreach (var executable in dependencyExecutables) - { - configFile = executable + Constants.ConfigSuffix; - configFiles.Add(configFile); - } - } - - exporter.GetAllExports().GenerateBindingRedirects(configFiles); - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs deleted file mode 100644 index 7ae531785..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ /dev/null @@ -1,84 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.ProjectModel.Compilation; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public static class LibraryExporterExtensions - { - public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) - { - return - exporter.GetDependencies(LibraryType.Project); - } - - public static void CopyTo(this IEnumerable assets, string destinationPath) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } - - foreach (var asset in assets) - { - var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - File.Copy(asset.ResolvedPath, file, overwrite: true); - RemoveFileAttribute(file, FileAttributes.ReadOnly); - } - } - - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } - - foreach (var asset in assets) - { - var targetName = ResolveTargetName(destinationPath, asset); - var transformedFile = asset.GetTransformedFile(tempLocation); - - File.Copy(transformedFile, targetName, overwrite: true); - RemoveFileAttribute(targetName, FileAttributes.ReadOnly); - } - } - - private static void RemoveFileAttribute(String file, FileAttributes attribute) - { - if (File.Exists(file)) - { - var fileAttributes = File.GetAttributes(file); - if ((fileAttributes & attribute) == attribute) - { - File.SetAttributes(file, fileAttributes & ~attribute); - } - } - } - - private static string ResolveTargetName(string destinationPath, LibraryAsset asset) - { - string targetName; - if (!string.IsNullOrEmpty(asset.RelativePath)) - { - targetName = Path.Combine(destinationPath, asset.RelativePath); - var destinationAssetPath = Path.GetDirectoryName(targetName); - - if (!Directory.Exists(destinationAssetPath)) - { - Directory.CreateDirectory(destinationAssetPath); - } - } - else - { - targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - } - return targetName; - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/Microsoft.DotNet.Compiler.Common.xproj b/src/Microsoft.DotNet.Compiler.Common/Microsoft.DotNet.Compiler.Common.xproj deleted file mode 100644 index e7b0225ee..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/Microsoft.DotNet.Compiler.Common.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - a16958e1-24c7-4f1e-b317-204ad91625dd - Microsoft.Dotnet.Cli.Compiler.Common - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin - - - - 2.0 - - - diff --git a/src/Microsoft.DotNet.Compiler.Common/OptionTemplate.cs b/src/Microsoft.DotNet.Compiler.Common/OptionTemplate.cs deleted file mode 100644 index 7d31a72e0..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/OptionTemplate.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - internal class OptionTemplate - { - public string Template { get; } - public string ShortName { get; } - public string LongName { get; } - - private static char[] s_separator = { '|' }; - public OptionTemplate(string template) - { - Template = template; - - foreach (var part in Template.Split(s_separator, 2, StringSplitOptions.RemoveEmptyEntries)) - { - if (part.Length == 1) - { - ShortName = part; - } - else - { - LongName = part; - } - } - - if (string.IsNullOrEmpty(LongName) && string.IsNullOrEmpty(ShortName)) - { - throw new ArgumentException($"Invalid template pattern '{template}'", nameof(template)); - } - } - - public string ToLongArg(object value) - { - return $"--{LongName}:{value}"; - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/ProjectContextExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/ProjectContextExtensions.cs deleted file mode 100644 index d51ec02e9..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/ProjectContextExtensions.cs +++ /dev/null @@ -1,67 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.ProjectModel; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Cli.Compiler.Common -{ - public static class ProjectContextExtensions - { - public static string ProjectName(this ProjectContext context) => context.RootProject.Identity.Name; - - public static string GetDisplayName(this ProjectContext context) => $"{context.RootProject.Identity.Name} ({context.TargetFramework})"; - - public static CommonCompilerOptions GetLanguageSpecificCompilerOptions(this ProjectContext context, NuGetFramework framework, string configurationName) - { - var baseOption = context.ProjectFile.GetCompilerOptions(framework, configurationName); - - IReadOnlyList defaultSuppresses; - var compilerName = baseOption.CompilerName ?? "csc"; - if (DefaultCompilerWarningSuppresses.Suppresses.TryGetValue(compilerName, out defaultSuppresses)) - { - baseOption.SuppressWarnings = (baseOption.SuppressWarnings ?? Enumerable.Empty()).Concat(defaultSuppresses).Distinct(); - } - - return baseOption; - } - - public static string GetSDKVersionFile(this ProjectContext context, string configuration, string buildBasePath, string outputPath) - { - var intermediatePath = context.GetOutputPaths(configuration, buildBasePath, outputPath).IntermediateOutputDirectoryPath; - return Path.Combine(intermediatePath, ".SDKVersion"); - } - - public static string IncrementalCacheFile(this ProjectContext context, string configuration, string buildBasePath, string outputPath) - { - var intermediatePath = context.GetOutputPaths(configuration, buildBasePath, outputPath).IntermediateOutputDirectoryPath; - return Path.Combine(intermediatePath, ".IncrementalCache"); - } - - // used in incremental compilation for the key file - public static CommonCompilerOptions ResolveCompilationOptions(this ProjectContext context, string configuration) - { - var compilerOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration); - - // Path to strong naming key in environment variable overrides path in project.json - var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile); - - if (!string.IsNullOrWhiteSpace(environmentKeyFile)) - { - compilerOptions.KeyFile = environmentKeyFile; - } - else if (!string.IsNullOrWhiteSpace(compilerOptions.KeyFile)) - { - // Resolve full path to key file - compilerOptions.KeyFile = - Path.GetFullPath(Path.Combine(context.ProjectFile.ProjectDirectory, compilerOptions.KeyFile)); - } - return compilerOptions; - } - } -} diff --git a/src/Microsoft.DotNet.Compiler.Common/Properties/Properties.cs b/src/Microsoft.DotNet.Compiler.Common/Properties/Properties.cs deleted file mode 100644 index 046cd5ad1..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/Properties/Properties.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyMetadataAttribute("Serviceable", "True")] -[assembly: InternalsVisibleTo("dotnet-compile.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file diff --git a/src/Microsoft.DotNet.Compiler.Common/project.json b/src/Microsoft.DotNet.Compiler.Common/project.json deleted file mode 100644 index c740966e1..000000000 --- a/src/Microsoft.DotNet.Compiler.Common/project.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0-preview3-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk" - }, - "dependencies": { - "Microsoft.CodeAnalysis.CSharp": "2.0.0-beta6-60922-08", - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "Microsoft.DotNet.Cli.Utils": { - "target": "project" - }, - "Microsoft.DotNet.Files": { - "target": "project" - }, - "NuGet.ProjectModel": "3.6.0-rc-1984" - }, - "frameworks": { - "netstandard1.5": { - "imports": [ - "portable-net45+wp80+win8+wpa81+dnxcore50" - ] - } - }, - "scripts": {} -} diff --git a/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs b/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs index df2d85931..fe644332b 100644 --- a/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs +++ b/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs @@ -86,7 +86,7 @@ namespace Microsoft.DotNet.Configurer private bool RestoreTemporaryProject(string extractedPackagesArchiveDirectory, string workingDirectory) { return RunCommand( - "restore3", + "restore", new[] {"-s", extractedPackagesArchiveDirectory}, workingDirectory); } diff --git a/src/Microsoft.DotNet.Configurer/project.json b/src/Microsoft.DotNet.Configurer/project.json index 2479637f5..7c1046a89 100644 --- a/src/Microsoft.DotNet.Configurer/project.json +++ b/src/Microsoft.DotNet.Configurer/project.json @@ -11,9 +11,6 @@ "Microsoft.DotNet.Cli.Utils": { "target": "project" }, - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, "Microsoft.DotNet.Archive": { "target": "project" } diff --git a/src/Microsoft.DotNet.Files/ContentFiles.cs b/src/Microsoft.DotNet.Files/ContentFiles.cs deleted file mode 100644 index b6e5ada0a..000000000 --- a/src/Microsoft.DotNet.Files/ContentFiles.cs +++ /dev/null @@ -1,120 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.Tools.Common; - -namespace Microsoft.DotNet.Files -{ - public class ContentFiles - { - private readonly ProjectContext _context; - - public ContentFiles(ProjectContext context) - { - _context = context; - } - - public void StructuredCopyTo(string targetDirectory) - { - var sourceFiles = _context - .ProjectFile - .Files - .GetContentFiles(); - - var sourceDirectory = _context.ProjectDirectory; - - if (sourceFiles == null) - { - throw new ArgumentNullException(nameof(sourceFiles)); - } - - sourceDirectory = EnsureTrailingSlash(sourceDirectory); - targetDirectory = EnsureTrailingSlash(targetDirectory); - - var pathMap = sourceFiles - .ToDictionary(s => s, - s => Path.Combine(targetDirectory, - PathUtility.GetRelativePathIgnoringDirectoryTraversals(sourceDirectory, s))); - - foreach (var targetDir in pathMap.Values - .Select(Path.GetDirectoryName) - .Distinct() - .Where(t => !Directory.Exists(t))) - { - Directory.CreateDirectory(targetDir); - } - - foreach (var sourceFilePath in pathMap.Keys) - { - File.Copy( - sourceFilePath, - pathMap[sourceFilePath], - overwrite: true); - } - - RemoveAttributeFromFiles(pathMap.Values, FileAttributes.ReadOnly); - } - - public void StructuredCopyTo(string targetDirectory, IEnumerable includeEntries) - { - if (includeEntries == null) - { - return; - } - - foreach (var targetDir in includeEntries - .Select(f => Path.GetDirectoryName(f.TargetPath)) - .Distinct() - .Where(t => !Directory.Exists(t))) - { - Directory.CreateDirectory(targetDir); - } - - foreach (var file in includeEntries) - { - File.Copy(file.SourcePath, file.TargetPath, overwrite: true); - } - - RemoveAttributeFromFiles(includeEntries.Select(f => f.TargetPath), FileAttributes.ReadOnly); - } - - private static void RemoveAttributeFromFiles(IEnumerable files, FileAttributes attribute) - { - foreach (var file in files) - { - var fileAttributes = File.GetAttributes(file); - if ((fileAttributes & attribute) == attribute) - { - File.SetAttributes(file, fileAttributes & ~attribute); - } - } - } - - private static string EnsureTrailingSlash(string path) - { - return EnsureTrailingCharacter(path, Path.DirectorySeparatorChar); - } - - private static string EnsureTrailingCharacter(string path, char trailingCharacter) - { - if (path == null) - { - throw new ArgumentNullException(nameof(path)); - } - - // if the path is empty, we want to return the original string instead of a single trailing character. - if (path.Length == 0 || path[path.Length - 1] == trailingCharacter) - { - return path; - } - - return path + trailingCharacter; - } - } -} diff --git a/src/Microsoft.DotNet.Files/Microsoft.DotNet.Files.xproj b/src/Microsoft.DotNet.Files/Microsoft.DotNet.Files.xproj deleted file mode 100644 index 0dca981d4..000000000 --- a/src/Microsoft.DotNet.Files/Microsoft.DotNet.Files.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - d521dd9f-0614-4929-93b4-d8fa5682c174 - Microsoft.DotNet.Files - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Files/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.Files/Properties/AssemblyInfo.cs deleted file mode 100644 index bd44bced5..000000000 --- a/src/Microsoft.DotNet.Files/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyMetadataAttribute("Serviceable", "True")] diff --git a/src/Microsoft.DotNet.Files/project.json b/src/Microsoft.DotNet.Files/project.json deleted file mode 100644 index a78ab145f..000000000 --- a/src/Microsoft.DotNet.Files/project.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": "1.0.0-preview3-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk" - }, - "description": "Abstraction to interact with the file system and file paths.", - "dependencies": { - "Microsoft.DotNet.Cli.Utils": { - "target": "project" - }, - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "System.Linq.Expressions": "4.1.0" - }, - "frameworks": { - "netstandard1.5": { - "imports": [ - "portable-net45+wp80+win8+wpa81+dnxcore50" - ] - } - }, - "scripts": {} -} diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ConstantPackageNames.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ConstantPackageNames.cs index 1f2e710d2..ada280bbf 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ConstantPackageNames.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ConstantPackageNames.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration { - public class ConstantPackageNames + internal class ConstantPackageNames { public const string CSdkPackageName = "Microsoft.NET.Sdk"; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs b/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs index 66251c2e5..90adfc19f 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/DefaultMigrationRuleSet.cs @@ -5,7 +5,7 @@ using Microsoft.DotNet.ProjectJsonMigration.Rules; namespace Microsoft.DotNet.ProjectJsonMigration { - public class DefaultMigrationRuleSet : IMigrationRule + internal class DefaultMigrationRuleSet : IMigrationRule { private IMigrationRule[] Rules => new IMigrationRule[] { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MSBuildExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MSBuildExtensions.cs index 9d42425ae..2d0d9bbfd 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MSBuildExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MSBuildExtensions.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Microsoft.DotNet.ProjectJsonMigration { - public static class MSBuildExtensions + internal static class MSBuildExtensions { public static IEnumerable GetEncompassedIncludes(this ProjectItemElement item, ProjectItemElement otherItem) diff --git a/src/Microsoft.DotNet.ProjectModel/AnalyzerOptions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/AnalyzerOptions.cs similarity index 92% rename from src/Microsoft.DotNet.ProjectModel/AnalyzerOptions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/AnalyzerOptions.cs index d27b3a85c..87cdc0eee 100644 --- a/src/Microsoft.DotNet.ProjectModel/AnalyzerOptions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/AnalyzerOptions.cs @@ -3,9 +3,9 @@ using System; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class AnalyzerOptions : IEquatable + internal class AnalyzerOptions : IEquatable { /// /// The identifier indicating the project language as defined by NuGet. diff --git a/src/Microsoft.DotNet.ProjectModel/BuildWorkspace.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/BuildWorkspace.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/BuildWorkspace.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/BuildWorkspace.cs index 232abdae7..39af35dc8 100644 --- a/src/Microsoft.DotNet.ProjectModel/BuildWorkspace.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/BuildWorkspace.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class BuildWorkspace : Workspace + internal class BuildWorkspace : Workspace { public BuildWorkspace(ProjectReaderSettings settings) : base(settings, false) { } diff --git a/src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/CommonCompilerOptions.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/CommonCompilerOptions.cs index 9411a2757..7bf66c2b2 100644 --- a/src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/CommonCompilerOptions.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.DotNet.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Files; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class CommonCompilerOptions + internal class CommonCompilerOptions { public IEnumerable Defines { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/AnalyzerAssembly.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/AnalyzerAssembly.cs similarity index 92% rename from src/Microsoft.DotNet.ProjectModel/Compilation/AnalyzerAssembly.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/AnalyzerAssembly.cs index 2e2236ae3..6ec2b0b27 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/AnalyzerAssembly.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/AnalyzerAssembly.cs @@ -3,9 +3,9 @@ using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { - public class AnalyzerReference + internal class AnalyzerReference { /// /// The fully-qualified path to the analyzer assembly. diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAsset.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAsset.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAsset.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAsset.cs index acd983dbf..93523331b 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAsset.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAsset.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { public struct LibraryAsset { diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAssetExtension.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAssetExtension.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAssetExtension.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAssetExtension.cs index 534a114a2..c9f46e44b 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAssetExtension.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAssetExtension.cs @@ -5,9 +5,9 @@ using System; using System.IO; using System.Reflection; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { - public static class LibraryAssetExtensions + internal static class LibraryAssetExtensions { private const string NativeImageSufix = ".ni"; diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAssetGroup.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAssetGroup.cs similarity index 91% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAssetGroup.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAssetGroup.cs index fd1b9809f..941fc0f48 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryAssetGroup.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryAssetGroup.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { - public class LibraryAssetGroup + internal class LibraryAssetGroup { public LibraryAssetGroup(string runtime, params LibraryAsset[] assets) : this(runtime, (IEnumerable)assets) { } public LibraryAssetGroup(params LibraryAsset[] assets) : this(string.Empty, (IEnumerable)assets) { } diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExport.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExport.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExport.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExport.cs index 4e68c549b..13a0a1388 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExport.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExport.cs @@ -4,10 +4,10 @@ using System.Collections.Generic; using System.Diagnostics; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class LibraryExport + internal class LibraryExport { /// /// Gets the library that produced this export diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExportBuilder.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExportBuilder.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExportBuilder.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExportBuilder.cs index 650f93d6f..54b55d7b1 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExportBuilder.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExportBuilder.cs @@ -4,9 +4,9 @@ using System; using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { - public class LibraryExportBuilder + internal class LibraryExportBuilder { private IList _runtimeAssemblyGroups; diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExporter.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExporter.cs index 8c6d00a1a..fa00c6020 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryExporter.cs @@ -5,18 +5,18 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Compilation.Preprocessor; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.Resolution; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Compilation.Preprocessor; +using Microsoft.DotNet.Internal.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Resolution; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using Microsoft.DotNet.Tools.Compiler; using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { - public class LibraryExporter + internal class LibraryExporter { private readonly string _configuration; private readonly string _runtime; diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryResourceAssembly.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryResourceAssembly.cs similarity index 80% rename from src/Microsoft.DotNet.ProjectModel/Compilation/LibraryResourceAssembly.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryResourceAssembly.cs index 1520352c3..79e93d615 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryResourceAssembly.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/LibraryResourceAssembly.cs @@ -1,9 +1,9 @@ // 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.ProjectModel.Compilation +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation { - public class LibraryResourceAssembly + internal class LibraryResourceAssembly { public LibraryResourceAssembly(LibraryAsset asset, string locale) { diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFileParameters.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFileParameters.cs similarity index 83% rename from src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFileParameters.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFileParameters.cs index eca04ad66..25f9e2953 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFileParameters.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFileParameters.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace Microsoft.DotNet.ProjectModel.Compilation.Preprocessor +namespace Microsoft.DotNet.Internal.ProjectModel.Compilation.Preprocessor { - public class PPFileParameters + internal class PPFileParameters { public static IDictionary CreateForProject(Project project) { diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFilePreprocessor.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFilePreprocessor.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFilePreprocessor.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFilePreprocessor.cs index c2d597c97..ebbf4d735 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFilePreprocessor.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFilePreprocessor.cs @@ -7,7 +7,7 @@ using System.IO; namespace Microsoft.DotNet.Tools.Compiler { - public class PPFilePreprocessor + internal class PPFilePreprocessor { public static void Preprocess(Stream input, Stream output, IDictionary parameters) { diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFileTokenizer.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFileTokenizer.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFileTokenizer.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFileTokenizer.cs index 8567aeb48..1bbfbe212 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/Preprocessor/PPFileTokenizer.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Compilation/Preprocessor/PPFileTokenizer.cs @@ -6,7 +6,7 @@ using System.Text; namespace Microsoft.DotNet.Tools.Compiler { - public class PPFileTokenizer + internal class PPFileTokenizer { private readonly string _text; private int _index; @@ -103,7 +103,7 @@ namespace Microsoft.DotNet.Tools.Compiler return new Token(TokenCategory.Text, sb.ToString()); } - public class Token + internal class Token { public string Value { get; private set; } public TokenCategory Category { get; private set; } diff --git a/src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/CompilationOutputFiles.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/CompilationOutputFiles.cs index 463451d4f..588bb3734 100644 --- a/src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/CompilationOutputFiles.cs @@ -4,13 +4,13 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.Resources; +using Microsoft.DotNet.Internal.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Resources; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class CompilationOutputFiles + internal class CompilationOutputFiles { protected readonly Project Project; protected readonly string Configuration; diff --git a/src/Microsoft.DotNet.ProjectModel/Constants.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Constants.cs similarity index 91% rename from src/Microsoft.DotNet.ProjectModel/Constants.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Constants.cs index 5b0100a00..3175fcbf4 100644 --- a/src/Microsoft.DotNet.ProjectModel/Constants.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Constants.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { internal static class Constants { diff --git a/src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DependencyContextBuilder.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DependencyContextBuilder.cs index d59047c3b..bf339806a 100644 --- a/src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DependencyContextBuilder.cs @@ -7,16 +7,16 @@ using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Resolution; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.Compilation; +using Microsoft.DotNet.Internal.ProjectModel.Resolution; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using NuGet.Frameworks; using NuGet.LibraryModel; namespace Microsoft.Extensions.DependencyModel { - public class DependencyContextBuilder + internal class DependencyContextBuilder { private readonly string _referenceAssembliesPath; diff --git a/src/Microsoft.DotNet.ProjectModel/DesignTimeWorkspace.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DesignTimeWorkspace.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/DesignTimeWorkspace.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DesignTimeWorkspace.cs index 33982fa2e..9c10b0514 100644 --- a/src/Microsoft.DotNet.ProjectModel/DesignTimeWorkspace.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DesignTimeWorkspace.cs @@ -7,9 +7,9 @@ using System.IO; using System.Linq; using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class DesignTimeWorkspace : Workspace + internal class DesignTimeWorkspace : Workspace { private readonly HashSet _projects = new HashSet(StringComparer.OrdinalIgnoreCase); diff --git a/src/Microsoft.DotNet.ProjectModel/DiagnosticMessage.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DiagnosticMessage.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/DiagnosticMessage.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DiagnosticMessage.cs index 1a7104c20..a8c8c07b4 100644 --- a/src/Microsoft.DotNet.ProjectModel/DiagnosticMessage.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DiagnosticMessage.cs @@ -1,12 +1,12 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { /// /// Represents a single diagnostic message, such as a compilation error or a project.json parsing error. /// - public class DiagnosticMessage + internal class DiagnosticMessage { public DiagnosticMessage(string errorCode, string message, string filePath, DiagnosticMessageSeverity severity) : this(errorCode, message, filePath, severity, startLine: 1, startColumn: 0) diff --git a/src/Microsoft.DotNet.ProjectModel/DiagnosticMessageSeverity.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DiagnosticMessageSeverity.cs similarity index 88% rename from src/Microsoft.DotNet.ProjectModel/DiagnosticMessageSeverity.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DiagnosticMessageSeverity.cs index 36a0c6fb8..2ead2eed5 100644 --- a/src/Microsoft.DotNet.ProjectModel/DiagnosticMessageSeverity.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DiagnosticMessageSeverity.cs @@ -1,7 +1,7 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { /// /// Specifies the severity of a . diff --git a/src/Microsoft.DotNet.ProjectModel/DirectoryNames.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DirectoryNames.cs similarity index 52% rename from src/Microsoft.DotNet.ProjectModel/DirectoryNames.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DirectoryNames.cs index bafbf8c0e..2b8e8b7ed 100644 --- a/src/Microsoft.DotNet.ProjectModel/DirectoryNames.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/DirectoryNames.cs @@ -1,6 +1,6 @@ -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static class DirectoryNames + internal static class DirectoryNames { public const string Bin = "bin"; diff --git a/src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/EnvironmentNames.cs similarity index 80% rename from src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/EnvironmentNames.cs index 6e0f9f02f..9c528501b 100644 --- a/src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/EnvironmentNames.cs @@ -1,9 +1,9 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class EnvironmentNames + internal class EnvironmentNames { public static readonly string PackagesStore = "NUGET_PACKAGES"; public static readonly string StrongNameKeyFile = "DOTNET_BUILD_STRONG_NAME_KEYFILE"; diff --git a/src/Microsoft.DotNet.ProjectModel/ErrorCodes.DotNet.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ErrorCodes.DotNet.cs similarity index 91% rename from src/Microsoft.DotNet.ProjectModel/ErrorCodes.DotNet.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ErrorCodes.DotNet.cs index e17418174..5179d14d7 100644 --- a/src/Microsoft.DotNet.ProjectModel/ErrorCodes.DotNet.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ErrorCodes.DotNet.cs @@ -1,9 +1,9 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static partial class ErrorCodes + internal static partial class ErrorCodes { // Target framework not installed public static readonly string DOTNET1011 = nameof(DOTNET1011); diff --git a/src/Microsoft.DotNet.ProjectModel/ErrorCodes.NuGet.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ErrorCodes.NuGet.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/ErrorCodes.NuGet.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ErrorCodes.NuGet.cs index 0c3b0ca71..da0f05837 100644 --- a/src/Microsoft.DotNet.ProjectModel/ErrorCodes.NuGet.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ErrorCodes.NuGet.cs @@ -1,9 +1,9 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static partial class ErrorCodes + internal static partial class ErrorCodes { // The dependency A could not be resolved. public static readonly string NU1001 = nameof(NU1001); diff --git a/src/Microsoft.DotNet.ProjectModel/FileFormatException.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileFormatException.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/FileFormatException.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileFormatException.cs index 006ed1371..7dc7088db 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileFormatException.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileFormatException.cs @@ -5,7 +5,7 @@ using System; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { public sealed class FileFormatException : Exception { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileNameSuffixes.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileNameSuffixes.cs new file mode 100644 index 000000000..ba5fbcd7b --- /dev/null +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileNameSuffixes.cs @@ -0,0 +1,73 @@ +using System; +using Microsoft.DotNet.PlatformAbstractions; + +namespace Microsoft.DotNet.Internal.ProjectModel +{ + internal static class FileNameSuffixes + { + public const string DepsJson = ".deps.json"; + public const string RuntimeConfigJson = ".runtimeconfig.json"; + public const string RuntimeConfigDevJson = ".runtimeconfig.dev.json"; + + public static PlatformFileNameSuffixes CurrentPlatform + { + get + { + switch (RuntimeEnvironment.OperatingSystemPlatform) + { + case Platform.Windows: + return Windows; + case Platform.Darwin: + return OSX; + case Platform.Linux: + return Linux; + default: + throw new InvalidOperationException("Unknown Platform"); + } + } + } + + public static PlatformFileNameSuffixes DotNet { get; } = new PlatformFileNameSuffixes + { + DynamicLib = ".dll", + Exe = ".exe", + ProgramDatabase = ".pdb", + StaticLib = ".lib" + }; + + public static PlatformFileNameSuffixes Windows { get; } = new PlatformFileNameSuffixes + { + DynamicLib = ".dll", + Exe = ".exe", + ProgramDatabase = ".pdb", + StaticLib = ".lib" + }; + + public static PlatformFileNameSuffixes OSX { get; } = new PlatformFileNameSuffixes + { + DynamicLib = ".dylib", + Exe = "", + ProgramDatabase = ".pdb", + StaticLib = ".a" + }; + + public static PlatformFileNameSuffixes Linux { get; } = new PlatformFileNameSuffixes + { + DynamicLib = ".so", + Exe = "", + ProgramDatabase = ".pdb", + StaticLib = ".a" + }; + + public struct PlatformFileNameSuffixes + { + public string DynamicLib { get; internal set; } + + public string Exe { get; internal set; } + + public string ProgramDatabase { get; internal set; } + + public string StaticLib { get; internal set; } + } + } +} diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs similarity index 74% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs index 69d5fe357..37f31803e 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoBase.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions { - public abstract class DirectoryInfoBase : FileSystemInfoBase + internal abstract class DirectoryInfoBase : FileSystemInfoBase { public abstract IEnumerable EnumerateFileSystemInfos(); diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs index 3d3ec1236..422a3580b 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/DirectoryInfoWrapper.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.IO; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions { - public class DirectoryInfoWrapper : DirectoryInfoBase + internal class DirectoryInfoWrapper : DirectoryInfoBase { private readonly DirectoryInfo _directoryInfo; private readonly bool _isParentPath; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoBase.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoBase.cs similarity index 57% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoBase.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoBase.cs index 5eee717b0..2a4dc403f 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoBase.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoBase.cs @@ -1,9 +1,9 @@ // 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.ProjectModel.FileSystemGlobbing.Abstractions +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions { - public abstract class FileInfoBase : FileSystemInfoBase + internal abstract class FileInfoBase : FileSystemInfoBase { } } \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs similarity index 84% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs index addafc60d..2cd2abcab 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileInfoWrapper.cs @@ -3,9 +3,9 @@ using System.IO; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions { - public class FileInfoWrapper : FileInfoBase + internal class FileInfoWrapper : FileInfoBase { private FileInfo _fileInfo; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs similarity index 73% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs index e6826cfb2..09a88909a 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Abstractions/FileSystemInfoBase.cs @@ -1,9 +1,9 @@ // 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.ProjectModel.FileSystemGlobbing.Abstractions +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions { - public abstract class FileSystemInfoBase + internal abstract class FileSystemInfoBase { public abstract string Name { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/FilePatternMatch.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/FilePatternMatch.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/FilePatternMatch.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/FilePatternMatch.cs index 498f976b0..b3bb6d075 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/FilePatternMatch.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/FilePatternMatch.cs @@ -4,7 +4,7 @@ using System; using Microsoft.DotNet.PlatformAbstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing { public struct FilePatternMatch : IEquatable { diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/ILinearPattern.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/ILinearPattern.cs similarity index 68% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/ILinearPattern.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/ILinearPattern.cs index a5cd7419b..9fcaa0306 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/ILinearPattern.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/ILinearPattern.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { - public interface ILinearPattern : IPattern + internal interface ILinearPattern : IPattern { IList Segments { get; } } diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPathSegment.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPathSegment.cs similarity index 69% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPathSegment.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPathSegment.cs index 9d15792cb..64300e4f6 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPathSegment.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPathSegment.cs @@ -1,9 +1,9 @@ // 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.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { - public interface IPathSegment + internal interface IPathSegment { bool CanProduceStem { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPattern.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPattern.cs similarity index 73% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPattern.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPattern.cs index c67d87abe..d7bc796cd 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPattern.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPattern.cs @@ -1,9 +1,9 @@ // 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.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { - public interface IPattern + internal interface IPattern { IPatternContext CreatePatternContextForInclude(); diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPatternContext.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPatternContext.cs similarity index 70% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPatternContext.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPatternContext.cs index ac98cb297..5b86cb6b7 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IPatternContext.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IPatternContext.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { - public interface IPatternContext + internal interface IPatternContext { void Declare(Action onDeclare); diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IRaggedPattern.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IRaggedPattern.cs similarity index 76% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IRaggedPattern.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IRaggedPattern.cs index 66915b91c..2bc081089 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/IRaggedPattern.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/IRaggedPattern.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { - public interface IRaggedPattern : IPattern + internal interface IRaggedPattern : IPattern { IList Segments { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/MatcherContext.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/MatcherContext.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/MatcherContext.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/MatcherContext.cs index 22565a06a..cb6298517 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/MatcherContext.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/MatcherContext.cs @@ -4,13 +4,13 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Util; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Util; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { - public class MatcherContext + internal class MatcherContext { private readonly DirectoryInfoBase _root; private readonly IList _includePatternContexts; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs similarity index 71% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs index 1b50202ca..6569c70ed 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/CurrentPathSegment.cs @@ -3,9 +3,9 @@ using System; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments { - public class CurrentPathSegment : IPathSegment + internal class CurrentPathSegment : IPathSegment { public bool CanProduceStem { get { return false; } } diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs similarity index 85% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs index 83b4dbe81..e41a1e3a3 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/LiteralPathSegment.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Util; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Util; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments { - public class LiteralPathSegment : IPathSegment + internal class LiteralPathSegment : IPathSegment { private readonly StringComparison _comparisonType; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs similarity index 76% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs index 02b336990..c83618abc 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/ParentPathSegment.cs @@ -3,9 +3,9 @@ using System; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments { - public class ParentPathSegment : IPathSegment + internal class ParentPathSegment : IPathSegment { private static readonly string LiteralParent = ".."; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs similarity index 70% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs index 1e9c607df..9337247fc 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/RecursiveWildcardSegment.cs @@ -3,9 +3,9 @@ using System; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments { - public class RecursiveWildcardSegment : IPathSegment + internal class RecursiveWildcardSegment : IPathSegment { public bool CanProduceStem { get { return true; } } diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs index d0eee3b0c..66e944dfb 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PathSegments/WildcardPathSegment.cs @@ -4,9 +4,9 @@ using System; using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments { - public class WildcardPathSegment : IPathSegment + internal class WildcardPathSegment : IPathSegment { // It doesn't matter which StringComparison type is used in this MatchAll segment because // all comparing are skipped since there is no content in the segment. diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs similarity index 79% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs index 9cc35670e..6afc07c3d 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContext.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public abstract class PatternContext : IPatternContext + internal abstract class PatternContext : IPatternContext { private Stack _stack = new Stack(); protected TFrame Frame; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs index c2767590d..7a22bd7c8 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinear.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public abstract class PatternContextLinear + internal abstract class PatternContextLinear : PatternContext { public PatternContextLinear(ILinearPattern pattern) diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs similarity index 75% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs index 17d0dffdb..f23f608c7 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearExclude.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public class PatternContextLinearExclude : PatternContextLinear + internal class PatternContextLinearExclude : PatternContextLinear { public PatternContextLinearExclude(ILinearPattern pattern) : base(pattern) diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs similarity index 84% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs index 5deb186aa..d2852b3e4 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextLinearInclude.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public class PatternContextLinearInclude : PatternContextLinear + internal class PatternContextLinearInclude : PatternContextLinear { public PatternContextLinearInclude(ILinearPattern pattern) : base(pattern) diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs index ea2dab475..7b2da0d8b 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRagged.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public abstract class PatternContextRagged : PatternContext + internal abstract class PatternContextRagged : PatternContext { public PatternContextRagged(IRaggedPattern pattern) { diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs similarity index 82% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs index fa757828d..76ebc353f 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedExclude.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public class PatternContextRaggedExclude : PatternContextRagged + internal class PatternContextRaggedExclude : PatternContextRagged { public PatternContextRaggedExclude(IRaggedPattern pattern) : base(pattern) diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs similarity index 82% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs index 33bef4954..65e8e3051 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternContexts/PatternContextRaggedInclude.cs @@ -2,12 +2,12 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts { - public class PatternContextRaggedInclude : PatternContextRagged + internal class PatternContextRaggedInclude : PatternContextRagged { public PatternContextRaggedInclude(IRaggedPattern pattern) : base(pattern) diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternTestResult.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternTestResult.cs similarity index 90% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternTestResult.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternTestResult.cs index 408dd29be..20146a528 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/PatternTestResult.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/PatternTestResult.cs @@ -1,7 +1,7 @@ // 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.ProjectModel.FileSystemGlobbing.Internal +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal { public struct PatternTestResult { diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs index c6995bce5..fc275fe06 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Internal/Patterns/PatternBuilder.cs @@ -3,12 +3,12 @@ using System; using System.Collections.Generic; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PathSegments; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.PatternContexts; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PathSegments; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.PatternContexts; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.Patterns +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.Patterns { - public class PatternBuilder + internal class PatternBuilder { private static readonly char[] _slashes = new[] { '/', '\\' }; private static readonly char[] _star = new[] { '*' }; diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Matcher.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Matcher.cs similarity index 80% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Matcher.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Matcher.cs index 64dc98586..1b93f480a 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Matcher.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Matcher.cs @@ -3,13 +3,13 @@ using System; using System.Collections.Generic; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Internal.Patterns; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Internal.Patterns; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing { - public class Matcher + internal class Matcher { private IList _includePatterns = new List(); private IList _excludePatterns = new List(); diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/MatcherExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/MatcherExtensions.cs similarity index 87% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/MatcherExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/MatcherExtensions.cs index f44e97ead..be4cfba4c 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/MatcherExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/MatcherExtensions.cs @@ -5,11 +5,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing { - public static class MatcherExtensions + internal static class MatcherExtensions { public static void AddExcludePatterns(this Matcher matcher, params IEnumerable[] excludePatternsGroups) { diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/PatternMatchingResult.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/PatternMatchingResult.cs similarity index 79% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/PatternMatchingResult.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/PatternMatchingResult.cs index 0a18b4b65..1cc933c01 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/PatternMatchingResult.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/PatternMatchingResult.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing { - public class PatternMatchingResult + internal class PatternMatchingResult { public PatternMatchingResult(IEnumerable files) { diff --git a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Util/StringComparisonHelper.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Util/StringComparisonHelper.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Util/StringComparisonHelper.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Util/StringComparisonHelper.cs index e7c8bfb7d..a35d6b483 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileSystemGlobbing/Util/StringComparisonHelper.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/FileSystemGlobbing/Util/StringComparisonHelper.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Util +namespace Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Util { internal static class StringComparisonHelper { diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeContext.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeContext.cs index bef8c47c7..bc90d63b0 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeContext.cs @@ -7,9 +7,9 @@ using System.IO; using System.Linq; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { - public class IncludeContext + internal class IncludeContext { private static readonly char[] PatternSeparator = new[] { ';' }; diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeEntry.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeEntry.cs similarity index 91% rename from src/Microsoft.DotNet.ProjectModel/Files/IncludeEntry.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeEntry.cs index aeb99cdc5..18786667d 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeEntry.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeEntry.cs @@ -4,9 +4,9 @@ using System; using Microsoft.DotNet.PlatformAbstractions; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { - public class IncludeEntry : IEquatable + internal class IncludeEntry : IEquatable { public string TargetPath { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeFilesResolver.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeFilesResolver.cs index f1baeb70f..537eeb7d9 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/IncludeFilesResolver.cs @@ -5,13 +5,13 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Utilities; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { - public class IncludeFilesResolver + internal class IncludeFilesResolver { public static IEnumerable GetIncludeFiles(IncludeContext context, string targetBasePath, IList diagnostics) { diff --git a/src/Microsoft.DotNet.ProjectModel/Files/NamedResourceReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/NamedResourceReader.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Files/NamedResourceReader.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/NamedResourceReader.cs index 6721a9fa6..c81829b0f 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/NamedResourceReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/NamedResourceReader.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { internal static class NamedResourceReader { diff --git a/src/Microsoft.DotNet.ProjectModel/Files/PackIncludeEntry.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PackIncludeEntry.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/Files/PackIncludeEntry.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PackIncludeEntry.cs index 615c42099..40bc57f1b 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/PackIncludeEntry.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PackIncludeEntry.cs @@ -5,9 +5,9 @@ using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { - public class PackIncludeEntry + internal class PackIncludeEntry { public string Target { get; } public string[] SourceGlobs { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/Files/PatternGroup.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PatternGroup.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Files/PatternGroup.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PatternGroup.cs index 80c8e8157..6bc6e8032 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/PatternGroup.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PatternGroup.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { - public class PatternGroup + internal class PatternGroup { private readonly List _excludeGroups = new List(); private readonly Matcher _matcher = new Matcher(); diff --git a/src/Microsoft.DotNet.ProjectModel/Files/PatternsCollectionHelper.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PatternsCollectionHelper.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Files/PatternsCollectionHelper.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PatternsCollectionHelper.cs index e87a316fb..83864bd64 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/PatternsCollectionHelper.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/PatternsCollectionHelper.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { internal static class PatternsCollectionHelper { diff --git a/src/Microsoft.DotNet.ProjectModel/Files/ProjectFilesCollection.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/ProjectFilesCollection.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Files/ProjectFilesCollection.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/ProjectFilesCollection.cs index 7cd84d78f..d86083a27 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/ProjectFilesCollection.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Files/ProjectFilesCollection.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel.Files +namespace Microsoft.DotNet.Internal.ProjectModel.Files { - public class ProjectFilesCollection + internal class ProjectFilesCollection { public static readonly string[] DefaultCompileBuiltInPatterns = new[] { @"**/*.cs" }; public static readonly string[] DefaultPreprocessPatterns = new[] { @"compiler/preprocess/**/*.cs" }; diff --git a/src/Microsoft.DotNet.ProjectModel/GlobalSettings.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/GlobalSettings.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/GlobalSettings.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/GlobalSettings.cs index 4f144f093..0b8886a21 100644 --- a/src/Microsoft.DotNet.ProjectModel/GlobalSettings.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/GlobalSettings.cs @@ -8,9 +8,9 @@ using System.IO; using Newtonsoft.Json; using System.Linq; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class GlobalSettings + internal class GlobalSettings { public const string FileName = "global.json"; diff --git a/src/Microsoft.DotNet.ProjectModel/Graph/ExportFile.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/ExportFile.cs similarity index 87% rename from src/Microsoft.DotNet.ProjectModel/Graph/ExportFile.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/ExportFile.cs index 226bd0d5f..92f586592 100644 --- a/src/Microsoft.DotNet.ProjectModel/Graph/ExportFile.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/ExportFile.cs @@ -2,9 +2,9 @@ using System.Linq; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel.Graph +namespace Microsoft.DotNet.Internal.ProjectModel.Graph { - public class ExportFile + internal class ExportFile { public static readonly string ExportFileName = "project.fragment.lock.json"; diff --git a/src/Microsoft.DotNet.ProjectModel/Graph/LockFileExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/LockFileExtensions.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/Graph/LockFileExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/LockFileExtensions.cs index 175e66679..0a6d879f3 100644 --- a/src/Microsoft.DotNet.ProjectModel/Graph/LockFileExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/LockFileExtensions.cs @@ -2,9 +2,9 @@ using System; using System.Linq; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel.Graph +namespace Microsoft.DotNet.Internal.ProjectModel.Graph { - public static class LockFileExtensions + internal static class LockFileExtensions { public static readonly int CurrentVersion = 2; diff --git a/src/Microsoft.DotNet.ProjectModel/Graph/LockFileLookup.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/LockFileLookup.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/Graph/LockFileLookup.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/LockFileLookup.cs index 4939f2f49..d45350fef 100644 --- a/src/Microsoft.DotNet.ProjectModel/Graph/LockFileLookup.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/LockFileLookup.cs @@ -7,9 +7,9 @@ using NuGet.LibraryModel; using NuGet.ProjectModel; using NuGet.Versioning; -namespace Microsoft.DotNet.ProjectModel.Graph +namespace Microsoft.DotNet.Internal.ProjectModel.Graph { - public class LockFileLookup + internal class LockFileLookup { // REVIEW: Case sensitivity? private readonly Dictionary, LockFileLibrary> _packages; diff --git a/src/Microsoft.DotNet.ProjectModel/Graph/ProjectLibraryDependency.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/ProjectLibraryDependency.cs similarity index 76% rename from src/Microsoft.DotNet.ProjectModel/Graph/ProjectLibraryDependency.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/ProjectLibraryDependency.cs index d67661aaa..5b2c015d5 100644 --- a/src/Microsoft.DotNet.ProjectModel/Graph/ProjectLibraryDependency.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Graph/ProjectLibraryDependency.cs @@ -1,8 +1,8 @@ using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectLibraryDependency : LibraryDependency + internal class ProjectLibraryDependency : LibraryDependency { public string SourceFilePath { get; set; } public int SourceLine { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/IProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/IProjectReader.cs similarity index 76% rename from src/Microsoft.DotNet.ProjectModel/IProjectReader.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/IProjectReader.cs index 981ecbc36..a9e8c61a2 100644 --- a/src/Microsoft.DotNet.ProjectModel/IProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/IProjectReader.cs @@ -1,9 +1,9 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public interface IProjectReader + internal interface IProjectReader { Project ReadProject(string projectPath, ProjectReaderSettings settings = null); } diff --git a/src/Microsoft.DotNet.ProjectModel/Internal/EmptyArray.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Internal/EmptyArray.cs similarity index 88% rename from src/Microsoft.DotNet.ProjectModel/Internal/EmptyArray.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Internal/EmptyArray.cs index d55b1456b..dad6516bb 100644 --- a/src/Microsoft.DotNet.ProjectModel/Internal/EmptyArray.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Internal/EmptyArray.cs @@ -1,7 +1,7 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { internal static class EmptyArray { diff --git a/src/Microsoft.DotNet.ProjectModel/LibraryDescription.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/LibraryDescription.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/LibraryDescription.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/LibraryDescription.cs index 10152c2a0..10a34a17d 100644 --- a/src/Microsoft.DotNet.ProjectModel/LibraryDescription.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/LibraryDescription.cs @@ -8,12 +8,12 @@ using Microsoft.DotNet.PlatformAbstractions; using NuGet.Frameworks; using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { /// /// Represents the result of resolving the library /// - public class LibraryDescription + internal class LibraryDescription { public LibraryDescription( LibraryIdentity identity, diff --git a/src/Microsoft.DotNet.ProjectModel/MSBuildProjectDescription.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/MSBuildProjectDescription.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/MSBuildProjectDescription.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/MSBuildProjectDescription.cs index 42b95ef72..9861892a5 100644 --- a/src/Microsoft.DotNet.ProjectModel/MSBuildProjectDescription.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/MSBuildProjectDescription.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { /// /// Represents an MSBuild project. @@ -14,7 +14,7 @@ namespace Microsoft.DotNet.ProjectModel /// Path points to the project's directory /// MSBuildPRojectPath points to the csproj file /// - public class MSBuildProjectDescription : TargetLibraryWithAssets + internal class MSBuildProjectDescription : TargetLibraryWithAssets { public MSBuildProjectDescription( string path, diff --git a/src/Microsoft.DotNet.ProjectModel/Microsoft.DotNet.ProjectModel.xproj b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Microsoft.DotNet.ProjectModel.xproj similarity index 100% rename from src/Microsoft.DotNet.ProjectModel/Microsoft.DotNet.ProjectModel.xproj rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Microsoft.DotNet.ProjectModel.xproj diff --git a/src/Microsoft.DotNet.ProjectModel/OutputPaths.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/OutputPaths.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/OutputPaths.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/OutputPaths.cs index 2628032d3..f2bdfd417 100644 --- a/src/Microsoft.DotNet.ProjectModel/OutputPaths.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/OutputPaths.cs @@ -3,9 +3,9 @@ using System; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class OutputPaths + internal class OutputPaths { private readonly string _runtimePath; private readonly RuntimeOutputFiles _runtimeFiles; diff --git a/src/Microsoft.DotNet.ProjectModel/OutputPathsCalculator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/OutputPathsCalculator.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/OutputPathsCalculator.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/OutputPathsCalculator.cs index f2a25bb45..d3269f61e 100644 --- a/src/Microsoft.DotNet.ProjectModel/OutputPathsCalculator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/OutputPathsCalculator.cs @@ -2,12 +2,12 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.IO; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class OutputPathsCalculator + internal class OutputPathsCalculator { private const string ObjDirectoryName = "obj"; private const string BinDirectoryName = "bin"; diff --git a/src/Microsoft.DotNet.ProjectModel/PackOptions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/PackOptions.cs similarity index 84% rename from src/Microsoft.DotNet.ProjectModel/PackOptions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/PackOptions.cs index ab8ee37ff..cd5677bb9 100644 --- a/src/Microsoft.DotNet.ProjectModel/PackOptions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/PackOptions.cs @@ -1,11 +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.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Files; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class PackOptions + internal class PackOptions { public string[] Tags { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/PackageDescription.cs similarity index 91% rename from src/Microsoft.DotNet.ProjectModel/PackageDescription.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/PackageDescription.cs index 62bd5be22..a296f0946 100644 --- a/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/PackageDescription.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.DotNet.ProjectModel.Resolution; +using Microsoft.DotNet.Internal.ProjectModel.Resolution; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class PackageDescription : TargetLibraryWithAssets + internal class PackageDescription : TargetLibraryWithAssets { public PackageDescription( string path, diff --git a/src/Microsoft.DotNet.ProjectModel/Project.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Project.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/Project.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Project.cs index 7a42b0748..f2177ad57 100644 --- a/src/Microsoft.DotNet.ProjectModel/Project.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Project.cs @@ -4,13 +4,13 @@ using System; using System.Collections.Generic; using System.IO; -using Microsoft.DotNet.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Files; using NuGet.Frameworks; using NuGet.Versioning; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class Project + internal class Project { public static readonly string FileName = "project.json"; @@ -71,8 +71,8 @@ namespace Microsoft.DotNet.ProjectModel public RuntimeOptions RuntimeOptions { get; set; } - public IList Runtimes { get; set; } - + public IList Runtimes { get; set; } + public IDictionary Commands { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); public IDictionary> Scripts { get; } = new Dictionary>(StringComparer.OrdinalIgnoreCase); diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectContext.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContext.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/ProjectContext.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContext.cs index 897a65b6a..df8b73458 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectContext.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContext.cs @@ -4,14 +4,14 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Resolution; +using Microsoft.DotNet.Internal.ProjectModel.Compilation; +using Microsoft.DotNet.Internal.ProjectModel.Resolution; using NuGet.Frameworks; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectContext + internal class ProjectContext { private string[] _runtimeFallbacks; diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectContextBuilder.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextBuilder.cs similarity index 99% rename from src/Microsoft.DotNet.ProjectModel/ProjectContextBuilder.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextBuilder.cs index d5e0a7517..de60159f8 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectContextBuilder.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextBuilder.cs @@ -6,19 +6,19 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using Microsoft.DotNet.InternalAbstractions; +using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel.Graph; -using Microsoft.DotNet.ProjectModel.Resolution; +using Microsoft.DotNet.Internal.ProjectModel.Graph; +using Microsoft.DotNet.Internal.ProjectModel.Resolution; using NuGet.Common; using NuGet.Configuration; using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectContextBuilder + internal class ProjectContextBuilder { // Note: When adding a property, make sure to add it to Clone below. You'll also need to update the CloneTest in // Microsoft.DotNet.ProjectModel.Tests.ProjectContextBuilderTests diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectContextCollection.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextCollection.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/ProjectContextCollection.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextCollection.cs index ab5e78239..5b697382d 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectContextCollection.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextCollection.cs @@ -7,9 +7,9 @@ using System.IO; using System.Linq; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectContextCollection + internal class ProjectContextCollection { public Project Project { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectContextIdentity.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextIdentity.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/ProjectContextIdentity.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextIdentity.cs index 7fd1bd33d..4278a9aca 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectContextIdentity.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectContextIdentity.cs @@ -4,7 +4,7 @@ using Microsoft.DotNet.PlatformAbstractions; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { public struct ProjectContextIdentity { diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectDescription.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectDescription.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/ProjectDescription.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectDescription.cs index bdd161d50..0b773f0e0 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectDescription.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectDescription.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Linq; using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectDescription : LibraryDescription + internal class ProjectDescription : LibraryDescription { // Create an unresolved project description public ProjectDescription(string name, string path) diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectExtensions.cs similarity index 90% rename from src/Microsoft.DotNet.ProjectModel/ProjectExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectExtensions.cs index b981fc9a1..b7300c994 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectExtensions.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static class ProjectExtensions + internal static class ProjectExtensions { private static readonly KeyValuePair[] _compilerNameToLanguageId = { diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectFileDependencyGroup.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectFileDependencyGroup.cs similarity index 85% rename from src/Microsoft.DotNet.ProjectModel/ProjectFileDependencyGroup.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectFileDependencyGroup.cs index 6bf8d5d8a..eea721847 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectFileDependencyGroup.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectFileDependencyGroup.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectFileDependencyGroup + internal class ProjectFileDependencyGroup { public ProjectFileDependencyGroup(NuGetFramework frameworkName, IEnumerable dependencies) { diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectModelPlatformExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectModelPlatformExtensions.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/ProjectModelPlatformExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectModelPlatformExtensions.cs index 220d9a84b..b7c826b31 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectModelPlatformExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectModelPlatformExtensions.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.DotNet.ProjectModel.Compilation; +using Microsoft.DotNet.Internal.ProjectModel.Compilation; using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static class ProjectModelPlatformExtensions + internal static class ProjectModelPlatformExtensions { public static HashSet GetPlatformExclusionList(this ProjectContext context, IDictionary exports) { diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectPathHelper.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectPathHelper.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/ProjectPathHelper.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectPathHelper.cs index b80b3f2e2..290952276 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectPathHelper.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectPathHelper.cs @@ -4,9 +4,9 @@ using System; using System.IO; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static class ProjectPathHelper + internal static class ProjectPathHelper { public static string NormalizeProjectDirectoryPath(string path) { diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/ProjectReader.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index 88534e11b..c5b67bf17 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -5,17 +5,17 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.Versioning; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectReader : IProjectReader + internal class ProjectReader : IProjectReader { public static bool TryGetProject(string path, out Project project, ProjectReaderSettings settings = null) { @@ -158,8 +158,10 @@ namespace Microsoft.DotNet.ProjectModel project.EmbedInteropTypes = rawProject.Value("embedInteropTypes"); project.Dependencies = new List(); + project.Tools = new List(); - project.Runtimes = new List(); + + project.Runtimes = new List(); // Project files project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath); @@ -224,8 +226,9 @@ namespace Microsoft.DotNet.ProjectModel rawProject, "tools", isGacOrFrameworkReference: false); - - PopulateRuntimes(project.Runtimes, rawProject); + + PopulateRuntimes(project.Runtimes, rawProject); + JToken runtimeOptionsToken; if (rawProject.TryGetValue("runtimeOptions", out runtimeOptionsToken)) @@ -372,20 +375,20 @@ namespace Microsoft.DotNet.ProjectModel } } } - - private static void PopulateRuntimes(IList results, JObject settings) - { - var runtimes = settings.Value("runtimes") as JObject; - if (runtimes != null) - { - foreach (var runtime in runtimes) - { - if (!string.IsNullOrEmpty(runtime.Key)) - { - results.Add(runtime.Key); - } - } - } + + private static void PopulateRuntimes(IList results, JObject settings) + { + var runtimes = settings.Value("runtimes") as JObject; + if (runtimes != null) + { + foreach (var runtime in runtimes) + { + if (!string.IsNullOrEmpty(runtime.Key)) + { + results.Add(runtime.Key); + } + } + } } private void BuildTargetFrameworksAndConfigurations(Project project, JObject projectJsonObject) diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectReaderSettings.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReaderSettings.cs similarity index 85% rename from src/Microsoft.DotNet.ProjectModel/ProjectReaderSettings.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReaderSettings.cs index 22f643f70..101a4b390 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectReaderSettings.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReaderSettings.cs @@ -1,8 +1,8 @@ using System; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ProjectReaderSettings + internal class ProjectReaderSettings { public string VersionSuffix { get; set; } public string AssemblyFileVersion { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectRootResolver.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectRootResolver.cs similarity index 89% rename from src/Microsoft.DotNet.ProjectModel/ProjectRootResolver.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectRootResolver.cs index 536a4d01f..cb1796721 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectRootResolver.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectRootResolver.cs @@ -3,9 +3,9 @@ using System.IO; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public static class ProjectRootResolver + internal static class ProjectRootResolver { public static readonly string GlobalFileName = "global.json"; public static string ResolveRootDirectory(string projectPath) diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkInformation.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/FrameworkInformation.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkInformation.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/FrameworkInformation.cs index 3dcd22249..4638b9674 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkInformation.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/FrameworkInformation.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.IO; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { internal class FrameworkInformation { diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/FrameworkReferenceResolver.cs similarity index 99% rename from src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/FrameworkReferenceResolver.cs index 679128952..f04b95644 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/FrameworkReferenceResolver.cs @@ -9,13 +9,13 @@ using System.Linq; using System.Runtime.Versioning; using System.Xml.Linq; using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using Microsoft.Extensions.DependencyModel.Resolution; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public class FrameworkReferenceResolver + internal class FrameworkReferenceResolver { // FrameworkConstants doesn't have dnx46 yet private static readonly NuGetFramework Dnx46 = new NuGetFramework( diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/LibraryManager.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/LibraryManager.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Resolution/LibraryManager.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/LibraryManager.cs index 8044bed54..d2cb50754 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/LibraryManager.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/LibraryManager.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public class LibraryManager + internal class LibraryManager { private readonly IList _libraries; private readonly IList _diagnostics; diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/MSBuildDependencyProvider.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/MSBuildDependencyProvider.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Resolution/MSBuildDependencyProvider.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/MSBuildDependencyProvider.cs index a0a58f290..cc53d5517 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/MSBuildDependencyProvider.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/MSBuildDependencyProvider.cs @@ -9,9 +9,9 @@ using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public class MSBuildDependencyProvider + internal class MSBuildDependencyProvider { private readonly Project _rootProject; private readonly Func _projectResolver; diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/PackageDependencyProvider.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/PackageDependencyProvider.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Resolution/PackageDependencyProvider.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/PackageDependencyProvider.cs index d823cfedd..c1661fd49 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/PackageDependencyProvider.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/PackageDependencyProvider.cs @@ -13,9 +13,9 @@ using NuGet.LibraryModel; using NuGet.Packaging; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public class PackageDependencyProvider + internal class PackageDependencyProvider { private readonly FallbackPackagePathResolver _packagePathResolver; private readonly VersionFolderPathResolver _versionFolderPathResolver; diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/ProjectDependencyProvider.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/ProjectDependencyProvider.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Resolution/ProjectDependencyProvider.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/ProjectDependencyProvider.cs index 192b03c33..eb32868d1 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/ProjectDependencyProvider.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/ProjectDependencyProvider.cs @@ -9,9 +9,9 @@ using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public class ProjectDependencyProvider + internal class ProjectDependencyProvider { private Func _resolveProject; diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/ReferenceAssemblyDependencyResolver.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/ReferenceAssemblyDependencyResolver.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/Resolution/ReferenceAssemblyDependencyResolver.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/ReferenceAssemblyDependencyResolver.cs index 795059831..4ebb51dad 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/ReferenceAssemblyDependencyResolver.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/ReferenceAssemblyDependencyResolver.cs @@ -7,9 +7,9 @@ using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.Versioning; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public class ReferenceAssemblyDependencyResolver + internal class ReferenceAssemblyDependencyResolver { public ReferenceAssemblyDependencyResolver(FrameworkReferenceResolver frameworkReferenceResolver) { diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/UnresolvedDependencyProvider.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/UnresolvedDependencyProvider.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/Resolution/UnresolvedDependencyProvider.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/UnresolvedDependencyProvider.cs index 599d96cd9..812c658b4 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/UnresolvedDependencyProvider.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resolution/UnresolvedDependencyProvider.cs @@ -5,9 +5,9 @@ using System.Linq; using NuGet.Frameworks; using NuGet.LibraryModel; -namespace Microsoft.DotNet.ProjectModel.Resolution +namespace Microsoft.DotNet.Internal.ProjectModel.Resolution { - public static class UnresolvedDependencyProvider + internal static class UnresolvedDependencyProvider { public static LibraryDescription GetDescription(ProjectLibraryDependency libraryDependency, NuGetFramework targetFramework) { diff --git a/src/Microsoft.DotNet.ProjectModel/ResourceFile.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ResourceFile.cs similarity index 79% rename from src/Microsoft.DotNet.ProjectModel/ResourceFile.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ResourceFile.cs index 73518481b..679595df3 100644 --- a/src/Microsoft.DotNet.ProjectModel/ResourceFile.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ResourceFile.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class ResourceFile + internal class ResourceFile { public string Path { get; } public string Locale { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/Resources/CultureInfoCache.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resources/CultureInfoCache.cs similarity index 99% rename from src/Microsoft.DotNet.ProjectModel/Resources/CultureInfoCache.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resources/CultureInfoCache.cs index 21882654a..b414e9028 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resources/CultureInfoCache.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resources/CultureInfoCache.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.DotNet.ProjectModel.Resources +namespace Microsoft.DotNet.Internal.ProjectModel.Resources { /// /// Contains a list of known culture names that can be used to create a . diff --git a/src/Microsoft.DotNet.ProjectModel/Resources/ResourceUtility.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resources/ResourceUtility.cs similarity index 94% rename from src/Microsoft.DotNet.ProjectModel/Resources/ResourceUtility.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resources/ResourceUtility.cs index 29a69ab5b..436007fba 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resources/ResourceUtility.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Resources/ResourceUtility.cs @@ -5,11 +5,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; -namespace Microsoft.DotNet.ProjectModel.Resources +namespace Microsoft.DotNet.Internal.ProjectModel.Resources { - public static class ResourceUtility + internal static class ResourceUtility { public static string GetResourceName(string projectFolder, string resourcePath) { diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeConfig/RuntimeConfig.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeConfig/RuntimeConfig.cs similarity index 95% rename from src/Microsoft.DotNet.ProjectModel/RuntimeConfig/RuntimeConfig.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeConfig/RuntimeConfig.cs index 5a8bf2136..7c7e20102 100644 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeConfig/RuntimeConfig.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeConfig/RuntimeConfig.cs @@ -8,9 +8,9 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.IO; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class RuntimeConfig + internal class RuntimeConfig { public bool IsPortable { get; } public RuntimeConfigFramework Framework { get; } diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeConfig/RuntimeConfigFramework.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeConfig/RuntimeConfigFramework.cs similarity index 92% rename from src/Microsoft.DotNet.ProjectModel/RuntimeConfig/RuntimeConfigFramework.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeConfig/RuntimeConfigFramework.cs index d6a0c6f63..ca1d4a396 100644 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeConfig/RuntimeConfigFramework.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeConfig/RuntimeConfigFramework.cs @@ -7,9 +7,9 @@ using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class RuntimeConfigFramework + internal class RuntimeConfigFramework { public string Name { get; set; } public string Version { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeGraphCollector.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeGraphCollector.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/RuntimeGraphCollector.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeGraphCollector.cs index a85b3a1a7..f1b5c7dbd 100644 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeGraphCollector.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeGraphCollector.cs @@ -7,7 +7,7 @@ using System.Linq; using NuGet.LibraryModel; using NuGet.RuntimeModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { class RuntimeGraphCollector { diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeOptions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeOptions.cs similarity index 77% rename from src/Microsoft.DotNet.ProjectModel/RuntimeOptions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeOptions.cs index b11f6c37d..2c9fac1dd 100644 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeOptions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeOptions.cs @@ -1,9 +1,9 @@ // 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.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class RuntimeOptions + internal class RuntimeOptions { public bool GcServer { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeOutputFiles.cs similarity index 96% rename from src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeOutputFiles.cs index ea420762f..cee19bd7a 100644 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/RuntimeOutputFiles.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.IO; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class RuntimeOutputFiles : CompilationOutputFiles + internal class RuntimeOutputFiles : CompilationOutputFiles { private readonly string _runtimeIdentifier; diff --git a/src/Microsoft.DotNet.ProjectModel/TargetFrameworkInformation.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/TargetFrameworkInformation.cs similarity index 88% rename from src/Microsoft.DotNet.ProjectModel/TargetFrameworkInformation.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/TargetFrameworkInformation.cs index 5dd9d9b31..8d36ed788 100644 --- a/src/Microsoft.DotNet.ProjectModel/TargetFrameworkInformation.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/TargetFrameworkInformation.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using NuGet.Frameworks; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public class TargetFrameworkInformation + internal class TargetFrameworkInformation { public NuGetFramework FrameworkName { get; set; } diff --git a/src/Microsoft.DotNet.ProjectModel/TargetLibraryWithAssets.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/TargetLibraryWithAssets.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/TargetLibraryWithAssets.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/TargetLibraryWithAssets.cs index 97fa24e3b..50b7049f8 100644 --- a/src/Microsoft.DotNet.ProjectModel/TargetLibraryWithAssets.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/TargetLibraryWithAssets.cs @@ -6,9 +6,9 @@ using NuGet.Frameworks; using NuGet.LibraryModel; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { - public abstract class TargetLibraryWithAssets : LibraryDescription + internal abstract class TargetLibraryWithAssets : LibraryDescription { public TargetLibraryWithAssets( LibraryIdentity libraryIdentity, diff --git a/src/Microsoft.DotNet.ProjectModel/Utilities/CollectionExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/CollectionExtensions.cs similarity index 93% rename from src/Microsoft.DotNet.ProjectModel/Utilities/CollectionExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/CollectionExtensions.cs index 6bb65ef5f..1344ab101 100644 --- a/src/Microsoft.DotNet.ProjectModel/Utilities/CollectionExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/CollectionExtensions.cs @@ -1,9 +1,9 @@ -using Microsoft.DotNet.ProjectModel.Compilation; +using Microsoft.DotNet.Internal.ProjectModel.Compilation; using System.Linq; namespace System.Collections.Generic { - public static class CollectionExtensions + internal static class CollectionExtensions { public static LibraryAssetGroup GetDefaultGroup(this IEnumerable self) => GetGroup(self, string.Empty); public static LibraryAssetGroup GetRuntimeGroup(this IEnumerable self, string runtime) diff --git a/src/Microsoft.DotNet.ProjectModel/Utilities/DictionaryExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/DictionaryExtensions.cs similarity index 90% rename from src/Microsoft.DotNet.ProjectModel/Utilities/DictionaryExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/DictionaryExtensions.cs index 65cd560e6..5c08da37b 100644 --- a/src/Microsoft.DotNet.ProjectModel/Utilities/DictionaryExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/DictionaryExtensions.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Microsoft.DotNet.ProjectModel.Utilities +namespace Microsoft.DotNet.Internal.ProjectModel.Utilities { - public static class DictionaryExtensions + internal static class DictionaryExtensions { public static IEnumerable GetOrEmpty(this IDictionary> self, K key) { diff --git a/src/Microsoft.DotNet.ProjectModel/Utilities/FrameworksExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/FrameworksExtensions.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Utilities/FrameworksExtensions.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/FrameworksExtensions.cs index 93b2cf921..903d9697f 100644 --- a/src/Microsoft.DotNet.ProjectModel/Utilities/FrameworksExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/FrameworksExtensions.cs @@ -6,7 +6,7 @@ using System.Runtime.Versioning; namespace NuGet.Frameworks { - public static class FrameworksExtensions + internal static class FrameworksExtensions { // HACK(anurse): NuGet.Frameworks turns "dnxcore50" into "dnxcore5" :( public static string GetTwoDigitShortFolderName(this NuGetFramework self) diff --git a/src/Microsoft.DotNet.ProjectModel/Utilities/PathUtility.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/PathUtility.cs similarity index 99% rename from src/Microsoft.DotNet.ProjectModel/Utilities/PathUtility.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/PathUtility.cs index 0f0bfc653..453b00847 100644 --- a/src/Microsoft.DotNet.ProjectModel/Utilities/PathUtility.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/PathUtility.cs @@ -5,7 +5,7 @@ using System; using System.IO; using Microsoft.DotNet.PlatformAbstractions; -namespace Microsoft.DotNet.ProjectModel.Utilities +namespace Microsoft.DotNet.Internal.ProjectModel.Utilities { internal static class PathUtility { diff --git a/src/Microsoft.DotNet.ProjectModel/Utilities/ResilientFileStreamOpener.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/ResilientFileStreamOpener.cs similarity index 91% rename from src/Microsoft.DotNet.ProjectModel/Utilities/ResilientFileStreamOpener.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/ResilientFileStreamOpener.cs index dc824c1b2..e2f4e29d0 100644 --- a/src/Microsoft.DotNet.ProjectModel/Utilities/ResilientFileStreamOpener.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/ResilientFileStreamOpener.cs @@ -5,9 +5,9 @@ using System; using System.IO; using System.Threading; -namespace Microsoft.DotNet.ProjectModel.Utilities +namespace Microsoft.DotNet.Internal.ProjectModel.Utilities { - public class ResilientFileStreamOpener + internal class ResilientFileStreamOpener { public static FileStream OpenFile(string filepath) { diff --git a/src/Microsoft.DotNet.ProjectModel/Utilities/VersionUtility.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/VersionUtility.cs similarity index 97% rename from src/Microsoft.DotNet.ProjectModel/Utilities/VersionUtility.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/VersionUtility.cs index 69072d3b3..90a721e38 100644 --- a/src/Microsoft.DotNet.ProjectModel/Utilities/VersionUtility.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Utilities/VersionUtility.cs @@ -11,9 +11,9 @@ using System.Reflection; using System.Text; using NuGet.Versioning; -namespace Microsoft.DotNet.ProjectModel.Utilities +namespace Microsoft.DotNet.Internal.ProjectModel.Utilities { - public static class VersionUtility + internal static class VersionUtility { public static readonly string DnxCoreFrameworkIdentifier = "DNXCore"; public static readonly string DnxFrameworkIdentifier = "DNX"; diff --git a/src/Microsoft.DotNet.ProjectModel/Workspace.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Workspace.cs similarity index 98% rename from src/Microsoft.DotNet.ProjectModel/Workspace.cs rename to src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Workspace.cs index 8ec8880aa..0a865a049 100644 --- a/src/Microsoft.DotNet.ProjectModel/Workspace.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/Workspace.cs @@ -6,16 +6,16 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Utilities; +using Microsoft.DotNet.Internal.ProjectModel.Utilities; using NuGet.Frameworks; using NuGet.ProjectModel; -namespace Microsoft.DotNet.ProjectModel +namespace Microsoft.DotNet.Internal.ProjectModel { /// /// Represents a cache of Projects, LockFiles, and ProjectContexts /// - public abstract class Workspace + internal abstract class Workspace { // key: project directory private readonly ConcurrentDictionary> _projectsCache diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationError.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationError.cs index c7d819415..868292fc7 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationError.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationError.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration { - public class MigrationError + internal class MigrationError { public string ErrorCode { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs index 23b6483d0..336bd42c0 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs @@ -5,7 +5,7 @@ using System; namespace Microsoft.DotNet.ProjectJsonMigration { - public static partial class MigrationErrorCodes + internal static partial class MigrationErrorCodes { public static Func MIGRATE1011 => (message) => new MigrationError(nameof(MIGRATE1011), "Deprecated Project", message); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationException.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationException.cs index ecef3c3ac..08047e66e 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationException.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationException.cs @@ -5,7 +5,7 @@ using System; namespace Microsoft.DotNet.ProjectJsonMigration { - public class MigrationException : Exception + internal class MigrationException : Exception { public MigrationError Error { get; } public MigrationException(MigrationError error, string message) : base(message) diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationNuGetFrameworkExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationNuGetFrameworkExtensions.cs index 76d063f38..1bdf4364d 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationNuGetFrameworkExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationNuGetFrameworkExtensions.cs @@ -5,7 +5,7 @@ using NuGet.Frameworks; namespace Microsoft.DotNet.ProjectJsonMigration { - public static class MigrationNuGetFrameworkExtensions + internal static class MigrationNuGetFrameworkExtensions { public static string GetMSBuildCondition(this NuGetFramework framework) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationRuleInputs.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationRuleInputs.cs index a0a1deebc..f08c06c88 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationRuleInputs.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationRuleInputs.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using Microsoft.Build.Construction; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; using System.Linq; namespace Microsoft.DotNet.ProjectJsonMigration { - public class MigrationRuleInputs + internal class MigrationRuleInputs { public ProjectRootElement ProjectXproj { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationSettings.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationSettings.cs index 594fa53c4..ec18c4709 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationSettings.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationSettings.cs @@ -5,7 +5,7 @@ using Microsoft.Build.Construction; namespace Microsoft.DotNet.ProjectJsonMigration { - public class MigrationSettings + internal class MigrationSettings { public string ProjectXProjFilePath { get; } public string ProjectDirectory { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationTrace.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationTrace.cs index 298f05b60..60d31e4d8 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationTrace.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationTrace.cs @@ -5,7 +5,7 @@ using System; namespace Microsoft.DotNet.ProjectJsonMigration { - public class MigrationTrace + internal class MigrationTrace { public static MigrationTrace Instance { get; set; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectItemInfo.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectItemInfo.cs index 5f1f31977..5cbd37153 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectItemInfo.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectItemInfo.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Microsoft.DotNet.ProjectJsonMigration.Models { - public class DefaultProjectItemInfo + internal class DefaultProjectItemInfo { public string ItemType {get; set;} public string Include {get; set;} diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectPropertyInfo.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectPropertyInfo.cs index d228e0179..cb4097e79 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectPropertyInfo.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Models/DefaultProjectPropertyInfo.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Microsoft.DotNet.ProjectJsonMigration.Models { - public class DefaultProjectPropertyInfo + internal class DefaultProjectPropertyInfo { public string Name {get; set;} public string Value {get; set;} diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Models/ItemMetadataValue.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Models/ItemMetadataValue.cs index 7b67db2c8..1fd6f77bb 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Models/ItemMetadataValue.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Models/ItemMetadataValue.cs @@ -5,7 +5,7 @@ using System; namespace Microsoft.DotNet.ProjectJsonMigration.Models { - public class ItemMetadataValue + internal class ItemMetadataValue { public string MetadataName { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Models/SerializableMigrationDefaultsInfo.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Models/SerializableMigrationDefaultsInfo.cs index 34a500864..25dc7b08d 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Models/SerializableMigrationDefaultsInfo.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Models/SerializableMigrationDefaultsInfo.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Microsoft.DotNet.ProjectJsonMigration.Models { - public class SerializableMigrationDefaultsInfo + internal class SerializableMigrationDefaultsInfo { public IEnumerable Items { get; set; } public IEnumerable Properties { get; set; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectContextExtensions.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectContextExtensions.cs index aa7d345ae..c0bb37bd5 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectContextExtensions.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectContextExtensions.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Generic; using Microsoft.Build.Construction; using System.Linq; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; using System.IO; namespace Microsoft.DotNet.ProjectJsonMigration { - public static class ProjectContextExtensions + internal static class ProjectContextExtensions { public static string GetProjectName(this ProjectContext projectContext) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependency.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependency.cs index 03c780d43..2315deabb 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependency.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependency.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration { - public class ProjectDependency + internal class ProjectDependency { public string Name { get; } public string ProjectFilePath { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyComparer.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyComparer.cs index afb2a8578..dcf3d8f7b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyComparer.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyComparer.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace Microsoft.DotNet.ProjectJsonMigration { - public class ProjectDependencyComparer : IEqualityComparer + internal class ProjectDependencyComparer : IEqualityComparer { public bool Equals(ProjectDependency one, ProjectDependency two) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs index c92bec3a7..904a7993b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using Microsoft.Build.Construction; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Graph; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.Graph; using System.Linq; using System.IO; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs index 9de79845e..031aa7651 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using Microsoft.Build.Construction; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Graph; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.Graph; using Microsoft.DotNet.Cli; using System.Linq; using System.IO; @@ -14,7 +14,7 @@ using Microsoft.DotNet.Tools.Common; namespace Microsoft.DotNet.ProjectJsonMigration { - public class ProjectMigrator + internal class ProjectMigrator { private readonly IMigrationRule _ruleSet; private readonly ProjectDependencyFinder _projectDependencyFinder = new ProjectDependencyFinder(); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Report/MigrationReport.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Report/MigrationReport.cs index d54d0faf7..bfde5391b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Report/MigrationReport.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Report/MigrationReport.cs @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration { /// Any changes to this need to be reflected in roslyn-project-system /// TODO add link - public class MigrationReport + internal class MigrationReport { public List ProjectMigrationReports { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Report/ProjectMigrationReport.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Report/ProjectMigrationReport.cs index b719b6ce7..2e71cd095 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Report/ProjectMigrationReport.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Report/ProjectMigrationReport.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; namespace Microsoft.DotNet.ProjectJsonMigration { - public class ProjectMigrationReport + internal class ProjectMigrationReport { public string ProjectDirectory { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/AddDefaultsToProjectRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/AddDefaultsToProjectRule.cs index bbc214d14..d4f529b7b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/AddDefaultsToProjectRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/AddDefaultsToProjectRule.cs @@ -13,7 +13,7 @@ using Newtonsoft.Json; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class AddDefaultsToProjectRule : IMigrationRule + internal class AddDefaultsToProjectRule : IMigrationRule { internal const string c_DefaultsProjectElementContainerLabel = "MigrationDefaultsTempContainer"; internal const string c_SdkDefaultsJsonFileName = "sdkdefaults.json"; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs index 3d58a006c..dfdb2420d 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/CleanOutputProjectRule.cs @@ -13,7 +13,7 @@ using Newtonsoft.Json; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class CleanOutputProjectRule : IMigrationRule + internal class CleanOutputProjectRule : IMigrationRule { public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/IMigrationRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/IMigrationRule.cs index 36cc3715c..92635883b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/IMigrationRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/IMigrationRule.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public interface IMigrationRule + internal interface IMigrationRule { void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs); } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs index 22edd478d..4f3e719c2 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateAssemblyInfoRule.cs @@ -10,14 +10,14 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.DotNet.ProjectJsonMigration; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.Files; using Microsoft.DotNet.Tools.Common; using NuGet.Frameworks; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateAssemblyInfoRule : IMigrationRule + internal class MigrateAssemblyInfoRule : IMigrationRule { private static IReadOnlyDictionary> Suppresses { get; } = new Dictionary> { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs index 00f561a87..78b28c2d1 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs @@ -6,13 +6,13 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Build.Construction; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.Files; using Newtonsoft.Json.Linq; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateBuildOptionsRule : IMigrationRule + internal class MigrateBuildOptionsRule : IMigrationRule { private AddPropertyTransform[] EmitEntryPointTransforms => new [] diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateConfigurationsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateConfigurationsRule.cs index 164d91243..4d9b55e43 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateConfigurationsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateConfigurationsRule.cs @@ -5,11 +5,11 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Build.Construction; using NuGet.Frameworks; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateConfigurationsRule : IMigrationRule + internal class MigrateConfigurationsRule : IMigrationRule { public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateJsonPropertiesRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateJsonPropertiesRule.cs index 11b85ba99..5751d5b4f 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateJsonPropertiesRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateJsonPropertiesRule.cs @@ -10,7 +10,7 @@ using Newtonsoft.Json.Linq; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateJsonPropertiesRule : IMigrationRule + internal class MigrateJsonPropertiesRule : IMigrationRule { private Dictionary> _propertyMappings = new Dictionary> diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs index b521fe1bd..570e8e648 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs @@ -8,13 +8,13 @@ using System.Linq; using Microsoft.Build.Construction; using Microsoft.DotNet.ProjectJsonMigration; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.Files; using Microsoft.DotNet.Tools.Common; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigratePackOptionsRule : IMigrationRule + internal class MigratePackOptionsRule : IMigrationRule { private AddPropertyTransform TagsTransform => new AddPropertyTransform( "PackageTags", diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs index 236e3ae10..6ca97b185 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackageDependenciesAndToolsRule.cs @@ -8,14 +8,14 @@ using System.Linq; using Microsoft.Build.Construction; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; using Microsoft.DotNet.Tools.Common; using NuGet.Frameworks; using NuGet.LibraryModel; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigratePackageDependenciesAndToolsRule : IMigrationRule + internal class MigratePackageDependenciesAndToolsRule : IMigrationRule { private readonly ITransformApplicator _transformApplicator; private readonly ProjectDependencyFinder _projectDependencyFinder; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateProjectDependenciesRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateProjectDependenciesRule.cs index bda537b2c..9fcd1b4da 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateProjectDependenciesRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateProjectDependenciesRule.cs @@ -7,13 +7,13 @@ using System.IO; using System.Linq; using Microsoft.Build.Construction; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; using Microsoft.DotNet.Tools.Common; using NuGet.Frameworks; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateProjectDependenciesRule : IMigrationRule + internal class MigrateProjectDependenciesRule : IMigrationRule { private readonly ITransformApplicator _transformApplicator; private readonly ProjectDependencyFinder _projectDependencyFinder; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs index 53c6b30d0..edb9582b6 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs @@ -6,7 +6,7 @@ using Microsoft.DotNet.ProjectJsonMigration.Transforms; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigratePublishOptionsRule : IMigrationRule + internal class MigratePublishOptionsRule : IMigrationRule { private readonly ITransformApplicator _transformApplicator; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRootOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRootOptionsRule.cs index 54f76b05f..73760a3a0 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRootOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRootOptionsRule.cs @@ -3,11 +3,11 @@ using System.Linq; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Project = Microsoft.DotNet.ProjectModel.Project; +using Project = Microsoft.DotNet.Internal.ProjectModel.Project; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateRootOptionsRule : IMigrationRule + internal class MigrateRootOptionsRule : IMigrationRule { private readonly ITransformApplicator _transformApplicator; private readonly AddPropertyTransform[] _transforms; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimeOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimeOptionsRule.cs index e865fe39a..0ad4aace3 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimeOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimeOptionsRule.cs @@ -5,7 +5,7 @@ using System.IO; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateRuntimeOptionsRule : IMigrationRule + internal class MigrateRuntimeOptionsRule : IMigrationRule { private static readonly string s_runtimeOptionsFileName = "runtimeconfig.template.json"; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs index c0ddb8c46..c30ac843f 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateRuntimesRule.cs @@ -7,7 +7,7 @@ using Microsoft.DotNet.ProjectJsonMigration.Transforms; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateRuntimesRule : IMigrationRule + internal class MigrateRuntimesRule : IMigrationRule { AddPropertyTransform> RuntimeIdentifiersTransform => new AddPropertyTransform>( diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateScriptsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateScriptsRule.cs index 5901b6256..1312c5d89 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateScriptsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateScriptsRule.cs @@ -7,11 +7,11 @@ using System.Linq; using Microsoft.Build.Construction; using Microsoft.DotNet.Cli.Utils.CommandParsing; using Microsoft.DotNet.ProjectJsonMigration.Transforms; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class MigrateScriptsRule : IMigrationRule + internal class MigrateScriptsRule : IMigrationRule { private readonly ITransformApplicator _transformApplicator; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs index ac75851ee..c173d90f9 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs @@ -13,7 +13,7 @@ using System.Collections.Generic; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { // TODO: Support Multi-TFM - public class MigrateTFMRule : IMigrationRule + internal class MigrateTFMRule : IMigrationRule { private readonly ITransformApplicator _transformApplicator; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/RemoveDefaultsFromProjectRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/RemoveDefaultsFromProjectRule.cs index 5a18b23ff..0802be4aa 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/RemoveDefaultsFromProjectRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/RemoveDefaultsFromProjectRule.cs @@ -13,7 +13,7 @@ using Newtonsoft.Json; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class RemoveDefaultsFromProjectRule : IMigrationRule + internal class RemoveDefaultsFromProjectRule : IMigrationRule { public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/SaveOutputProjectRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/SaveOutputProjectRule.cs index dd4a88ee7..ed35d9907 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/SaveOutputProjectRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/SaveOutputProjectRule.cs @@ -6,7 +6,7 @@ using Microsoft.Build.Construction; namespace Microsoft.DotNet.ProjectJsonMigration.Rules { - public class SaveOutputProjectRule : IMigrationRule + internal class SaveOutputProjectRule : IMigrationRule { public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs index 9fabbc316..8aa455422 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public class ItemTransformApplicator : ITransformApplicator + internal class ItemTransformApplicator : ITransformApplicator { private readonly ProjectRootElement _projectElementGenerator = ProjectRootElement.Create(); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/PropertyTransformApplicator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/PropertyTransformApplicator.cs index 91f21641b..fa85e942b 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/PropertyTransformApplicator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/PropertyTransformApplicator.cs @@ -9,7 +9,7 @@ using System.Text.RegularExpressions; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public class PropertyTransformApplicator : ITransformApplicator + internal class PropertyTransformApplicator : ITransformApplicator { private readonly ProjectRootElement _projectElementGenerator = ProjectRootElement.Create(); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/project.json b/src/Microsoft.DotNet.ProjectJsonMigration/project.json index d2bb6c028..c04560752 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/project.json +++ b/src/Microsoft.DotNet.ProjectJsonMigration/project.json @@ -8,15 +8,9 @@ } }, "dependencies": { - "Microsoft.DotNet.Compiler.Common": { - "target": "project" - }, "Microsoft.DotNet.Cli.Utils": { "target": "project" }, - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, "Microsoft.Build": "15.1.319-preview5", "Microsoft.CodeAnalysis.CSharp": "2.0.0-beta6-60922-08" }, diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddItemTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddItemTransform.cs index 55bb687b1..59505d3c0 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddItemTransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddItemTransform.cs @@ -8,7 +8,7 @@ using Microsoft.DotNet.ProjectJsonMigration.Models; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public class AddItemTransform : ConditionalTransform + internal class AddItemTransform : ConditionalTransform { private readonly ProjectRootElement _itemObjectGenerator = ProjectRootElement.Create(); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddPropertyTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddPropertyTransform.cs index b3dbe40f5..6b25fc290 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddPropertyTransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/AddPropertyTransform.cs @@ -6,7 +6,7 @@ using Microsoft.Build.Construction; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public class AddPropertyTransform : ConditionalTransform + internal class AddPropertyTransform : ConditionalTransform { public string PropertyName { get; } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs index 4fc455e7f..099f553c2 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ConditionalTransform.cs @@ -5,7 +5,7 @@ using System; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public abstract class ConditionalTransform : ITransform + internal abstract class ConditionalTransform : ITransform { private Func _condition; diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransform.cs index 7cd8f68f0..23e82b8f7 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransform.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public interface ITransform + internal interface ITransform { U Transform(T source); } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransformApplicator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransformApplicator.cs index 4efd2f16f..6b1bb5f52 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransformApplicator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/ITransformApplicator.cs @@ -6,7 +6,7 @@ using Microsoft.Build.Construction; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public interface ITransformApplicator + internal interface ITransformApplicator { void Execute( T element, diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs index b2ff28ac2..3a6183d03 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/IncludeContextTransform.cs @@ -1,7 +1,7 @@ // 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.ProjectModel.Files; +using Microsoft.DotNet.Internal.ProjectModel.Files; using System; using System.IO; using System.Collections.Generic; @@ -13,7 +13,7 @@ using Microsoft.DotNet.Tools.Common; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public class IncludeContextTransform : ConditionalTransform> + internal class IncludeContextTransform : ConditionalTransform> { private Func> IncludeFilesExcludeFilesTransformGetter => (itemName) => diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/TransformApplicator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/TransformApplicator.cs index 47815949e..85759d662 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/transforms/TransformApplicator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/transforms/TransformApplicator.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Microsoft.DotNet.ProjectJsonMigration.Transforms { - public class TransformApplicator : ITransformApplicator + internal class TransformApplicator : ITransformApplicator { private readonly ITransformApplicator _propertyTransformApplicator; diff --git a/src/Microsoft.DotNet.ProjectModel.Loader/LoaderProjectContextExtensions.cs b/src/Microsoft.DotNet.ProjectModel.Loader/LoaderProjectContextExtensions.cs deleted file mode 100644 index 5dec13272..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Loader/LoaderProjectContextExtensions.cs +++ /dev/null @@ -1,127 +0,0 @@ -// 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; -using System.Reflection; -using System.Runtime.Loader; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.Extensions.DependencyModel; - -namespace Microsoft.DotNet.ProjectModel.Loader -{ - public static class LoaderProjectContextExtensions - { - public static AssemblyLoadContext CreateLoadContext( - this ProjectContext context, - string configuration) => CreateLoadContext(context, context.RuntimeIdentifier, configuration); - - public static AssemblyLoadContext CreateLoadContext( - this ProjectContext context, - string runtimeIdentifier, - string configuration) => CreateLoadContext(context, runtimeIdentifier, configuration, outputPath: null); - - public static AssemblyLoadContext CreateLoadContext( - this ProjectContext context, - string runtimeIdentifier, - string configuration, - string outputPath) - { - var exporter = context.CreateExporter(configuration); - var assemblies = new Dictionary(AssemblyNameComparer.OrdinalIgnoreCase); - var nativeLibs = new Dictionary(); - var rids = DependencyContext.Default?.RuntimeGraph ?? Enumerable.Empty(); - var fallbacks = rids.FirstOrDefault(r => r.Runtime.Equals(runtimeIdentifier)); - - foreach (var export in exporter.GetAllExports()) - { - // Process managed assets - var group = string.IsNullOrEmpty(runtimeIdentifier) ? - export.RuntimeAssemblyGroups.GetDefaultGroup() : - GetGroup(export.RuntimeAssemblyGroups, runtimeIdentifier, fallbacks); - if(group != null) - { - foreach(var asset in group.Assets) - { - assemblies[asset.GetAssemblyName()] = asset.ResolvedPath; - } - } - - // Process native assets - group = string.IsNullOrEmpty(runtimeIdentifier) ? - export.NativeLibraryGroups.GetDefaultGroup() : - GetGroup(export.NativeLibraryGroups, runtimeIdentifier, fallbacks); - if(group != null) - { - foreach(var asset in group.Assets) - { - nativeLibs[asset.Name] = asset.ResolvedPath; - } - } - - // Process resource assets - foreach(var asset in export.ResourceAssemblies) - { - var name = asset.Asset.GetAssemblyName(); - name.CultureName = asset.Locale; - assemblies[name] = asset.Asset.ResolvedPath; - } - } - - return new ProjectLoadContext( - assemblies, - nativeLibs, - - // Add the project's output directory path to ensure project-to-project references get located - new[] { context.GetOutputPaths(configuration, outputPath: outputPath).CompilationOutputPath }); - } - - private static LibraryAssetGroup GetGroup(IEnumerable groups, string runtimeIdentifier, RuntimeFallbacks fallbacks) - { - IEnumerable rids = new[] { runtimeIdentifier }; - if(fallbacks != null) - { - rids = Enumerable.Concat(rids, fallbacks.Fallbacks); - } - - foreach(var rid in rids) - { - var group = groups.GetRuntimeGroup(rid); - if(group != null) - { - return group; - } - } - return null; - } - - private class AssemblyNameComparer : IEqualityComparer - { - public static readonly IEqualityComparer OrdinalIgnoreCase = new AssemblyNameComparer(); - - private AssemblyNameComparer() - { - } - - public bool Equals(AssemblyName x, AssemblyName y) - { - // Ignore case because that's what Assembly.Load does. - return string.Equals(x.Name, y.Name, StringComparison.OrdinalIgnoreCase) && - string.Equals(x.CultureName ?? string.Empty, y.CultureName ?? string.Empty, StringComparison.Ordinal); - } - - public int GetHashCode(AssemblyName obj) - { - var hashCode = 0; - if (obj.Name != null) - { - hashCode ^= obj.Name.GetHashCode(); - } - - hashCode ^= (obj.CultureName ?? string.Empty).GetHashCode(); - return hashCode; - } - } - } -} diff --git a/src/Microsoft.DotNet.ProjectModel.Loader/Microsoft.DotNet.ProjectModel.Loader.xproj b/src/Microsoft.DotNet.ProjectModel.Loader/Microsoft.DotNet.ProjectModel.Loader.xproj deleted file mode 100644 index bb7e99e2f..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Loader/Microsoft.DotNet.ProjectModel.Loader.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0.24720 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 651DDD55-4819-4F20-B619-4F8A5BC2DF6D - Microsoft.DotNet.ProjectModel.Loader - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel.Loader/ProjectLoadContext.cs b/src/Microsoft.DotNet.ProjectModel.Loader/ProjectLoadContext.cs deleted file mode 100644 index fa92273b6..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Loader/ProjectLoadContext.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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.IO; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.Loader; - -namespace Microsoft.DotNet.ProjectModel.Loader -{ - /// - /// An designed to allow loading from a Project. - /// - public class ProjectLoadContext : AssemblyLoadContext - { - private readonly IDictionary _assemblyPaths; - private readonly IDictionary _nativeLibraries; - private readonly IEnumerable _searchPaths; - - private static readonly string[] NativeLibraryExtensions; - private static readonly string[] ManagedAssemblyExtensions = new[] - { - ".dll", - ".ni.dll", - ".exe", - ".ni.exe" - }; - - - static ProjectLoadContext() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - NativeLibraryExtensions = new[] { ".dll" }; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - NativeLibraryExtensions = new[] { ".dylib" }; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - NativeLibraryExtensions = new[] { ".so" }; - } - else - { - NativeLibraryExtensions = new string[0]; - } - } - - public ProjectLoadContext(IDictionary assemblyPaths, - IDictionary nativeLibraries, - IEnumerable searchPaths) - { - _assemblyPaths = assemblyPaths; - _nativeLibraries = nativeLibraries; - _searchPaths = searchPaths; - } - - protected override Assembly Load(AssemblyName assemblyName) - { - string path; - if (_assemblyPaths.TryGetValue(assemblyName, out path) || SearchForLibrary(ManagedAssemblyExtensions, assemblyName.Name, out path)) - { - return LoadFromAssemblyPath(path); - } - - return null; - } - - protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) - { - string path; - if (_nativeLibraries.TryGetValue(unmanagedDllName, out path) || SearchForLibrary(NativeLibraryExtensions, unmanagedDllName, out path)) - { - return LoadUnmanagedDllFromPath(path); - } - - return base.LoadUnmanagedDll(unmanagedDllName); - } - - private bool SearchForLibrary(string[] extensions, string name, out string path) - { - foreach (var searchPath in _searchPaths) - { - foreach (var extension in extensions) - { - var candidate = Path.Combine(searchPath, name + extension); - if (File.Exists(candidate)) - { - path = candidate; - return true; - } - } - } - path = null; - return false; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel.Loader/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.ProjectModel.Loader/Properties/AssemblyInfo.cs deleted file mode 100644 index bd44bced5..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Loader/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyMetadataAttribute("Serviceable", "True")] diff --git a/src/Microsoft.DotNet.ProjectModel.Loader/project.json b/src/Microsoft.DotNet.ProjectModel.Loader/project.json deleted file mode 100644 index 3d0d43789..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Loader/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "1.0.0-preview3-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk" - }, - "dependencies": { - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "System.Runtime.Loader": "4.0.0" - }, - "frameworks": { - "netstandard1.6": { - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } - } -} diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/Microsoft.DotNet.ProjectModel.Workspaces.xproj b/src/Microsoft.DotNet.ProjectModel.Workspaces/Microsoft.DotNet.ProjectModel.Workspaces.xproj deleted file mode 100644 index 3227dea0a..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/Microsoft.DotNet.ProjectModel.Workspaces.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.23107 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - bd7833f8-3209-4682-bf75-b4bca883e279 - Microsoft.DotNet.ProjectModel.Workspaces - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs b/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs deleted file mode 100644 index 43b50b3fd..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs +++ /dev/null @@ -1,251 +0,0 @@ -// 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.IO; -using System.Linq; -using System.Reflection.PortableExecutable; -using System.Text; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Text; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Files; -using NuGet.Frameworks; - -using RoslynWorkspace = Microsoft.CodeAnalysis.Workspace; - -namespace Microsoft.DotNet.ProjectModel.Workspaces -{ - public class ProjectJsonWorkspace : RoslynWorkspace - { - private Dictionary _cache = new Dictionary(); - - public ProjectJsonWorkspace(ProjectContext context) : base(MefHostServices.DefaultHost, "Custom") - { - AddProject(context); - } - - public ProjectJsonWorkspace(string projectPath) : this(new[] { projectPath }) - { - } - - public ProjectJsonWorkspace(IEnumerable projectPaths) : base(MefHostServices.DefaultHost, "Custom") - { - Initialize(projectPaths); - } - - private void Initialize(IEnumerable projectPaths) - { - foreach (var projectPath in projectPaths) - { - AddProject(projectPath); - } - } - - private void AddProject(string projectPath) - { - // Get all of the specific projects (there is a project per framework) - foreach (var p in ProjectContext.CreateContextForEachFramework(projectPath)) - { - AddProject(p); - } - } - - private ProjectId AddProject(ProjectContext project) - { - // Create the framework specific project and add it to the workspace - var projectInfo = ProjectInfo.Create( - ProjectId.CreateNewId(), - VersionStamp.Create(), - project.ProjectFile.Name + "+" + project.TargetFramework, - project.ProjectFile.Name, - LanguageNames.CSharp, - project.ProjectFile.ProjectFilePath); - - OnProjectAdded(projectInfo); - - // TODO: ctor argument? - var configuration = "Debug"; - - var compilerOptions = project.GetLanguageSpecificCompilerOptions(project.TargetFramework, configuration); - - var compilationSettings = ToCompilationSettings(compilerOptions, project.TargetFramework, project.ProjectFile.ProjectDirectory); - - OnParseOptionsChanged(projectInfo.Id, new CSharpParseOptions(compilationSettings.LanguageVersion, preprocessorSymbols: compilationSettings.Defines)); - - OnCompilationOptionsChanged(projectInfo.Id, compilationSettings.CompilationOptions); - - IEnumerable sourceFiles = null; - if (compilerOptions.CompileInclude == null) - { - sourceFiles = project.ProjectFile.Files.SourceFiles; - } - else - { - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); - sourceFiles = includeFiles.Select(f => f.SourcePath); - } - - foreach (var file in sourceFiles) - { - using (var stream = File.OpenRead(file)) - { - AddSourceFile(projectInfo, file, stream); - } - } - - var exporter = project.CreateExporter(configuration); - - foreach (var dependency in exporter.GetDependencies()) - { - var projectDependency = dependency.Library as ProjectDescription; - if (projectDependency != null) - { - var projectDependencyContext = ProjectContext.Create(projectDependency.Project.ProjectFilePath, projectDependency.Framework); - - var id = AddProject(projectDependencyContext); - - OnProjectReferenceAdded(projectInfo.Id, new ProjectReference(id)); - } - else - { - foreach (var asset in dependency.CompilationAssemblies) - { - OnMetadataReferenceAdded(projectInfo.Id, GetMetadataReference(asset.ResolvedPath)); - } - } - - foreach (var file in dependency.SourceReferences) - { - using (var stream = file.GetTransformedStream()) - { - AddSourceFile(projectInfo, file.ResolvedPath, stream); - } - } - } - - return projectInfo.Id; - } - - private void AddSourceFile(ProjectInfo projectInfo, string file, Stream stream) - { - var sourceText = SourceText.From(stream, encoding: Encoding.UTF8); - var id = DocumentId.CreateNewId(projectInfo.Id); - var version = VersionStamp.Create(); - - var loader = TextLoader.From(TextAndVersion.Create(sourceText, version)); - OnDocumentAdded(DocumentInfo.Create(id, file, filePath: file, loader: loader)); - } - - private MetadataReference GetMetadataReference(string path) - { - AssemblyMetadata assemblyMetadata; - if (!_cache.TryGetValue(path, out assemblyMetadata)) - { - using (var stream = File.OpenRead(path)) - { - var moduleMetadata = ModuleMetadata.CreateFromStream(stream, PEStreamOptions.PrefetchMetadata); - assemblyMetadata = AssemblyMetadata.Create(moduleMetadata); - _cache[path] = assemblyMetadata; - } - } - - return assemblyMetadata.GetReference(); - } - - private static CompilationSettings ToCompilationSettings(CommonCompilerOptions compilerOptions, - NuGetFramework targetFramework, - string projectDirectory) - { - var options = GetCompilationOptions(compilerOptions, projectDirectory); - - options = options.WithSpecificDiagnosticOptions(compilerOptions.SuppressWarnings.ToDictionary( - suppress => suppress, _ => ReportDiagnostic.Suppress)); - - AssemblyIdentityComparer assemblyIdentityComparer = - targetFramework.IsDesktop() ? - DesktopAssemblyIdentityComparer.Default : - null; - - options = options.WithAssemblyIdentityComparer(assemblyIdentityComparer); - - LanguageVersion languageVersion; - if (!Enum.TryParse(value: compilerOptions.LanguageVersion, - ignoreCase: true, - result: out languageVersion)) - { - languageVersion = LanguageVersion.CSharp6; - } - - var settings = new CompilationSettings - { - LanguageVersion = languageVersion, - Defines = compilerOptions.Defines ?? Enumerable.Empty(), - CompilationOptions = options - }; - - return settings; - } - - private static CSharpCompilationOptions GetCompilationOptions(CommonCompilerOptions compilerOptions, string projectDirectory) - { - var outputKind = compilerOptions.EmitEntryPoint.GetValueOrDefault() ? - OutputKind.ConsoleApplication : OutputKind.DynamicallyLinkedLibrary; - var options = new CSharpCompilationOptions(outputKind); - - string platformValue = compilerOptions.Platform; - bool allowUnsafe = compilerOptions.AllowUnsafe ?? false; - bool optimize = compilerOptions.Optimize ?? false; - bool warningsAsErrors = compilerOptions.WarningsAsErrors ?? false; - - Microsoft.CodeAnalysis.Platform platform; - if (!Enum.TryParse(value: platformValue, ignoreCase: true, result: out platform)) - { - platform = Microsoft.CodeAnalysis.Platform.AnyCpu; - } - - options = options - .WithAllowUnsafe(allowUnsafe) - .WithPlatform(platform) - .WithGeneralDiagnosticOption(warningsAsErrors ? ReportDiagnostic.Error : ReportDiagnostic.Default) - .WithOptimizationLevel(optimize ? OptimizationLevel.Release : OptimizationLevel.Debug); - - return AddSigningOptions(options, compilerOptions, projectDirectory); - } - - private static CSharpCompilationOptions AddSigningOptions(CSharpCompilationOptions options, CommonCompilerOptions compilerOptions, string projectDirectory) - { - var useOssSigning = compilerOptions.PublicSign == true; - var keyFile = compilerOptions.KeyFile; - - if (!string.IsNullOrEmpty(keyFile)) - { - keyFile = Path.GetFullPath(Path.Combine(projectDirectory, compilerOptions.KeyFile)); - - if (RuntimeEnvironment.OperatingSystemPlatform != PlatformAbstractions.Platform.Windows || useOssSigning) - { - return options.WithCryptoPublicKey( - SnkUtils.ExtractPublicKey(File.ReadAllBytes(keyFile))); - } - - options = options.WithCryptoKeyFile(keyFile); - - return options.WithDelaySign(compilerOptions.DelaySign); - } - - return options; - } - - private class CompilationSettings - { - public LanguageVersion LanguageVersion { get; set; } - public IEnumerable Defines { get; set; } - public CSharpCompilationOptions CompilationOptions { get; set; } - } - } -} diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.ProjectModel.Workspaces/Properties/AssemblyInfo.cs deleted file mode 100644 index bd44bced5..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyMetadataAttribute("Serviceable", "True")] diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/SnkUtils.cs b/src/Microsoft.DotNet.ProjectModel.Workspaces/SnkUtils.cs deleted file mode 100644 index 608d4e023..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/SnkUtils.cs +++ /dev/null @@ -1,87 +0,0 @@ -// 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.Immutable; -using System.IO; - -namespace Microsoft.DotNet.ProjectModel.Workspaces -{ - internal static class SnkUtils - { - const byte PUBLICKEYBLOB = 0x06; - const byte PRIVATEKEYBLOB = 0x07; - - private const uint CALG_RSA_SIGN = 0x00002400; - private const uint CALG_SHA = 0x00008004; - - private const uint RSA1 = 0x31415352; //"RSA1" publickeyblob - private const uint RSA2 = 0x32415352; //"RSA2" privatekeyblob - - private const int VersionOffset = 1; - private const int ModulusLengthOffset = 12; - private const int ExponentOffset = 16; - private const int MagicPrivateKeyOffset = 8; - private const int MagicPublicKeyOffset = 20; - - public static ImmutableArray ExtractPublicKey(byte[] snk) - { - ValidateBlob(snk); - - if (snk[0] != PRIVATEKEYBLOB) - { - return ImmutableArray.Create(snk); - } - - var version = snk[VersionOffset]; - int modulusBitLength = ReadInt32(snk, ModulusLengthOffset); - uint exponent = (uint)ReadInt32(snk, ExponentOffset); - var modulus = new byte[modulusBitLength >> 3]; - - Array.Copy(snk, 20, modulus, 0, modulus.Length); - - return CreatePublicKey(version, exponent, modulus); - } - - private static void ValidateBlob(byte[] snk) - { - // 160 - the size of public key - if (snk.Length >= 160) - { - if (snk[0] == PRIVATEKEYBLOB && ReadInt32(snk, MagicPrivateKeyOffset) == RSA2 || // valid private key - snk[12] == PUBLICKEYBLOB && ReadInt32(snk, MagicPublicKeyOffset) == RSA1) // valid public key - { - return; - } - } - - throw new InvalidOperationException("Invalid key file."); - } - - private static int ReadInt32(byte[] array, int index) - { - return array[index] | array[index + 1] << 8 | array[index + 2] << 16 | array[index + 3] << 24; - } - - private static ImmutableArray CreatePublicKey(byte version, uint exponent, byte[] modulus) - { - using (var ms = new MemoryStream(160)) - using (var binaryWriter = new BinaryWriter(ms)) - { - binaryWriter.Write(CALG_RSA_SIGN); - binaryWriter.Write(CALG_SHA); - // total size of the rest of the blob (20 - size of RSAPUBKEY) - binaryWriter.Write(modulus.Length + 20); - binaryWriter.Write(PUBLICKEYBLOB); - binaryWriter.Write(version); - binaryWriter.Write((ushort)0x00000000); // reserved - binaryWriter.Write(CALG_RSA_SIGN); - binaryWriter.Write(RSA1); - binaryWriter.Write(modulus.Length << 3); - binaryWriter.Write(exponent); - binaryWriter.Write(modulus); - return ImmutableArray.Create(ms.ToArray()); - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/WorkspaceProjectContextExtensions.cs b/src/Microsoft.DotNet.ProjectModel.Workspaces/WorkspaceProjectContextExtensions.cs deleted file mode 100644 index fd54b39c0..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/WorkspaceProjectContextExtensions.cs +++ /dev/null @@ -1,9 +0,0 @@ -using RoslynWorkspace = Microsoft.CodeAnalysis.Workspace; - -namespace Microsoft.DotNet.ProjectModel.Workspaces -{ - public static class WorkspaceProjectContextExtensions - { - public static RoslynWorkspace CreateRoslynWorkspace(this ProjectContext context) => new ProjectJsonWorkspace(context); - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/project.json b/src/Microsoft.DotNet.ProjectModel.Workspaces/project.json deleted file mode 100644 index ef434e125..000000000 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/project.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": "1.0.0-preview3-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk" - }, - "dependencies": { - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "Microsoft.DotNet.Compiler.Common": { - "target": "project" - }, - "Microsoft.CodeAnalysis.CSharp.Workspaces": "2.0.0-beta6-60922-08", - "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933" - }, - "frameworks": { - "netstandard1.5": { - "imports": [ - "portable-net45+wp80+win8+wpa81+dnxcore50", - "portable-net45+win8" - ] - } - } -} diff --git a/src/Microsoft.DotNet.ProjectModel/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.ProjectModel/Properties/AssemblyInfo.cs deleted file mode 100644 index f0ea358d0..000000000 --- a/src/Microsoft.DotNet.ProjectModel/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Microsoft.DotNet.ProjectModel")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.DotNet.ProjectModel")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("303677d5-7312-4c3f-baee-beb1a9bd9fe6")] - -[assembly: AssemblyMetadataAttribute("Serviceable", "True")] -[assembly: InternalsVisibleTo("Microsoft.DotNet.ProjectJsonMigration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] -[assembly: InternalsVisibleTo("Microsoft.DotNet.ProjectModel.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")] -[assembly: - InternalsVisibleTo( - "dotnet-test.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796" - )] \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeEnvironmentRidExtensions.cs b/src/Microsoft.DotNet.ProjectModel/RuntimeEnvironmentRidExtensions.cs deleted file mode 100644 index 3ff7ed5dd..000000000 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeEnvironmentRidExtensions.cs +++ /dev/null @@ -1,84 +0,0 @@ - -using System; -using System.Collections.Generic; -using Microsoft.DotNet.PlatformAbstractions; - -namespace Microsoft.DotNet.InternalAbstractions -{ - // This is to support some legacy stuff. - // dnu restore (and thus dotnet restore) always uses win7-x64 as the Windows restore target, - // so, when picking targets out of the lock file, we need to do version fallback since the - // active RID might be higher than the RID in the lock file. - // - // We should clean this up. Filed #619 to track. - public static class RuntimeEnvironmentRidExtensions - { - // Gets the identfier that is used for restore by default (this is different from the actual RID, but only on Windows) - public static string GetLegacyRestoreRuntimeIdentifier() - { - if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) - { - return RuntimeEnvironment.GetRuntimeIdentifier(); - } - else - { - var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant(); - return "win7-" + arch; - } - } - - public static IEnumerable GetAllCandidateRuntimeIdentifiers() - { - return GetAllCandidateRuntimeIdentifiers(null); - } - - public static IEnumerable GetAllCandidateRuntimeIdentifiers(IEnumerable fallbackIdentifiers = null) - { - List result = new List(); - - if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) - { - result.Add(RuntimeEnvironment.GetRuntimeIdentifier()); - } - else - { - var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant(); - if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.1", StringComparison.Ordinal)) - { - result.Add("win7-" + arch); - } - else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.2", StringComparison.Ordinal)) - { - result.Add("win8-" + arch); - result.Add("win7-" + arch); - } - else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.3", StringComparison.Ordinal)) - { - result.Add("win81-" + arch); - result.Add("win8-" + arch); - result.Add("win7-" + arch); - } - else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("10.0", StringComparison.Ordinal)) - { - result.Add("win10-" + arch); - result.Add("win81-" + arch); - result.Add("win8-" + arch); - result.Add("win7-" + arch); - } - } - - if (fallbackIdentifiers != null) - { - foreach (string fallbackIdentifier in fallbackIdentifiers) - { - if (!result.Contains(fallbackIdentifier)) - { - result.Add(fallbackIdentifier); - } - } - } - - return result; - } - } -} diff --git a/src/Microsoft.DotNet.ProjectModel/project.json b/src/Microsoft.DotNet.ProjectModel/project.json deleted file mode 100644 index 292acc616..000000000 --- a/src/Microsoft.DotNet.ProjectModel/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "version": "1.0.0-rc4-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk" - }, - "description": "Types to model a .NET Project", - "dependencies": { - "Microsoft.Extensions.DependencyModel": "1.0.1-beta-000933", - "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933", - "Newtonsoft.Json": "9.0.1", - "NuGet.Configuration": "3.6.0-rc-1984", - "NuGet.Packaging": "3.6.0-rc-1984", - "NuGet.RuntimeModel": "3.6.0-rc-1984", - "NuGet.ProjectModel": "3.6.0-rc-1984", - "System.Reflection.Metadata": "1.4.1-beta-24410-02" - }, - "frameworks": { - "netstandard1.3": { - "imports": [ - "portable-net45+wp80+win8+wpa81+dnxcore50", - "dotnet5.4" - ], - "dependencies": { - "Microsoft.CSharp": "4.0.1", - "System.Dynamic.Runtime": "4.0.11", - "System.Runtime.Serialization.Primitives": "4.1.1", - "System.Security.Cryptography.Algorithms": "4.2.0", - "System.Threading.Thread": "4.0.0", - "System.Xml.XDocument": "4.0.11" - } - } - } -} diff --git a/src/Microsoft.DotNet.TestFramework/Extensions/DirectoryInfoExtensions.cs b/src/Microsoft.DotNet.TestFramework/Extensions/DirectoryInfoExtensions.cs new file mode 100644 index 000000000..981fc8eee --- /dev/null +++ b/src/Microsoft.DotNet.TestFramework/Extensions/DirectoryInfoExtensions.cs @@ -0,0 +1,25 @@ +// 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.IO; + +namespace Microsoft.DotNet.TestFramework +{ + internal static class DirectoryInfoExtensions + { + public static bool Contains(this DirectoryInfo subject, FileSystemInfo target) + { + return target.FullName.StartsWith(subject.FullName); + } + + public static DirectoryInfo GetDirectory(this DirectoryInfo subject, params string [] directoryNames) + { + return new DirectoryInfo(Path.Combine(subject.FullName, Path.Combine(directoryNames))); + } + + public static FileInfo GetFile(this DirectoryInfo subject, string fileName) + { + return new FileInfo(Path.Combine(subject.FullName, fileName)); + } + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestAssetInfo.cs b/src/Microsoft.DotNet.TestFramework/TestAssetInfo.cs new file mode 100644 index 000000000..2b5772d47 --- /dev/null +++ b/src/Microsoft.DotNet.TestFramework/TestAssetInfo.cs @@ -0,0 +1,229 @@ +// 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.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.PlatformAbstractions; + +namespace Microsoft.DotNet.TestFramework +{ + public class TestAssetInfo + { + private const string DataDirectoryName = ".tam"; + + private readonly string [] FilesToExclude = { ".DS_Store", ".noautobuild" }; + + private readonly DirectoryInfo [] _directoriesToExclude; + + private readonly string _assetName; + + private readonly DirectoryInfo _dataDirectory; + + private readonly DirectoryInfo _root; + + private readonly TestAssetInventoryFiles _inventoryFiles; + + internal DirectoryInfo Root + { + get + { + return _root; + } + } + + internal TestAssetInfo(DirectoryInfo root, string assetName) + { + if (!root.Exists) + { + throw new DirectoryNotFoundException($"Directory not found at '{root}'"); + } + + _assetName = assetName; + + _root = root; + + _dataDirectory = new DirectoryInfo(Path.Combine(_root.FullName, DataDirectoryName)); + + _inventoryFiles = new TestAssetInventoryFiles(_dataDirectory); + + _directoriesToExclude = new [] + { + _dataDirectory + }; + + if (!_dataDirectory.Exists) + { + _dataDirectory.Create(); + } + } + + public TestAssetInstance CreateInstance([CallerMemberName] string callingMethod = "", string identifier = "") + { + var instancePath = GetTestDestinationDirectoryPath(callingMethod, identifier); + + var testInstance = new TestAssetInstance(this, new DirectoryInfo(instancePath)); + + return testInstance; + } + + private string GetTestDestinationDirectoryPath(string callingMethod, string identifier) + { +#if NET451 + string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; +#else + string baseDirectory = AppContext.BaseDirectory; +#endif + return Path.Combine(baseDirectory, callingMethod + identifier, _assetName); + } + + private List LoadInventory(FileInfo file) + { + if (!file.Exists) + { + return null; + } + + var inventory = new List(); + + var lines = file.OpenText(); + + while (lines.Peek() > 0) + { + inventory.Add(new FileInfo(lines.ReadLine())); + } + + return inventory; + } + + private void SaveInventory(FileInfo file, IEnumerable inventory) + { + StreamWriter writer; + + if (file.Exists) + { + writer = file.AppendText(); + } + else + { + writer = file.CreateText(); + } + + using(writer) + { + foreach (var path in inventory.Select(i => i.FullName)) + { + writer.WriteLine(path); + } + } + } + + private IEnumerable GetFileList() + { + return _root.GetFiles("*.*", SearchOption.AllDirectories) + .Where(f => !_directoriesToExclude.Any(d => d.Contains(f))) + .Where(f => !FilesToExclude.Contains(f.Name)); + } + + internal IEnumerable GetSourceFiles() + { + return GetInventory(_inventoryFiles.Source, null, () => {}); + } + + internal IEnumerable GetRestoreFiles() + { + return GetInventory(_inventoryFiles.Restore, GetSourceFiles, DoRestore); + } + + internal IEnumerable GetBuildFiles() + { + return GetInventory(_inventoryFiles.Build, GetRestoreFiles, DoBuild); + } + + private IEnumerable GetInventory(FileInfo file, Func> beforeAction, Action action) + { + if (file.Exists) + { + return LoadInventory(file); + } + + IEnumerable preInventory; + + if (beforeAction == null) + { + preInventory = new List(); + } + else + { + beforeAction(); + + preInventory = GetFileList(); + } + + action(); + + var inventory = GetFileList().Where(i => !preInventory.Select(p => p.FullName).Contains(i.FullName)); + + SaveInventory(file, inventory); + + return inventory; + } + + private void DoRestore() + { + Console.WriteLine($"TestAsset Restore '{_assetName}'"); + + var projFiles = _root.GetFiles("*.csproj", SearchOption.AllDirectories); + + foreach (var projFile in projFiles) + { + var restoreArgs = new string[] { "restore", projFile.FullName, "/p:SkipInvalidConfigurations=true" }; + + var commandResult = Command.Create(new PathCommandResolverPolicy(), "dotnet", restoreArgs) + .CaptureStdOut() + .CaptureStdErr() + .Execute(); + + int exitCode = commandResult.ExitCode; + + if (exitCode != 0) + { + Console.WriteLine(commandResult.StdOut); + + Console.WriteLine(commandResult.StdErr); + + string message = string.Format($"TestAsset Restore '{_assetName}'@'{projFile.FullName}' Failed with {exitCode}"); + + throw new Exception(message); + } + } + } + + private void DoBuild() + { + string[] args = new string[] { "build" }; + + Console.WriteLine($"TestAsset Build '{_assetName}'"); + + var commandResult = Command.Create(new PathCommandResolverPolicy(), "dotnet", args) + .WorkingDirectory(_root.FullName) + .CaptureStdOut() + .CaptureStdErr() + .Execute(); + + int exitCode = commandResult.ExitCode; + + if (exitCode != 0) + { + Console.WriteLine(commandResult.StdOut); + Console.WriteLine(commandResult.StdErr); + string message = string.Format($"TestAsset Build '{_assetName}' Failed with {exitCode}"); + throw new Exception(message); + } + } + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs b/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs new file mode 100644 index 000000000..12c6c27d2 --- /dev/null +++ b/src/Microsoft.DotNet.TestFramework/TestAssetInstance.cs @@ -0,0 +1,87 @@ +// 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.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Tools.Common; + +namespace Microsoft.DotNet.TestFramework +{ + public class TestAssetInstance + { + private TestAssetInfo _testAssetInfo; + + private DirectoryInfo _root; + + public DirectoryInfo Root + { + get + { + return _root; + } + } + + public TestAssetInstance(TestAssetInfo testAssetInfo, DirectoryInfo root) + { + _testAssetInfo = testAssetInfo; + + _root = root; + + if (root.Exists) + { + root.Delete(recursive: true); + } + + root.Create(); + } + + public TestAssetInstance WithSourceFiles() + { + var filesToCopy = _testAssetInfo.GetSourceFiles(); + + CopyFiles(filesToCopy); + + return this; + } + + public TestAssetInstance WithRestoreFiles() + { + var filesToCopy = _testAssetInfo.GetRestoreFiles(); + + CopyFiles(filesToCopy); + + return this; + } + + public TestAssetInstance WithBuildFiles() + { + var filesToCopy = _testAssetInfo.GetBuildFiles(); + + CopyFiles(filesToCopy); + + return this; + } + + private void CopyFiles(IEnumerable filesToCopy) + { + foreach (var file in filesToCopy) + { + var relativePath = file.FullName.Substring(_testAssetInfo.Root.FullName.Length + 1); + + var newPath = Path.Combine(Root.FullName, relativePath); + + var newFile = new FileInfo(newPath); + + PathUtility.EnsureDirectory(newFile.Directory.FullName); + + file.CopyTo(newPath); + } + + } + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestAssetInventoryFiles.cs b/src/Microsoft.DotNet.TestFramework/TestAssetInventoryFiles.cs new file mode 100644 index 000000000..563ba8fd1 --- /dev/null +++ b/src/Microsoft.DotNet.TestFramework/TestAssetInventoryFiles.cs @@ -0,0 +1,76 @@ +// 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.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.DotNet.Cli.Utils; + +namespace Microsoft.DotNet.TestFramework +{ + public class TestAssetInventoryFiles + { + private FileInfo _source; + + private FileInfo _restore; + + private FileInfo _build; + + public FileInfo Source + { + get + { + _source.Refresh(); + + return _source; + } + + private set + { + _source = value; + } + } + + public FileInfo Restore + { + get + { + _restore.Refresh(); + + return _restore; + } + + private set + { + _restore = value; + } + } + + public FileInfo Build + { + get + { + _build.Refresh(); + + return _build; + } + + private set + { + _build = value; + } + } + + public TestAssetInventoryFiles(DirectoryInfo inventoryFileDirectory) + { + Source = new FileInfo(Path.Combine(inventoryFileDirectory.FullName, "source.txt")); + + Restore = new FileInfo(Path.Combine(inventoryFileDirectory.FullName, "restore.txt")); + + Build = new FileInfo(Path.Combine(inventoryFileDirectory.FullName, "build.txt")); + } + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestAssetKinds.cs b/src/Microsoft.DotNet.TestFramework/TestAssetKinds.cs new file mode 100644 index 000000000..6d95b0128 --- /dev/null +++ b/src/Microsoft.DotNet.TestFramework/TestAssetKinds.cs @@ -0,0 +1,20 @@ +// 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.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.DotNet.Cli.Utils; + +namespace Microsoft.DotNet.TestFramework +{ + public class TestAssetKinds + { + public static string DesktopTestProjects = "DesktopTestProjects"; + + public static string TestProjects = "TestProjects"; + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestAssets.cs b/src/Microsoft.DotNet.TestFramework/TestAssets.cs new file mode 100644 index 000000000..a08b225bf --- /dev/null +++ b/src/Microsoft.DotNet.TestFramework/TestAssets.cs @@ -0,0 +1,40 @@ +// 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.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.DotNet.Cli.Utils; + +namespace Microsoft.DotNet.TestFramework +{ + public class TestAssets + { + private DirectoryInfo _root; + + public TestAssets(DirectoryInfo assetsRoot) + { + if (!assetsRoot.Exists) + { + throw new DirectoryNotFoundException($"Directory not found at '{assetsRoot}'"); + } + + _root = assetsRoot; + } + + public TestAssetInfo Get(string name) + { + return Get(TestAssetKinds.TestProjects, name); + } + + public TestAssetInfo Get(string kind, string name) + { + var assetDirectory = new DirectoryInfo(Path.Combine(_root.FullName, kind, name)); + + return new TestAssetInfo(assetDirectory, name); + } + } +} diff --git a/src/Microsoft.DotNet.TestFramework/TestInstance.cs b/src/Microsoft.DotNet.TestFramework/TestInstance.cs index 8e5f8229c..b39adf509 100644 --- a/src/Microsoft.DotNet.TestFramework/TestInstance.cs +++ b/src/Microsoft.DotNet.TestFramework/TestInstance.cs @@ -49,7 +49,7 @@ namespace Microsoft.DotNet.TestFramework .Where(file => { file = file.ToLower(); - return !file.EndsWith("project.lock.json") + return !file.EndsWith("project.assets.json") && !file.Contains($"{System.IO.Path.DirectorySeparatorChar}bin{System.IO.Path.DirectorySeparatorChar}") && !file.Contains($"{System.IO.Path.DirectorySeparatorChar}obj{System.IO.Path.DirectorySeparatorChar}"); }); @@ -61,9 +61,22 @@ namespace Microsoft.DotNet.TestFramework } } + public TestInstance WithNuGetMSBuildFiles() + { + foreach (string file in Directory.GetFiles(_testAssetRoot, "*.nuget.g.*", SearchOption.AllDirectories)) + { + string destinationLockFile = file.Replace(_testAssetRoot, Path); + Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destinationLockFile)); + + File.Copy(file, destinationLockFile, true); + } + + return this; + } + public TestInstance WithLockFiles() { - foreach (string lockFile in Directory.GetFiles(_testAssetRoot, "project.lock.json", SearchOption.AllDirectories)) + foreach (string lockFile in Directory.GetFiles(_testAssetRoot, "project.assets.json", SearchOption.AllDirectories)) { string destinationLockFile = lockFile.Replace(_testAssetRoot, Path); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destinationLockFile)); diff --git a/src/Microsoft.DotNet.Tools.Test/AssemblyTestRunnerDecorator.cs b/src/Microsoft.DotNet.Tools.Test/AssemblyTestRunnerDecorator.cs deleted file mode 100644 index c6d9836b7..000000000 --- a/src/Microsoft.DotNet.Tools.Test/AssemblyTestRunnerDecorator.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Test -{ - public class AssemblyTestRunnerDecorator : IDotnetTestRunner - { - private readonly Func _nextRunner; - - public AssemblyTestRunnerDecorator(Func nextRunner) - { - _nextRunner = nextRunner; - } - - public int RunTests(DotnetTestParams dotnetTestParams) - { - var assembly = new FileInfo(dotnetTestParams.ProjectOrAssemblyPath); - var publishDirectory = assembly.Directory.FullName; - var applicationName = Path.GetFileNameWithoutExtension(dotnetTestParams.ProjectOrAssemblyPath); - - var commandFactory = new PublishedPathCommandFactory(publishDirectory, applicationName); - - var assemblyUnderTest = dotnetTestParams.ProjectOrAssemblyPath; - - return _nextRunner(commandFactory, assemblyUnderTest).RunTests(dotnetTestParams); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Tools.Test/AssemblyUnderTest.cs b/src/Microsoft.DotNet.Tools.Test/AssemblyUnderTest.cs deleted file mode 100644 index 39820969f..000000000 --- a/src/Microsoft.DotNet.Tools.Test/AssemblyUnderTest.cs +++ /dev/null @@ -1,33 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Test -{ - public class AssemblyUnderTest - { - private readonly ProjectContext _projectContext; - private readonly DotnetTestParams _dotentTestParams; - - public AssemblyUnderTest(ProjectContext projectContext, DotnetTestParams dotentTestParams) - { - _projectContext = projectContext; - _dotentTestParams = dotentTestParams; - } - - public string Path - { - get - { - var outputPaths = _projectContext.GetOutputPaths( - _dotentTestParams.Config, - _dotentTestParams.BuildBasePath, - _dotentTestParams.Output); - - return outputPaths.RuntimeFiles.Assembly; - } - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/CommandTestRunnerExtensions.cs b/src/Microsoft.DotNet.Tools.Test/CommandTestRunnerExtensions.cs deleted file mode 100644 index d90df7e6a..000000000 --- a/src/Microsoft.DotNet.Tools.Test/CommandTestRunnerExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -// 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.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Test -{ - public static class CommandTestRunnerExtensions - { - public static TestStartInfo ToTestStartInfo(this ICommand command) - { - return new TestStartInfo - { - FileName = command.CommandName, - Arguments = command.CommandArgs - }; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/ConsoleTestRunner.cs b/src/Microsoft.DotNet.Tools.Test/ConsoleTestRunner.cs deleted file mode 100644 index fa8a6b00e..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ConsoleTestRunner.cs +++ /dev/null @@ -1,55 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.Cli.Utils; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.Test -{ - public class ConsoleTestRunner : IDotnetTestRunner - { - private readonly ITestRunnerNameResolver _testRunnerNameResolver; - - private readonly ICommandFactory _commandFactory; - - private readonly string _assemblyUnderTest; - - private readonly NuGetFramework _framework; - - public ConsoleTestRunner( - ITestRunnerNameResolver testRunnerNameResolver, - ICommandFactory commandFactory, - string assemblyUnderTest, - NuGetFramework framework = null) - { - _testRunnerNameResolver = testRunnerNameResolver; - _commandFactory = commandFactory; - _assemblyUnderTest = assemblyUnderTest; - _framework = framework; - } - - public int RunTests(DotnetTestParams dotnetTestParams) - { - return _commandFactory.Create( - _testRunnerNameResolver.ResolveTestRunner(), - GetCommandArgs(dotnetTestParams), - _framework, - dotnetTestParams.Config) - .Execute() - .ExitCode; - } - - private IEnumerable GetCommandArgs(DotnetTestParams dotnetTestParams) - { - var commandArgs = new List - { - _assemblyUnderTest - }; - - commandArgs.AddRange(dotnetTestParams.RemainingArguments); - - return commandArgs; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/DesignTimeRunner.cs b/src/Microsoft.DotNet.Tools.Test/DesignTimeRunner.cs deleted file mode 100644 index 8d3d37ded..000000000 --- a/src/Microsoft.DotNet.Tools.Test/DesignTimeRunner.cs +++ /dev/null @@ -1,69 +0,0 @@ -// 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 Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Test -{ - public class DesignTimeRunner : IDotnetTestRunner - { - private readonly ITestRunnerNameResolver _testRunnerNameResolver; - - private readonly ICommandFactory _commandFactory; - - private readonly string _assemblyUnderTest; - - public DesignTimeRunner( - ITestRunnerNameResolver testRunnerNameResolver, - ICommandFactory commandFactory, - string assemblyUnderTest) - { - _testRunnerNameResolver = testRunnerNameResolver; - _commandFactory = commandFactory; - _assemblyUnderTest = assemblyUnderTest; - } - - public int RunTests(DotnetTestParams dotnetTestParams) - { - Console.WriteLine("Listening on port {0}", dotnetTestParams.Port.Value); - - HandleDesignTimeMessages(dotnetTestParams); - - return 0; - } - - private void HandleDesignTimeMessages(DotnetTestParams dotnetTestParams) - { - var reportingChannelFactory = new ReportingChannelFactory(); - var adapterChannel = reportingChannelFactory.CreateAdapterChannel(dotnetTestParams.Port.Value); - - try - { - var pathToAssemblyUnderTest = _assemblyUnderTest; - var messages = new TestMessagesCollection(); - using (var dotnetTest = new DotnetTest(messages, pathToAssemblyUnderTest)) - { - var testRunnerFactory = - new TestRunnerFactory(_testRunnerNameResolver.ResolveTestRunner(), _commandFactory); - - dotnetTest - .AddNonSpecificMessageHandlers(messages, adapterChannel) - .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory) - .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory) - .AddTestRunnnersMessageHandlers(adapterChannel, reportingChannelFactory); - - dotnetTest.StartListeningTo(adapterChannel); - - adapterChannel.Connect(); - - dotnetTest.StartHandlingMessages(); - } - } - catch (Exception ex) - { - adapterChannel.SendError(ex); - } - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/DotnetTest.cs b/src/Microsoft.DotNet.Tools.Test/DotnetTest.cs deleted file mode 100644 index b684fce1b..000000000 --- a/src/Microsoft.DotNet.Tools.Test/DotnetTest.cs +++ /dev/null @@ -1,108 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class DotnetTest : IDotnetTest - { - private readonly IList _channels; - private readonly IList _messageHandlers; - private readonly ITestMessagesCollection _messages; - - public IDotnetTestMessageHandler TestSessionTerminateMessageHandler { private get; set; } - public IDotnetTestMessageHandler UnknownMessageHandler { private get; set; } - - public DotnetTestState State { get; private set; } - - public string PathToAssemblyUnderTest { get; } - - public IEnumerable TestsToRun { get; set; } - - public DotnetTest(ITestMessagesCollection messages, string pathToAssemblyUnderTest) - { - PathToAssemblyUnderTest = pathToAssemblyUnderTest; - State = DotnetTestState.InitialState; - _channels = new List(); - _messageHandlers = new List(); - _messages = messages; - } - - public DotnetTest AddMessageHandler(IDotnetTestMessageHandler messageHandler) - { - _messageHandlers.Add(messageHandler); - - return this; - } - - public void StartHandlingMessages() - { - Message message; - while (_messages.TryTake(out message)) - { - HandleMessage(message); - } - } - - public void StartListeningTo(IReportingChannel reportingChannel) - { - ValidateSpecialMessageHandlersArePresent(); - - _channels.Add(reportingChannel); - reportingChannel.MessageReceived += OnMessageReceived; - } - - public void Dispose() - { - foreach (var reportingChannel in _channels) - { - reportingChannel.Dispose(); - } - } - - private void ValidateSpecialMessageHandlersArePresent() - { - if (TestSessionTerminateMessageHandler == null) - { - throw new InvalidOperationException("The TestSession.Terminate message handler needs to be set."); - } - - if (UnknownMessageHandler == null) - { - throw new InvalidOperationException("The unknown message handler needs to be set."); - } - } - - private void HandleMessage(Message message) - { - foreach (var messageHandler in _messageHandlers) - { - var nextState = messageHandler.HandleMessage(this, message); - - if (nextState != DotnetTestState.NoOp) - { - State = nextState; - return; - } - } - - UnknownMessageHandler.HandleMessage(this, message); - } - - private void OnMessageReceived(object sender, Message message) - { - if (!TerminateTestSession(message)) - { - _messages.Add(message); - } - } - - private bool TerminateTestSession(Message message) - { - return TestSessionTerminateMessageHandler.HandleMessage(this, message) == DotnetTestState.Terminated; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/DotnetTestExtensions.cs b/src/Microsoft.DotNet.Tools.Test/DotnetTestExtensions.cs deleted file mode 100644 index 0e4c17b74..000000000 --- a/src/Microsoft.DotNet.Tools.Test/DotnetTestExtensions.cs +++ /dev/null @@ -1,63 +0,0 @@ -// 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.Cli.Tools.Test; - -namespace Microsoft.DotNet.Tools.Test -{ - public static class DotnetTestExtensions - { - public static IDotnetTest AddNonSpecificMessageHandlers( - this IDotnetTest dotnetTest, - ITestMessagesCollection messages, - IReportingChannel adapterChannel) - { - dotnetTest.TestSessionTerminateMessageHandler = new TestSessionTerminateMessageHandler(messages); - dotnetTest.UnknownMessageHandler = new UnknownMessageHandler(adapterChannel); - - dotnetTest.AddMessageHandler(new VersionCheckMessageHandler(adapterChannel)); - - return dotnetTest; - } - - public static IDotnetTest AddTestDiscoveryMessageHandlers( - this IDotnetTest dotnetTest, - IReportingChannel adapterChannel, - IReportingChannelFactory reportingChannelFactory, - ITestRunnerFactory testRunnerFactory) - { - dotnetTest.AddMessageHandler( - new TestDiscoveryStartMessageHandler(testRunnerFactory, adapterChannel, reportingChannelFactory)); - - return dotnetTest; - } - - public static IDotnetTest AddTestRunMessageHandlers( - this IDotnetTest dotnetTest, - IReportingChannel adapterChannel, - IReportingChannelFactory reportingChannelFactory, - ITestRunnerFactory testRunnerFactory) - { - dotnetTest.AddMessageHandler(new GetTestRunnerProcessStartInfoMessageHandler( - testRunnerFactory, - adapterChannel, - reportingChannelFactory)); - - return dotnetTest; - } - - public static IDotnetTest AddTestRunnnersMessageHandlers( - this IDotnetTest dotnetTest, - IReportingChannel adapterChannel, - IReportingChannelFactory reportingChannelFactory) - { - dotnetTest.AddMessageHandler(new TestRunnerTestStartedMessageHandler(adapterChannel)); - dotnetTest.AddMessageHandler(new TestRunnerTestResultMessageHandler(adapterChannel)); - dotnetTest.AddMessageHandler(new TestRunnerTestFoundMessageHandler(adapterChannel)); - dotnetTest.AddMessageHandler(new TestRunnerTestCompletedMessageHandler(adapterChannel)); - dotnetTest.AddMessageHandler(new TestRunnerWaitingCommandMessageHandler(reportingChannelFactory)); - - return dotnetTest; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/DotnetTestParams.cs b/src/Microsoft.DotNet.Tools.Test/DotnetTestParams.cs deleted file mode 100644 index 9bfdadff1..000000000 --- a/src/Microsoft.DotNet.Tools.Test/DotnetTestParams.cs +++ /dev/null @@ -1,189 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Common; -using NuGet.Frameworks; -using static System.Int32; - -namespace Microsoft.DotNet.Tools.Test -{ - public class DotnetTestParams - { - private readonly CommandLineApplication _app; - - private CommandOption _outputOption; - private CommandOption _buildBasePath; - private CommandOption _frameworkOption; - private CommandOption _runtimeOption; - private CommandOption _configurationOption; - private CommandOption _portOption; - private CommandOption _parentProcessIdOption; - private CommandArgument _projectOrAssemblyPath; - private CommandOption _noBuildOption; - private CommandOption _testRunner; - - public int? Port { get; set; } - - public int? ParentProcessId { get; set; } - - public string Runtime { get; set; } - - public string Config { get; set; } - - public string BuildBasePath { get; set; } - - public string Output { get; set; } - - public string ProjectOrAssemblyPath { get; set; } - - public NuGetFramework Framework { get; set; } - - public string UnparsedFramework { get; set; } - - public List RemainingArguments { get; set; } - - public bool NoBuild { get; set; } - - public bool Help { get; set; } - - public string TestRunner { get; set; } - - public bool HasTestRunner => !string.IsNullOrWhiteSpace(TestRunner); - - public bool IsTestingAssembly => ProjectOrAssemblyPath.EndsWith(".dll"); - - public DotnetTestParams() - { - _app = new CommandLineApplication(false) - { - Name = "dotnet test", - FullName = ".NET Test Driver", - Description = "Test Driver for the .NET Platform" - }; - - AddDotnetTestParameters(); - - Help = true; - } - - public void Parse(string[] args) - { - _app.OnExecute(() => - { - // Locate the project and get the name and full path - ProjectOrAssemblyPath = _projectOrAssemblyPath.Value; - if (string.IsNullOrEmpty(ProjectOrAssemblyPath)) - { - ProjectOrAssemblyPath = Directory.GetCurrentDirectory(); - } - - if (_parentProcessIdOption.HasValue()) - { - int processId; - - if (!TryParse(_parentProcessIdOption.Value(), out processId)) - { - throw new InvalidOperationException( - $"Invalid process id '{_parentProcessIdOption.Value()}'. Process id must be an integer."); - } - - ParentProcessId = processId; - } - - if (_portOption.HasValue()) - { - int port; - - if (!TryParse(_portOption.Value(), out port)) - { - throw new InvalidOperationException($"{_portOption.Value()} is not a valid port number."); - } - - Port = port; - } - - if (_testRunner.HasValue()) - { - if (!IsTestingAssembly) - { - throw new InvalidOperationException("You can only specify a test runner with a dll."); - } - - TestRunner = _testRunner.Value(); - } - - UnparsedFramework = _frameworkOption.Value(); - if (_frameworkOption.HasValue()) - { - Framework = NuGetFramework.Parse(_frameworkOption.Value()); - } - - Output = _outputOption.Value(); - BuildBasePath = PathUtility.GetFullPath(_buildBasePath.Value()); - Config = _configurationOption.Value() ?? Constants.DefaultConfiguration; - Runtime = _runtimeOption.Value(); - NoBuild = _noBuildOption.HasValue(); - - RemainingArguments = _app.RemainingArguments; - - Help = false; - - return 0; - }); - - _app.Execute(args); - } - - private void AddDotnetTestParameters() - { - _app.HelpOption("-?|-h|--help"); - - _parentProcessIdOption = _app.Option( - "--parentProcessId", - "Used by IDEs to specify their process ID. Test will exit if the parent process does.", - CommandOptionType.SingleValue); - _portOption = _app.Option( - "--port", - "Used by IDEs to specify a port number to listen for a connection.", - CommandOptionType.SingleValue); - _configurationOption = _app.Option( - "-c|--configuration ", - "Configuration under which to build", - CommandOptionType.SingleValue); - _outputOption = _app.Option( - "-o|--output ", - "Directory in which to find the binaries to be run", - CommandOptionType.SingleValue); - _buildBasePath = _app.Option( - "-b|--build-base-path ", - "Directory in which to find temporary outputs", - CommandOptionType.SingleValue); - _frameworkOption = _app.Option( - "-f|--framework ", - "Looks for test binaries for a specific framework", - CommandOptionType.SingleValue); - _runtimeOption = _app.Option( - "-r|--runtime ", - "Look for test binaries for a for the specified runtime", - CommandOptionType.SingleValue); - _noBuildOption = - _app.Option("--no-build", "Do not build project before testing", CommandOptionType.NoValue); - _testRunner = - _app.Option( - "-t|--test-runner ", - "Test runner to be used to run the test when an assembly to test is specified. If this option " + - "is not provided, we will try to find a suitable runner collocated with the assembly", - CommandOptionType.SingleValue); - _projectOrAssemblyPath = _app.Argument( - "", - "The project or assembly to test, defaults to the current directory. Can be a path to a " + - "project.json, to a dll or a project directory."); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/DotnetTestRunnerFactory.cs b/src/Microsoft.DotNet.Tools.Test/DotnetTestRunnerFactory.cs deleted file mode 100644 index bcef09d91..000000000 --- a/src/Microsoft.DotNet.Tools.Test/DotnetTestRunnerFactory.cs +++ /dev/null @@ -1,56 +0,0 @@ -// 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 Microsoft.DotNet.Cli.Utils; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.Test -{ - public class DotnetTestRunnerFactory : IDotnetTestRunnerFactory - { - private readonly DotnetTestRunnerResolverFactory _dotnetTestRunnerResolverFactory; - - public DotnetTestRunnerFactory(DotnetTestRunnerResolverFactory dotnetTestRunnerResolverFactory) - { - _dotnetTestRunnerResolverFactory = dotnetTestRunnerResolverFactory; - } - - public IDotnetTestRunner Create(DotnetTestParams dotnetTestParams) - { - Func nextTestRunner = - (commandFactory, assemblyUnderTest, framework) => - { - var dotnetTestRunnerResolver = _dotnetTestRunnerResolverFactory.Create(dotnetTestParams); - - IDotnetTestRunner testRunner = - new ConsoleTestRunner(dotnetTestRunnerResolver, commandFactory, assemblyUnderTest, framework); - if (dotnetTestParams.Port.HasValue) - { - testRunner = new DesignTimeRunner(dotnetTestRunnerResolver, commandFactory, assemblyUnderTest); - } - - return testRunner; - }; - - return dotnetTestParams.IsTestingAssembly - ? CreateTestRunnerForAssembly(nextTestRunner) - : CreateTestRunnerForProjectJson(nextTestRunner); - } - - private static IDotnetTestRunner CreateTestRunnerForAssembly( - Func nextTestRunner) - { - Func nextAssemblyTestRunner = - (commandFactory, assemblyUnderTest) => nextTestRunner(commandFactory, assemblyUnderTest, null); - - return new AssemblyTestRunnerDecorator(nextAssemblyTestRunner); - } - - private static IDotnetTestRunner CreateTestRunnerForProjectJson( - Func nextTestRunner) - { - return new ProjectJsonTestRunnerDecorator(nextTestRunner); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/DotnetTestState.cs b/src/Microsoft.DotNet.Tools.Test/DotnetTestState.cs deleted file mode 100644 index 7520f5c75..000000000 --- a/src/Microsoft.DotNet.Tools.Test/DotnetTestState.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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.Tools.Test -{ - public enum DotnetTestState - { - NoOp, - InitialState, - VersionCheckCompleted, - TestDiscoveryStarted, - TestDiscoveryCompleted, - TestExecutionSentTestRunnerProcessStartInfo, - TestExecutionStarted, - TestExecutionCompleted, - Terminated - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/IDotnetTest.cs b/src/Microsoft.DotNet.Tools.Test/IDotnetTest.cs deleted file mode 100644 index 1cf7350f4..000000000 --- a/src/Microsoft.DotNet.Tools.Test/IDotnetTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface IDotnetTest : IDisposable - { - string PathToAssemblyUnderTest { get; } - - DotnetTestState State { get; } - - DotnetTest AddMessageHandler(IDotnetTestMessageHandler messageHandler); - - IDotnetTestMessageHandler TestSessionTerminateMessageHandler { set; } - - IDotnetTestMessageHandler UnknownMessageHandler { set; } - - IEnumerable TestsToRun { get; set; } - - void StartHandlingMessages(); - - void StartListeningTo(IReportingChannel reportingChannel); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/IDotnetTestRunner.cs b/src/Microsoft.DotNet.Tools.Test/IDotnetTestRunner.cs deleted file mode 100644 index 2e40e335c..000000000 --- a/src/Microsoft.DotNet.Tools.Test/IDotnetTestRunner.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Tools.Test -{ - public interface IDotnetTestRunner - { - int RunTests(DotnetTestParams dotnetTestParams); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/IDotnetTestRunnerFactory.cs b/src/Microsoft.DotNet.Tools.Test/IDotnetTestRunnerFactory.cs deleted file mode 100644 index ccb0dc47b..000000000 --- a/src/Microsoft.DotNet.Tools.Test/IDotnetTestRunnerFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Tools.Test -{ - public interface IDotnetTestRunnerFactory - { - IDotnetTestRunner Create(DotnetTestParams dotnetTestParams); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/ITestMessagesCollection.cs b/src/Microsoft.DotNet.Tools.Test/ITestMessagesCollection.cs deleted file mode 100644 index ff462fb6a..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ITestMessagesCollection.cs +++ /dev/null @@ -1,17 +0,0 @@ -// 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 Microsoft.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface ITestMessagesCollection : IDisposable - { - void Drain(); - - void Add(Message message); - - bool TryTake(out Message message); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/GetTestRunnerProcessStartInfoMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/GetTestRunnerProcessStartInfoMessageHandler.cs deleted file mode 100644 index 95931d9cd..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/GetTestRunnerProcessStartInfoMessageHandler.cs +++ /dev/null @@ -1,72 +0,0 @@ -// 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.Extensions.Testing.Abstractions; -using Newtonsoft.Json.Linq; - -namespace Microsoft.DotNet.Tools.Test -{ - public class GetTestRunnerProcessStartInfoMessageHandler : IDotnetTestMessageHandler - { - private readonly ITestRunnerFactory _testRunnerFactory; - private readonly IReportingChannel _adapterChannel; - private readonly IReportingChannelFactory _reportingChannelFactory; - - public GetTestRunnerProcessStartInfoMessageHandler( - ITestRunnerFactory testRunnerFactory, - IReportingChannel adapterChannel, - IReportingChannelFactory reportingChannelFactory) - { - _testRunnerFactory = testRunnerFactory; - _adapterChannel = adapterChannel; - _reportingChannelFactory = reportingChannelFactory; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - - if (CanHandleMessage(dotnetTest, message)) - { - DoHandleMessage(dotnetTest, message); - nextState = DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo; - } - - return nextState; - } - - private void DoHandleMessage(IDotnetTest dotnetTest, Message message) - { - var testRunnerChannel = _reportingChannelFactory.CreateTestRunnerChannel(); - - dotnetTest.StartListeningTo(testRunnerChannel); - - testRunnerChannel.Connect(); - - var testRunner = _testRunnerFactory.CreateTestRunner( - new RunTestsArgumentsBuilder(dotnetTest.PathToAssemblyUnderTest, testRunnerChannel.Port, message)); - - dotnetTest.TestsToRun = message.Payload?.ToObject().Tests; - - var processStartInfo = testRunner.GetProcessStartInfo(); - - _adapterChannel.Send(new Message - { - MessageType = TestMessageTypes.TestExecutionTestRunnerProcessStartInfo, - Payload = JToken.FromObject(processStartInfo) - }); - } - - private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return IsAtAnAcceptableState(dotnetTest) && - message.MessageType == TestMessageTypes.TestExecutionGetTestRunnerProcessStartInfo; - } - - private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) - { - return dotnetTest.State == DotnetTestState.VersionCheckCompleted || - dotnetTest.State == DotnetTestState.InitialState; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/IDotnetTestMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/IDotnetTestMessageHandler.cs deleted file mode 100644 index b2c44c614..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/IDotnetTestMessageHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface IDotnetTestMessageHandler - { - DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestDiscoveryStartMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestDiscoveryStartMessageHandler.cs deleted file mode 100644 index d33109e95..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestDiscoveryStartMessageHandler.cs +++ /dev/null @@ -1,81 +0,0 @@ -// 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; -using Microsoft.DotNet.Tools.Test; -using Microsoft.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Cli.Tools.Test -{ - public class TestDiscoveryStartMessageHandler : IDotnetTestMessageHandler - { - private readonly ITestRunnerFactory _testRunnerFactory; - private readonly IReportingChannel _adapterChannel; - private readonly IReportingChannelFactory _reportingChannelFactory; - - public TestDiscoveryStartMessageHandler( - ITestRunnerFactory testRunnerFactory, - IReportingChannel adapterChannel, - IReportingChannelFactory reportingChannelFactory) - { - _testRunnerFactory = testRunnerFactory; - _adapterChannel = adapterChannel; - _reportingChannelFactory = reportingChannelFactory; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - if (CanHandleMessage(dotnetTest, message)) - { - HandleMessage(dotnetTest); - nextState = DotnetTestState.TestDiscoveryStarted; - } - - return nextState; - } - - private void HandleMessage(IDotnetTest dotnetTest) - { - TestHostTracing.Source.TraceInformation("Starting Discovery"); - - DiscoverTests(dotnetTest); - } - - private void DiscoverTests(IDotnetTest dotnetTest) - { - var testRunnerResults = Enumerable.Empty(); - - try - { - var testRunnerChannel = _reportingChannelFactory.CreateTestRunnerChannel(); - - dotnetTest.StartListeningTo(testRunnerChannel); - - testRunnerChannel.Connect(); - - var testRunner = _testRunnerFactory.CreateTestRunner( - new DiscoverTestsArgumentsBuilder(dotnetTest.PathToAssemblyUnderTest, testRunnerChannel.Port)); - - testRunner.RunTestCommand(); - } - catch (TestRunnerOperationFailedException e) - { - _adapterChannel.SendError(e.Message); - } - } - - private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestDiscoveryStart; - } - - private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) - { - return (dotnetTest.State == DotnetTestState.VersionCheckCompleted || - dotnetTest.State == DotnetTestState.InitialState); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestMessageTypes.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestMessageTypes.cs deleted file mode 100644 index ce76ccef4..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestMessageTypes.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.Tools.Test -{ - public static class TestMessageTypes - { - public const string TestRunnerExecute = "TestRunner.Execute"; - public const string TestRunnerWaitingCommand = "TestRunner.WaitingCommand"; - public const string TestRunnerTestResult = "TestExecution.TestResult"; - public const string TestRunnerTestStarted = "TestExecution.TestStarted"; - public const string TestRunnerTestCompleted = "TestRunner.TestCompleted"; - public const string TestRunnerTestFound = "TestDiscovery.TestFound"; - public const string TestSessionConnected = "TestSession.Connected"; - public const string TestSessionTerminate = "TestSession.Terminate"; - public const string VersionCheck = "ProtocolVersion"; - public const string TestDiscoveryStart = "TestDiscovery.Start"; - public const string TestDiscoveryCompleted = "TestDiscovery.Completed"; - public const string TestDiscoveryTestFound = "TestDiscovery.TestFound"; - public const string TestExecutionGetTestRunnerProcessStartInfo = "TestExecution.GetTestRunnerProcessStartInfo"; - public const string TestExecutionTestRunnerProcessStartInfo = "TestExecution.TestRunnerProcessStartInfo"; - public const string TestExecutionStarted = "TestExecution.TestStarted"; - public const string TestExecutionTestResult = "TestExecution.TestResult"; - public const string TestExecutionCompleted = "TestExecution.Completed"; - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerResultMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerResultMessageHandler.cs deleted file mode 100644 index e33a4bbfb..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerResultMessageHandler.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public abstract class TestRunnerResultMessageHandler : IDotnetTestMessageHandler - { - private readonly IReportingChannel _adapterChannel; - private readonly DotnetTestState _nextStateIfHandled; - private readonly string _messageIfHandled; - - protected TestRunnerResultMessageHandler( - IReportingChannel adapterChannel, - DotnetTestState nextStateIfHandled, - string messageIfHandled) - { - _adapterChannel = adapterChannel; - _nextStateIfHandled = nextStateIfHandled; - _messageIfHandled = messageIfHandled; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - if (CanHandleMessage(dotnetTest, message)) - { - HandleMessage(message); - nextState = _nextStateIfHandled; - } - - return nextState; - } - - private void HandleMessage(Message message) - { - _adapterChannel.Send(new Message - { - MessageType = _messageIfHandled, - Payload = message.Payload - }); - } - - protected abstract bool CanHandleMessage(IDotnetTest dotnetTest, Message message); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestCompletedMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestCompletedMessageHandler.cs deleted file mode 100644 index 8e60b2838..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestCompletedMessageHandler.cs +++ /dev/null @@ -1,67 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerTestCompletedMessageHandler : IDotnetTestMessageHandler - { - private readonly IReportingChannel _adapterChannel; - - public TestRunnerTestCompletedMessageHandler(IReportingChannel adapterChannel) - { - _adapterChannel = adapterChannel; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - if (CanHandleMessage(dotnetTest, message)) - { - DoHandleMessage(dotnetTest, message); - nextState = NextState(dotnetTest); - } - - return nextState; - } - - private void DoHandleMessage(IDotnetTest dotnetTest, Message message) - { - _adapterChannel.Send(new Message - { - MessageType = MessageType(dotnetTest) - }); - } - - private string MessageType(IDotnetTest dotnetTest) - { - return dotnetTest.State == DotnetTestState.TestDiscoveryStarted - ? TestMessageTypes.TestDiscoveryCompleted - : TestMessageTypes.TestExecutionCompleted; - } - - private DotnetTestState NextState(IDotnetTest dotnetTest) - { - return dotnetTest.State == DotnetTestState.TestDiscoveryStarted - ? DotnetTestState.TestDiscoveryCompleted - : DotnetTestState.TestExecutionCompleted; - } - - private bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return IsAtAnAcceptableState(dotnetTest) && CanAcceptMessage(message); - } - - private static bool CanAcceptMessage(Message message) - { - return message.MessageType == TestMessageTypes.TestRunnerTestCompleted; - } - - private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) - { - return (dotnetTest.State == DotnetTestState.TestDiscoveryStarted || - dotnetTest.State == DotnetTestState.TestExecutionStarted); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestFoundMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestFoundMessageHandler.cs deleted file mode 100644 index 78bbbba6a..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestFoundMessageHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerTestFoundMessageHandler : TestRunnerResultMessageHandler - { - public TestRunnerTestFoundMessageHandler(IReportingChannel adapterChannel) - : base(adapterChannel, DotnetTestState.TestDiscoveryStarted, TestMessageTypes.TestDiscoveryTestFound) - { - } - - protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return dotnetTest.State == DotnetTestState.TestDiscoveryStarted && - message.MessageType == TestMessageTypes.TestRunnerTestFound; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestResultMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestResultMessageHandler.cs deleted file mode 100644 index 78bcb4a32..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestResultMessageHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerTestResultMessageHandler : TestRunnerResultMessageHandler - { - public TestRunnerTestResultMessageHandler(IReportingChannel adapterChannel) - : base(adapterChannel, DotnetTestState.TestExecutionStarted, TestMessageTypes.TestExecutionTestResult) - { - } - - protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return dotnetTest.State == DotnetTestState.TestExecutionStarted && - message.MessageType == TestMessageTypes.TestRunnerTestResult; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestStartedMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestStartedMessageHandler.cs deleted file mode 100644 index ac08ebc6c..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerTestStartedMessageHandler.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerTestStartedMessageHandler : TestRunnerResultMessageHandler - { - public TestRunnerTestStartedMessageHandler(IReportingChannel adapterChannel) - : base(adapterChannel, DotnetTestState.TestExecutionStarted, TestMessageTypes.TestExecutionStarted) - { - } - - protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return IsAtAnAcceptableState(dotnetTest) && - message.MessageType == TestMessageTypes.TestRunnerTestStarted; - } - - private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) - { - return dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo || - dotnetTest.State == DotnetTestState.TestExecutionStarted; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerWaitingCommandMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerWaitingCommandMessageHandler.cs deleted file mode 100644 index 8f05566be..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestRunnerWaitingCommandMessageHandler.cs +++ /dev/null @@ -1,73 +0,0 @@ -// 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.Extensions.Testing.Abstractions; -using Newtonsoft.Json.Linq; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerWaitingCommandMessageHandler : IDotnetTestMessageHandler - { - private readonly IReportingChannelFactory _reportingChannelFactory; - private IReportingChannel _testRunnerChannel; - - public TestRunnerWaitingCommandMessageHandler(IReportingChannelFactory reportingChannelFactory) - { - _reportingChannelFactory = reportingChannelFactory; - - _reportingChannelFactory.TestRunnerChannelCreated += OnTestRunnerChannelCreated; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - - if (CanHandleMessage(dotnetTest, message)) - { - HandleMessage(dotnetTest); - nextState = DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo; - } - - return nextState; - } - - private void HandleMessage(IDotnetTest dotnetTest) - { - if (_testRunnerChannel == null) - { - const string errorMessage = - "A test runner channel hasn't been created for TestRunnerWaitingCommandMessageHandler"; - throw new InvalidOperationException(errorMessage); - } - - _testRunnerChannel.Send(new Message - { - MessageType = TestMessageTypes.TestRunnerExecute, - Payload = JToken.FromObject(new RunTestsMessage - { - Tests = new List(dotnetTest.TestsToRun.OrEmptyIfNull()) - }) - }); - } - - private void OnTestRunnerChannelCreated(object sender, IReportingChannel testRunnerChannel) - { - if (_testRunnerChannel != null) - { - const string errorMessage = "TestRunnerWaitingCommandMessageHandler already has a test runner channel"; - throw new InvalidOperationException(errorMessage); - } - - _testRunnerChannel = testRunnerChannel; - } - - private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo && - message.MessageType == TestMessageTypes.TestRunnerWaitingCommand; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestSessionTerminateMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestSessionTerminateMessageHandler.cs deleted file mode 100644 index 39d1dd381..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/TestSessionTerminateMessageHandler.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestSessionTerminateMessageHandler : IDotnetTestMessageHandler - { - private readonly ITestMessagesCollection _messages; - - public TestSessionTerminateMessageHandler(ITestMessagesCollection messages) - { - _messages = messages; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - - if (TestMessageTypes.TestSessionTerminate.Equals(message.MessageType)) - { - nextState = DotnetTestState.Terminated; - _messages.Drain(); - } - - return nextState; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/UnknownMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/UnknownMessageHandler.cs deleted file mode 100644 index d0ce66db1..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/UnknownMessageHandler.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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.Diagnostics; -using Microsoft.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class UnknownMessageHandler : IDotnetTestMessageHandler - { - private readonly IReportingChannel _adapterChannel; - - public UnknownMessageHandler(IReportingChannel adapterChannel) - { - _adapterChannel = adapterChannel; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var error = $"No handler for message '{message.MessageType}' when at state '{dotnetTest.State}'"; - - TestHostTracing.Source.TraceEvent(TraceEventType.Error, 0, error); - - _adapterChannel.SendError(error); - - throw new InvalidOperationException(error); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/VersionCheckMessageHandler.cs b/src/Microsoft.DotNet.Tools.Test/MessageHandlers/VersionCheckMessageHandler.cs deleted file mode 100644 index e6d458337..000000000 --- a/src/Microsoft.DotNet.Tools.Test/MessageHandlers/VersionCheckMessageHandler.cs +++ /dev/null @@ -1,56 +0,0 @@ -// 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.Extensions.Testing.Abstractions; -using Newtonsoft.Json.Linq; - -namespace Microsoft.DotNet.Tools.Test -{ - public class VersionCheckMessageHandler : IDotnetTestMessageHandler - { - private const int SupportedVersion = 1; - - private readonly IReportingChannel _adapterChannel; - - public VersionCheckMessageHandler(IReportingChannel adapterChannel) - { - _adapterChannel = adapterChannel; - } - - public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) - { - var nextState = DotnetTestState.NoOp; - if (CanHandleMessage(dotnetTest, message)) - { - HandleMessage(message); - nextState = DotnetTestState.VersionCheckCompleted; - } - - return nextState; - } - - private void HandleMessage(Message message) - { - var version = message.Payload?.ToObject().Version; - TestHostTracing.Source.TraceInformation( - "[ReportingChannel]: Requested Version: {0} - Using Version: {1}", - version, - SupportedVersion); - - _adapterChannel.Send(new Message - { - MessageType = TestMessageTypes.VersionCheck, - Payload = JToken.FromObject(new ProtocolVersionMessage - { - Version = SupportedVersion, - }), - }); - } - - private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) - { - return dotnetTest.State == DotnetTestState.InitialState && - TestMessageTypes.VersionCheck.Equals(message.MessageType); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/Microsoft.DotNet.Tools.Test.xproj b/src/Microsoft.DotNet.Tools.Test/Microsoft.DotNet.Tools.Test.xproj deleted file mode 100644 index f429f9bf5..000000000 --- a/src/Microsoft.DotNet.Tools.Test/Microsoft.DotNet.Tools.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 6D028154-5518-4A56-BAD6-938A90E5BCF6 - dotnet_test_console - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin - - - - 2.0 - - - diff --git a/src/Microsoft.DotNet.Tools.Test/ProjectJsonTestRunnerDecorator.cs b/src/Microsoft.DotNet.Tools.Test/ProjectJsonTestRunnerDecorator.cs deleted file mode 100644 index c103741a8..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ProjectJsonTestRunnerDecorator.cs +++ /dev/null @@ -1,148 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.Test -{ - public class ProjectJsonTestRunnerDecorator : IDotnetTestRunner - { - private readonly Func _nextRunner; - private readonly TestProjectBuilder _testProjectBuilder; - - public ProjectJsonTestRunnerDecorator( - Func nextRunner) - { - _nextRunner = nextRunner; - _testProjectBuilder = new TestProjectBuilder(); - } - - public int RunTests(DotnetTestParams dotnetTestParams) - { - var projectPath = GetProjectPath(dotnetTestParams.ProjectOrAssemblyPath); - var runtimeIdentifiers = !string.IsNullOrEmpty(dotnetTestParams.Runtime) - ? new[] {dotnetTestParams.Runtime} - : DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject); - var exitCode = 0; - - // Create a workspace - var workspace = new BuildWorkspace(ProjectReaderSettings.ReadFromEnvironment()); - - if (dotnetTestParams.Framework != null) - { - var projectContext = workspace.GetProjectContext(projectPath, dotnetTestParams.Framework); - if (projectContext == null) - { - Reporter.Error.WriteLine( - $"Project '{projectPath}' does not support framework: {dotnetTestParams.UnparsedFramework}"); - return 1; - } - projectContext = workspace.GetRuntimeContext(projectContext, runtimeIdentifiers); - - exitCode = RunTests(projectContext, dotnetTestParams); - } - else - { - var summary = new Summary(); - var projectContexts = workspace.GetProjectContextCollection(projectPath) - .EnsureValid(projectPath) - .FrameworkOnlyContexts - .Select(c => workspace.GetRuntimeContext(c, runtimeIdentifiers)) - .ToList(); - - // Execute for all TFMs the project targets. - foreach (var projectContext in projectContexts) - { - var result = RunTests(projectContext, dotnetTestParams); - if (result == 0) - { - summary.Passed++; - } - else - { - summary.Failed++; - if (exitCode == 0) - { - // If tests fail in more than one TFM, we'll have it use the result of the first one - // as the exit code. - exitCode = result; - } - } - } - - summary.Print(); - } - - return exitCode; - } - - private int RunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams) - { - var result = _testProjectBuilder.BuildTestProject(projectContext, dotnetTestParams); - - if (result == 0) - { - var commandFactory = - new ProjectDependenciesCommandFactory( - projectContext.TargetFramework, - dotnetTestParams.Config, - dotnetTestParams.Output, - dotnetTestParams.BuildBasePath, - projectContext.ProjectDirectory); - - var assemblyUnderTest = new AssemblyUnderTest(projectContext, dotnetTestParams); - - var framework = projectContext.TargetFramework; - - result = _nextRunner(commandFactory, assemblyUnderTest.Path, framework).RunTests(dotnetTestParams); - } - - return result; - } - - private static string GetProjectPath(string projectPath) - { - projectPath = projectPath ?? Directory.GetCurrentDirectory(); - - if (!projectPath.EndsWith(Project.FileName)) - { - projectPath = Path.Combine(projectPath, Project.FileName); - } - - if (!File.Exists(projectPath)) - { - throw new InvalidOperationException($"{projectPath} does not exist."); - } - - return projectPath; - } - - private class Summary - { - public int Passed { get; set; } - - public int Failed { get; set; } - - private int Total => Passed + Failed; - - public void Print() - { - var summaryMessage = $"SUMMARY: Total: {Total} targets, Passed: {Passed}, Failed: {Failed}."; - if (Failed > 0) - { - Reporter.Error.WriteLine(summaryMessage.Red()); - } - else - { - Reporter.Output.WriteLine(summaryMessage); - } - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Tools.Test/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.Tools.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index f0993d023..000000000 --- a/src/Microsoft.DotNet.Tools.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: InternalsVisibleTo("dotnet-test.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")] diff --git a/src/Microsoft.DotNet.Tools.Test/README.md b/src/Microsoft.DotNet.Tools.Test/README.md deleted file mode 100644 index a3b9dc64b..000000000 --- a/src/Microsoft.DotNet.Tools.Test/README.md +++ /dev/null @@ -1,104 +0,0 @@ -% DOTNET-TEST(1) -% Microsoft Corporation dotnetclifeedback@microsoft.com -% April 2016 - -## NAME - -`dotnet-test` - Runs unit tests using the configured test runner - -## SYNOPSIS - -`dotnet test [--configuration] - [--output] [--build-base-path] [--framework] [--runtime] - [--no-build] - [--parentProcessId] [--port] - []` - -## DESCRIPTION - -The `dotnet test` command is used to execute unit tests in a given project. Unit tests are class library -projects that have dependencies on the unit test framework (for example, NUnit or xUnit) and the -dotnet test runner for that unit testing framework. -These are packaged as NuGet packages and are restored as ordinary dependencies for the project. - -Test projects also need to specify a test runner property in project.json using the "testRunner" node. -This value should contain the name of the unit test framework. - -The following sample project.json shows the properties needed: - -```json -{ - "version": "1.0.0-*", - - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0-rc2-3002702", - "type": "platform" - }, - "xunit": "2.1.0", - "dotnet-test-xunit": "1.0.0-rc2-build10015" - }, - "testRunner": "xunit", - - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dnxcore50", - "portable-net45+win8" - ] - } - } -} -``` -`dotnet test` supports two running modes: - -1. Console: In console mode, `dotnet test` simply executes fully any command gets passed to it and outputs the results. Anytime you invoke `dotnet test` without passing --port, it runs in console mode, which in turn will cause the runner to run in console mode. -2. Design time: used in the context of other tools, such as editors or Integrated Development Environments (IDEs). You can find out more about this mode in the [dotnet-test protocol](../../../../Documentation/dotnet-test-protocol.md) document. - -## OPTIONS - -`[project]` - -Specifies a path to the test project. If omitted, it defaults to current directory. - -`-c`, `--configuration` [Debug|Release] - -Configuration under which to build. The default value is Release. - -`-o`, `--output` [DIR] - -Directory in which to find binaries to run. - -`-b`, `--build-base-path` [DIR] - -Directory in which to place temporary outputs. - -`-f`, `--framework` [FRAMEWORK] - -Looks for test binaries for a specific framework. - -`-r`, `--runtime` [RUNTIME_IDENTIFIER] - -Look for test binaries for a for the specified runtime. - -`--no-build` - -Does not build the test project prior to running it. - ---parentProcessId - -Used by IDEs to specify their process ID. Test will exit if the parent process does. - -`--port` - -Used by IDEs to specify a port number to listen for a connection. - -## EXAMPLES - -`dotnet test` - -Runs the tests in the project in the current directory. - -`dotnet test /projects/test1/project.json` - -Runs the tests in the test1 project. diff --git a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/AdapterReportingChannel.cs b/src/Microsoft.DotNet.Tools.Test/ReportingChannels/AdapterReportingChannel.cs deleted file mode 100644 index 1bf9ffb21..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/AdapterReportingChannel.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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.Extensions.Testing.Abstractions; -using System.Net; -using System.Net.Sockets; - -namespace Microsoft.DotNet.Tools.Test -{ - public class AdapterReportingChannel : ReportingChannel - { - private readonly IPEndPoint _ipEndPoint; - - public static AdapterReportingChannel ConnectTo(int port) - { - var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - - var ipEndPoint = new IPEndPoint(IPAddress.Loopback, port); - - return new AdapterReportingChannel(socket, ipEndPoint); - } - - private AdapterReportingChannel(Socket connectSocket, IPEndPoint ipEndPoint) - : base(connectSocket, ipEndPoint.Port) - { - _ipEndPoint = ipEndPoint; - } - - public override void Connect() - { - Socket = ConnectSocket; - - Socket.Connect(_ipEndPoint); - - StartReadingMessages(); - - Send(new Message - { - MessageType = TestMessageTypes.TestSessionConnected - }); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannel.cs b/src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannel.cs deleted file mode 100644 index 0729b4032..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannel.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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.Threading.Tasks; -using Microsoft.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface IReportingChannel : IDisposable - { - event EventHandler MessageReceived; - - int Port { get; } - - void Connect(); - - void Send(Message message); - - void SendError(string error); - - void SendError(Exception ex); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannelFactory.cs b/src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannelFactory.cs deleted file mode 100644 index 2f35fffd2..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/IReportingChannelFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface IReportingChannelFactory - { - event EventHandler TestRunnerChannelCreated; - - IReportingChannel CreateTestRunnerChannel(); - - IReportingChannel CreateAdapterChannel(int port); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannel.cs b/src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannel.cs deleted file mode 100644 index 624e75c32..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannel.cs +++ /dev/null @@ -1,130 +0,0 @@ -// 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.Diagnostics; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Testing.Abstractions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.DotNet.Tools.Test -{ - public abstract class ReportingChannel : IReportingChannel - { - private BinaryWriter _writer; - private BinaryReader _reader; - - protected ReportingChannel(Socket connectSocket, int port) - { - ConnectSocket = connectSocket; - Port = port; - } - - protected Socket Socket { get; set; } - - public event EventHandler MessageReceived; - - public Socket ConnectSocket { get; } - - public int Port { get; } - - public abstract void Connect(); - - public void Send(Message message) - { - lock (_writer) - { - try - { - TestHostTracing.Source.TraceEvent( - TraceEventType.Verbose, - 0, - "[ReportingChannel]: Send({0})", - message); - - _writer.Write(JsonConvert.SerializeObject(message)); - } - catch (Exception ex) - { - TestHostTracing.Source.TraceEvent( - TraceEventType.Error, - 0, - "[ReportingChannel]: Error sending {0}", - ex); - throw; - } - } - } - - public void SendError(string error) - { - Send(new Message() - { - MessageType = "Error", - Payload = JToken.FromObject(new ErrorMessage() - { - Message = error, - }), - }); - } - - public void SendError(Exception ex) - { - SendError(ex.ToString()); - } - - protected void StartReadingMessages() - { - var stream = new NetworkStream(Socket); - _writer = new BinaryWriter(stream); - _reader = new BinaryReader(stream); - - // Read incoming messages on the background thread - new Thread(ReadMessages) { IsBackground = true }.Start(); - } - - private void ReadMessages() - { - while (true) - { - try - { - var rawMessage = _reader.ReadString(); - var message = JsonConvert.DeserializeObject(rawMessage); - - MessageReceived?.Invoke(this, message); - - if (ShouldStopListening(message)) - { - break; - } - } - catch (Exception ex) - { - TestHostTracing.Source.TraceEvent( - TraceEventType.Error, - 0, - "[ReportingChannel]: Waiting for message failed {0}", - ex); - throw; - } - } - } - - private static bool ShouldStopListening(Message message) - { - return message.MessageType == TestMessageTypes.TestRunnerTestCompleted || - message.MessageType == TestMessageTypes.TestSessionTerminate; - } - - public void Dispose() - { - Socket?.Dispose(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannelFactory.cs b/src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannelFactory.cs deleted file mode 100644 index 0ecec58c6..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/ReportingChannelFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.Tools.Test -{ - public class ReportingChannelFactory : IReportingChannelFactory - { - public event EventHandler TestRunnerChannelCreated; - - public IReportingChannel CreateTestRunnerChannel() - { - var testRunnerChannel = TestRunnerReportingChannel.ListenOn(0); - - TestRunnerChannelCreated?.Invoke(this, testRunnerChannel); - - return testRunnerChannel; - } - - public IReportingChannel CreateAdapterChannel(int port) - { - return AdapterReportingChannel.ConnectTo(port); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/TestRunnerReportingChannel.cs b/src/Microsoft.DotNet.Tools.Test/ReportingChannels/TestRunnerReportingChannel.cs deleted file mode 100644 index 204988441..000000000 --- a/src/Microsoft.DotNet.Tools.Test/ReportingChannels/TestRunnerReportingChannel.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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.Net; -using System.Net.Sockets; -using System.Threading; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerReportingChannel : ReportingChannel - { - public static ReportingChannel ListenOn(int port) - { - // This fixes the mono incompatibility but ties it to ipv4 connections - var listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - - listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, port)); - listenSocket.Listen(10); - - return new TestRunnerReportingChannel(listenSocket, ((IPEndPoint)listenSocket.LocalEndPoint)); - } - - private TestRunnerReportingChannel(Socket connectSocket, IPEndPoint ipEndPoint) - : base(connectSocket, ipEndPoint.Port) - { - } - - public override void Connect() - { - new Thread(() => - { - using (ConnectSocket) - { - Socket = ConnectSocket.Accept(); - - StartReadingMessages(); - } - }) - { IsBackground = true }.Start(); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestCommand.cs b/src/Microsoft.DotNet.Tools.Test/TestCommand.cs deleted file mode 100644 index 8d40829a0..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestCommand.cs +++ /dev/null @@ -1,100 +0,0 @@ -// 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.Diagnostics; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.InternalAbstractions; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestCommand - { - private readonly IDotnetTestRunnerFactory _dotnetTestRunnerFactory; - - public static int Run(string[] args) - { - var dotnetTestRunnerResolverFactory = new DotnetTestRunnerResolverFactory(new ProjectReader()); - var testCommand = new TestCommand(new DotnetTestRunnerFactory(dotnetTestRunnerResolverFactory)); - - return testCommand.DoRun(args); - } - - public TestCommand(IDotnetTestRunnerFactory testRunnerFactory) - { - _dotnetTestRunnerFactory = testRunnerFactory; - } - - public int DoRun(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - var dotnetTestParams = new DotnetTestParams(); - - try - { - dotnetTestParams.Parse(args); - - if (dotnetTestParams.Help) - { - return 0; - } - - // Register for parent process's exit event - if (dotnetTestParams.ParentProcessId.HasValue) - { - RegisterForParentProcessExit(dotnetTestParams.ParentProcessId.Value); - } - - return RunTest(dotnetTestParams); - } - catch (InvalidOperationException ex) - { - TestHostTracing.Source.TraceEvent(TraceEventType.Error, 0, ex.ToString()); - return -1; - } - catch (Exception ex) when (!(ex is GracefulException)) - { - Console.WriteLine(ex.ToString()); - TestHostTracing.Source.TraceEvent(TraceEventType.Error, 0, ex.ToString()); - return -2; - } - } - - private static void RegisterForParentProcessExit(int id) - { - var parentProcess = Process.GetProcesses().FirstOrDefault(p => p.Id == id); - - if (parentProcess != null) - { - parentProcess.EnableRaisingEvents = true; - parentProcess.Exited += (sender, eventArgs) => - { - TestHostTracing.Source.TraceEvent( - TraceEventType.Information, - 0, - "Killing the current process as parent process has exited."); - - Process.GetCurrentProcess().Kill(); - }; - } - else - { - TestHostTracing.Source.TraceEvent( - TraceEventType.Information, - 0, - "Failed to register for parent process's exit event. " + - $"Parent process with id '{id}' was not found."); - } - } - - private int RunTest(DotnetTestParams dotnetTestParams) - { - var dotnetTestRunner = _dotnetTestRunnerFactory.Create(dotnetTestParams); - return dotnetTestRunner.RunTests(dotnetTestParams); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Tools.Test/TestHostTracing.cs b/src/Microsoft.DotNet.Tools.Test/TestHostTracing.cs deleted file mode 100644 index 44299586b..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestHostTracing.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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.Diagnostics; - -namespace Microsoft.DotNet.Tools.Test -{ - public static class TestHostTracing - { - public static readonly string TracingEnvironmentVariable = "DOTNET_TEST_TRACE"; - - public static readonly TraceSource Source; - - static TestHostTracing() - { - Source = Environment.GetEnvironmentVariable(TracingEnvironmentVariable) == "1" - ? new TraceSource("dotnet-test", SourceLevels.Verbose) - : new TraceSource("dotnet-test", SourceLevels.Warning); - - Source.Listeners.Add(new TextWriterTraceListener(Console.Error)); - } - - public static void ClearListeners() - { - Source.Listeners.Clear(); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestMessagesCollection.cs b/src/Microsoft.DotNet.Tools.Test/TestMessagesCollection.cs deleted file mode 100644 index d803f4a81..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestMessagesCollection.cs +++ /dev/null @@ -1,73 +0,0 @@ -// 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.Collections.Concurrent; -using System.Diagnostics; -using System.Threading; -using Microsoft.Extensions.Testing.Abstractions; -using System; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestMessagesCollection : ITestMessagesCollection - { - private readonly ManualResetEventSlim _terminateWaitHandle; - private readonly BlockingCollection _readQueue; - - public TestMessagesCollection() - { - _readQueue = new BlockingCollection(); - _terminateWaitHandle = new ManualResetEventSlim(); - } - - public void Drain() - { - _terminateWaitHandle.Set(); - _readQueue.CompleteAdding(); - DrainQueue(); - } - - public void Add(Message message) - { - _readQueue.Add(message); - } - - public bool TryTake(out Message message) - { - message = null; - try - { - message = _readQueue.Take(); - } - catch (InvalidOperationException) - { - return false; - } - - return true; - } - - public void Dispose() - { - if (_terminateWaitHandle.Wait(TimeSpan.FromSeconds(10))) - { - TestHostTracing.Source.TraceInformation("[ReportingChannel]: Received TestSession:Terminate from test host"); - } - else - { - TestHostTracing.Source.TraceEvent( - TraceEventType.Error, - 0, - "[ReportingChannel]: Timed out waiting for aTestSession:Terminate from test host"); - } - } - - private void DrainQueue() - { - Message message; - while (_readQueue.TryTake(out message, millisecondsTimeout: 1)) - { - } - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestProjectBuilder.cs b/src/Microsoft.DotNet.Tools.Test/TestProjectBuilder.cs deleted file mode 100644 index ffaafbf70..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestProjectBuilder.cs +++ /dev/null @@ -1,52 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestProjectBuilder - { - public int BuildTestProject(ProjectContext projectContext, DotnetTestParams dotnetTestParams) - { - return dotnetTestParams.NoBuild ? 0 : DoBuildTestProject(projectContext, dotnetTestParams); - } - - private int DoBuildTestProject(ProjectContext projectContext, DotnetTestParams dotnetTestParams) - { - var strings = new List - { - $"{dotnetTestParams.ProjectOrAssemblyPath}", - $"--configuration", dotnetTestParams.Config, - "--framework", projectContext.TargetFramework.ToString() - }; - - // Build the test specifically for the target framework \ rid of the ProjectContext. - // This avoids building the project for tfms that the user did not request. - - if (!string.IsNullOrEmpty(dotnetTestParams.BuildBasePath)) - { - strings.Add("--build-base-path"); - strings.Add(dotnetTestParams.BuildBasePath); - } - - if (!string.IsNullOrEmpty(dotnetTestParams.Output)) - { - strings.Add("--output"); - strings.Add(dotnetTestParams.Output); - } - - if (!string.IsNullOrEmpty(projectContext.RuntimeIdentifier)) - { - strings.Add("--runtime"); - strings.Add(projectContext.RuntimeIdentifier); - } - - var result = Command.CreateDotNet("build", strings).Execute().ExitCode; - - return result; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/AssemblyTestRunnerNameResolver.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/AssemblyTestRunnerNameResolver.cs deleted file mode 100644 index 0b006f1a6..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/AssemblyTestRunnerNameResolver.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.Extensions.EnvironmentAbstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class AssemblyTestRunnerNameResolver : ITestRunnerNameResolver - { - private readonly string _directoryOfAssemblyUnderTest; - - private readonly IDirectory _directory; - - public AssemblyTestRunnerNameResolver(string assemblyUnderTest) : - this(assemblyUnderTest, FileSystemWrapper.Default.Directory) - { - } - - internal AssemblyTestRunnerNameResolver(string assemblyUnderTest, IDirectory directory) - { - _directoryOfAssemblyUnderTest = directory.GetDirectoryFullName(assemblyUnderTest); - _directory = directory; - } - - public string ResolveTestRunner() - { - var testRunnerPath = _directory.GetFiles(_directoryOfAssemblyUnderTest, "dotnet-test-*").FirstOrDefault(); - - return Path.GetFileNameWithoutExtension(testRunnerPath); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/DiscoverTestsArgumentsBuilder.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/DiscoverTestsArgumentsBuilder.cs deleted file mode 100644 index 7f1202d00..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/DiscoverTestsArgumentsBuilder.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.Extensions.Testing.Abstractions; -using System.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Test -{ - public class DiscoverTestsArgumentsBuilder : ITestRunnerArgumentsBuilder - { - private readonly string _assemblyUnderTest; - private readonly int _port; - - public DiscoverTestsArgumentsBuilder(string assemblyUnderTest, int port) - { - _assemblyUnderTest = assemblyUnderTest; - _port = port; - } - - public IEnumerable BuildArguments() - { - var commandArgs = new List - { - _assemblyUnderTest, - "--list", - "--designtime", - "--port", - $"{_port}" - }; - - return commandArgs; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/DotnetTestRunnerResolverFactory.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/DotnetTestRunnerResolverFactory.cs deleted file mode 100644 index efe9cc877..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/DotnetTestRunnerResolverFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Test -{ - public class DotnetTestRunnerResolverFactory - { - private readonly IProjectReader _projectReader; - - public DotnetTestRunnerResolverFactory(IProjectReader projectReader) - { - _projectReader = projectReader; - } - - public ITestRunnerNameResolver Create(DotnetTestParams dotnetTestParams) - { - var testRunnerResolver = dotnetTestParams.IsTestingAssembly ? - GetAssemblyTestRunnerResolver(dotnetTestParams) : - GetProjectJsonTestRunnerResolver(dotnetTestParams); - - return testRunnerResolver; - } - - private ITestRunnerNameResolver GetAssemblyTestRunnerResolver(DotnetTestParams dotnetTestParams) - { - ITestRunnerNameResolver testRunnerNameResolver = null; - if (dotnetTestParams.HasTestRunner) - { - testRunnerNameResolver = new ParameterTestRunnerNameResolver(dotnetTestParams.TestRunner); - } - else - { - testRunnerNameResolver = new AssemblyTestRunnerNameResolver(dotnetTestParams.ProjectOrAssemblyPath); - } - - return testRunnerNameResolver; - } - - private ITestRunnerNameResolver GetProjectJsonTestRunnerResolver(DotnetTestParams dotnetTestParams) - { - var project = _projectReader.ReadProject(dotnetTestParams.ProjectOrAssemblyPath); - return new ProjectJsonTestRunnerNameResolver(project); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunner.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunner.cs deleted file mode 100644 index 4534c1be2..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunner.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Tools.Test -{ - public interface ITestRunner - { - void RunTestCommand(); - - TestStartInfo GetProcessStartInfo(); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerArgumentsBuilder.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerArgumentsBuilder.cs deleted file mode 100644 index 55bbd3aa9..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerArgumentsBuilder.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface ITestRunnerArgumentsBuilder - { - IEnumerable BuildArguments(); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerFactory.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerFactory.cs deleted file mode 100644 index d702eccb7..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public interface ITestRunnerFactory - { - ITestRunner CreateTestRunner(ITestRunnerArgumentsBuilder argumentsBuilder); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerNameResolver.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerNameResolver.cs deleted file mode 100644 index aa0d94243..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/ITestRunnerNameResolver.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Tools.Test -{ - public interface ITestRunnerNameResolver - { - string ResolveTestRunner(); - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/ParameterTestRunnerNameResolver.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/ParameterTestRunnerNameResolver.cs deleted file mode 100644 index 7a393f0b8..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/ParameterTestRunnerNameResolver.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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.Tools.Test -{ - public class ParameterTestRunnerNameResolver : ITestRunnerNameResolver - { - private readonly string _testRunner; - - public ParameterTestRunnerNameResolver(string testRunner) - { - _testRunner = testRunner; - } - - public string ResolveTestRunner() - { - return $"dotnet-test-{_testRunner}"; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/ProjectJsonTestRunnerNameResolver.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/ProjectJsonTestRunnerNameResolver.cs deleted file mode 100644 index 2de3784c7..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/ProjectJsonTestRunnerNameResolver.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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.ProjectModel; - -namespace Microsoft.DotNet.Tools.Test -{ - public class ProjectJsonTestRunnerNameResolver : ITestRunnerNameResolver - { - private Project _project; - - public ProjectJsonTestRunnerNameResolver(Project project) - { - _project = project; - } - - public string ResolveTestRunner() - { - return string.IsNullOrEmpty(_project.TestRunner) ? null : $"dotnet-test-{_project.TestRunner}"; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/RunTestsArgumentsBuilder.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/RunTestsArgumentsBuilder.cs deleted file mode 100644 index 7a2c86f4f..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/RunTestsArgumentsBuilder.cs +++ /dev/null @@ -1,36 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.Extensions.Testing.Abstractions; - -namespace Microsoft.DotNet.Tools.Test -{ - public class RunTestsArgumentsBuilder : ITestRunnerArgumentsBuilder - { - private readonly string _assemblyUnderTest; - private readonly int _port; - private readonly Message _message; - - public RunTestsArgumentsBuilder(string assemblyUnderTest, int port, Message message) - { - _assemblyUnderTest = assemblyUnderTest; - _port = port; - _message = message; - } - - public IEnumerable BuildArguments() - { - var commandArgs = new List - { - _assemblyUnderTest, - "--designtime", - "--port", - $"{_port}", - "--wait-command" - }; - - return commandArgs; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunner.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunner.cs deleted file mode 100644 index 6ef3474d5..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunner.cs +++ /dev/null @@ -1,60 +0,0 @@ -// 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.Diagnostics; -using Microsoft.DotNet.Cli.Utils; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunner : ITestRunner - { - private readonly string _testRunner; - private readonly ICommandFactory _commandFactory; - private readonly ITestRunnerArgumentsBuilder _argumentsBuilder; - - public TestRunner( - string testRunner, - ICommandFactory commandFactory, - ITestRunnerArgumentsBuilder argumentsBuilder) - { - _testRunner = testRunner; - _commandFactory = commandFactory; - _argumentsBuilder = argumentsBuilder; - } - - public void RunTestCommand() - { - ExecuteRunnerCommand(); - } - - public TestStartInfo GetProcessStartInfo() - { - var command = CreateTestRunnerCommand(); - - return command.ToTestStartInfo(); - } - - private void ExecuteRunnerCommand() - { - var result = CreateTestRunnerCommand().Execute(); - - if (result.ExitCode != 0) - { - throw new TestRunnerOperationFailedException(_testRunner, result.ExitCode); - } - } - - private ICommand CreateTestRunnerCommand() - { - var commandArgs = _argumentsBuilder.BuildArguments(); - - return _commandFactory.Create( - $"{_testRunner}", - commandArgs, - null, - null); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerFactory.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerFactory.cs deleted file mode 100644 index 7c28b910d..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerFactory.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerFactory : ITestRunnerFactory - { - private readonly string _testRunner; - private readonly ICommandFactory _commandFactory; - - public TestRunnerFactory(string testRunner, ICommandFactory commandFactory) - { - _testRunner = testRunner; - _commandFactory = commandFactory; - } - - public ITestRunner CreateTestRunner(ITestRunnerArgumentsBuilder argumentsBuilder) - { - return new TestRunner(_testRunner, _commandFactory, argumentsBuilder); - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerOperationFailedException.cs b/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerOperationFailedException.cs deleted file mode 100644 index 4a718f328..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestRunners/TestRunnerOperationFailedException.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.Tools.Test -{ - public class TestRunnerOperationFailedException : Exception - { - public string TestRunner { get; set; } - public int ExitCode { get; set; } - public override string Message => $"'{TestRunner}' returned '{ExitCode}'."; - - public TestRunnerOperationFailedException(string testRunner, int exitCode) - { - TestRunner = testRunner; - ExitCode = exitCode; - } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/TestStartInfo.cs b/src/Microsoft.DotNet.Tools.Test/TestStartInfo.cs deleted file mode 100644 index 0a71ea551..000000000 --- a/src/Microsoft.DotNet.Tools.Test/TestStartInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Tools.Test -{ - public class TestStartInfo - { - public string FileName { get; set; } - - public string Arguments { get; set; } - } -} diff --git a/src/Microsoft.DotNet.Tools.Test/project.json b/src/Microsoft.DotNet.Tools.Test/project.json deleted file mode 100644 index cf39effa5..000000000 --- a/src/Microsoft.DotNet.Tools.Test/project.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version": "1.0.0-preview3-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk", - "compile": { - "include": [ - "**/*.cs", - "../dotnet/CommandLine/*.cs", - "../dotnet/DotnetFiles.cs" - ] - } - }, - - "dependencies": { - "System.Diagnostics.TraceSource": "4.0.0", - "System.Diagnostics.TextWriterTraceListener": "4.0.0", - "Microsoft.DotNet.Cli.Utils": { - "target": "project" - }, - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "Microsoft.Extensions.Testing.Abstractions": { - "target": "project" - }, - "Microsoft.DotNet.InternalAbstractions": { - "target": "project" - }, - "Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933" - }, - - "frameworks": { - "netstandard1.6": { - "imports": [ - "portable-net45+wp80+win8+wpa81+dnxcore50" - ] - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/ComStreamWrapper.cs b/src/Microsoft.Extensions.Testing.Abstractions/ComStreamWrapper.cs deleted file mode 100644 index b1eb9713d..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/ComStreamWrapper.cs +++ /dev/null @@ -1,98 +0,0 @@ -// 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.Diagnostics; -using System.IO; -using System.Runtime.InteropServices.ComTypes; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - internal sealed class ComStreamWrapper : IStream - { - private readonly Stream _stream; - - public ComStreamWrapper(Stream stream) - { - Debug.Assert(stream != null); - Debug.Assert(stream.CanSeek); - - _stream = stream; - } - - public void Commit(int grfCommitFlags) - { - _stream.Flush(); - } - - /// - /// The actual number of bytes read can be fewer than the number of bytes requested - /// if an error occurs or if the end of the stream is reached during the read operation. - /// - public unsafe void Read(byte[] pv, int cb, IntPtr pcbRead) - { - int bytesRead = _stream.Read(pv, 0, cb); - - if (pcbRead != IntPtr.Zero) - { - *(int*)pcbRead = bytesRead; - } - } - - public unsafe void Seek(long dlibMove, int origin, IntPtr plibNewPosition) - { - long newPosition = _stream.Seek(dlibMove, (SeekOrigin)origin); - if (plibNewPosition != IntPtr.Zero) - { - *(long*)plibNewPosition = newPosition; - } - } - - public void SetSize(long libNewSize) - { - _stream.SetLength(libNewSize); - } - - public void Stat(out STATSTG pstatstg, int grfStatFlag) - { - pstatstg = new STATSTG() - { - cbSize = _stream.Length - }; - } - - public unsafe void Write(byte[] pv, int cb, IntPtr pcbWritten) - { - _stream.Write(pv, 0, cb); - if (pcbWritten != IntPtr.Zero) - { - *(int*)pcbWritten = cb; - } - } - - public void Clone(out IStream ppstm) - { - throw new NotSupportedException(); - } - - public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten) - { - throw new NotSupportedException(); - } - - public void LockRegion(long libOffset, long cb, int lockType) - { - throw new NotSupportedException(); - } - - public void Revert() - { - throw new NotSupportedException(); - } - - public void UnlockRegion(long libOffset, long cb, int lockType) - { - throw new NotSupportedException(); - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/FullPdbReader.cs b/src/Microsoft.Extensions.Testing.Abstractions/FullPdbReader.cs deleted file mode 100644 index d5339096b..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/FullPdbReader.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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.IO; -using System.Reflection; -using System.Runtime.InteropServices; -using Microsoft.DiaSymReader; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class FullPdbReader : IPdbReader - { - [DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)] - [DllImport("Microsoft.DiaSymReader.Native.x86.dll", EntryPoint = "CreateSymReader")] - private extern static void CreateSymReader32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader); - - [DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)] - [DllImport("Microsoft.DiaSymReader.Native.amd64.dll", EntryPoint = "CreateSymReader")] - private extern static void CreateSymReader64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader); - - private readonly ISymUnmanagedReader3 _symReader; - - public FullPdbReader(Stream pdbStream) - { - pdbStream.Position = 0; - - _symReader = CreateNativeSymReader(pdbStream); - } - - public SourceInformation GetSourceInformation(MethodInfo methodInfo) - { - if (methodInfo == null) - { - return null; - } - - var methodToken = methodInfo.GetMethodToken(); - - var method = GetMethod(methodToken); - - return method?.GetSourceInformation(); - } - - private ISymUnmanagedMethod GetMethod(int methodToken) - { - ISymUnmanagedMethod method; - _symReader.GetMethod(methodToken, out method); - return method; - } - - private static ISymUnmanagedReader3 CreateNativeSymReader(Stream pdbStream) - { - try - { - object symReader = null; - var guid = default(Guid); - if (IntPtr.Size == 4) - { - CreateSymReader32(ref guid, out symReader); - } - else - { - CreateSymReader64(ref guid, out symReader); - } - var reader = (ISymUnmanagedReader3)symReader; - var hr = reader.Initialize(new DummyMetadataImport(), null, null, new ComStreamWrapper(pdbStream)); - SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr); - return reader; - } - catch (Exception e) - { - throw new IOException(e.Message, e); - } - } - - public void Dispose() - { - ((ISymUnmanagedDispose)_symReader).Destroy(); - } - } - - [ComVisible(false)] - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44")] - interface IMetadataImport { } - - class DummyMetadataImport : IMetadataImport { } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/IPdbReader.cs b/src/Microsoft.Extensions.Testing.Abstractions/IPdbReader.cs deleted file mode 100644 index a9af07762..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/IPdbReader.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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.Reflection; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public interface IPdbReader : IDisposable - { - SourceInformation GetSourceInformation(MethodInfo methodInfo); - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/IPdbReaderFactory.cs b/src/Microsoft.Extensions.Testing.Abstractions/IPdbReaderFactory.cs deleted file mode 100644 index d6f7a23e3..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/IPdbReaderFactory.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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.IO; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public interface IPdbReaderFactory - { - /// - /// Creates for given file. - /// - /// - /// Path to the .pdb file or a PE file that refers to the .pdb file in its Debug Directory Table. - /// - /// File does not exist or can't be read. - /// is null. - IPdbReader Create(string pdbPath); - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/ISourceInformationProvider.cs b/src/Microsoft.Extensions.Testing.Abstractions/ISourceInformationProvider.cs deleted file mode 100644 index a1616b9b9..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/ISourceInformationProvider.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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.Reflection; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public interface ISourceInformationProvider : IDisposable - { - SourceInformation GetSourceInformation(MethodInfo method); - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/ITestDiscoverySink.cs b/src/Microsoft.Extensions.Testing.Abstractions/ITestDiscoverySink.cs deleted file mode 100644 index b5e6d4f49..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/ITestDiscoverySink.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Extensions.Testing.Abstractions -{ - public interface ITestDiscoverySink : ITestSink - { - void SendTestFound(Test test); - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/ITestExecutionSink.cs b/src/Microsoft.Extensions.Testing.Abstractions/ITestExecutionSink.cs deleted file mode 100644 index a58b92e75..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/ITestExecutionSink.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Extensions.Testing.Abstractions -{ - public interface ITestExecutionSink : ITestSink - { - void SendTestStarted(Test test); - - void SendTestResult(TestResult testResult); - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/ITestSink.cs b/src/Microsoft.Extensions.Testing.Abstractions/ITestSink.cs deleted file mode 100644 index c72b327e4..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/ITestSink.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Extensions.Testing.Abstractions -{ - public interface ITestSink - { - void SendWaitingCommand(); - - void SendTestCompleted(); - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/LineDelimitedJsonStream.cs b/src/Microsoft.Extensions.Testing.Abstractions/LineDelimitedJsonStream.cs deleted file mode 100644 index 55d9d926c..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/LineDelimitedJsonStream.cs +++ /dev/null @@ -1,25 +0,0 @@ -// 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.IO; -using Newtonsoft.Json; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class LineDelimitedJsonStream - { - private readonly StreamWriter _stream; - - public LineDelimitedJsonStream(Stream stream) - { - _stream = new StreamWriter(stream); - } - - public void Send(object @object) - { - _stream.WriteLine(JsonConvert.SerializeObject(@object)); - - _stream.Flush(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Messages/ErrorMessage.cs b/src/Microsoft.Extensions.Testing.Abstractions/Messages/ErrorMessage.cs deleted file mode 100644 index 254889ef8..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Messages/ErrorMessage.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Tools.Test -{ - public class ErrorMessage - { - public string Message { get; set; } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Messages/Message.cs b/src/Microsoft.Extensions.Testing.Abstractions/Messages/Message.cs deleted file mode 100644 index 5a40f7470..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Messages/Message.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class Message - { - public string MessageType { get; set; } - - public JToken Payload { get; set; } - - public override string ToString() - { - return "(" + MessageType + ") -> " + (Payload == null ? "null" : Payload.ToString(Formatting.Indented)); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Messages/ProtocolVersionMessage.cs b/src/Microsoft.Extensions.Testing.Abstractions/Messages/ProtocolVersionMessage.cs deleted file mode 100644 index 3aa6e78fc..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Messages/ProtocolVersionMessage.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Tools.Test -{ - public class ProtocolVersionMessage - { - public int Version { get; set; } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Messages/RunTestsMessage.cs b/src/Microsoft.Extensions.Testing.Abstractions/Messages/RunTestsMessage.cs deleted file mode 100644 index 403cb033c..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Messages/RunTestsMessage.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Collections.Generic; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class RunTestsMessage - { - public List Tests { get; set; } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/MetadataExtensions.cs b/src/Microsoft.Extensions.Testing.Abstractions/MetadataExtensions.cs deleted file mode 100644 index 68da748e6..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/MetadataExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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.Reflection; -using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - internal static class MetadataExtensions - { - private static PropertyInfo s_methodInfoMethodTokenProperty = typeof(MethodInfo).GetProperty("MethodToken"); - - internal static int GetMethodToken(this MethodInfo methodInfo) - { - return (int)s_methodInfoMethodTokenProperty.GetValue(methodInfo); - } - - internal static MethodDebugInformationHandle GetMethodDebugInformationHandle(this MethodInfo methodInfo) - { - var methodToken = methodInfo.GetMethodToken(); - var handle = ((MethodDefinitionHandle)MetadataTokens.Handle(methodToken)).ToDebugInformationHandle(); - return handle; - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Microsoft.Extensions.Testing.Abstractions.xproj b/src/Microsoft.Extensions.Testing.Abstractions/Microsoft.Extensions.Testing.Abstractions.xproj deleted file mode 100644 index a364b40ec..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Microsoft.Extensions.Testing.Abstractions.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - dcdfe282-03de-4dbc-b90c-cc3ce3ec8162 - Microsoft.Extensions.Testing.Abstractions - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/MissingPdbReader.cs b/src/Microsoft.Extensions.Testing.Abstractions/MissingPdbReader.cs deleted file mode 100644 index c4b860670..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/MissingPdbReader.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Reflection; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - internal sealed class MissingPdbReader : IPdbReader - { - public static readonly MissingPdbReader Instance = new MissingPdbReader(); - - public SourceInformation GetSourceInformation(MethodInfo methodInfo) => null; - public void Dispose() { } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/PdbReaderFactory.cs b/src/Microsoft.Extensions.Testing.Abstractions/PdbReaderFactory.cs deleted file mode 100644 index 8c05227fe..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/PdbReaderFactory.cs +++ /dev/null @@ -1,105 +0,0 @@ -// 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.IO; -using System.Reflection.Metadata; -using System.Reflection.PortableExecutable; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class PdbReaderFactory : IPdbReaderFactory - { - /// - /// Creates for given file. - /// - /// - /// Path to the .pdb file or a PE file that refers to the .pdb file in its Debug Directory Table. - /// - /// File does not exist or can't be read. - /// is null. - public IPdbReader Create(string pdbPath) - { - if (pdbPath == null) - { - throw new ArgumentNullException(nameof(pdbPath)); - } - - Stream stream = OpenRead(pdbPath); - - if (IsPE(stream)) - { - return CreateFromPortableExecutable(stream, pdbPath); - } - - if (IsPortable(stream)) - { - return new PortablePdbReader(stream); - } - - return new FullPdbReader(stream); - } - - private static bool IsPortable(Stream stream) - { - bool result = stream.ReadByte() == 'B' && stream.ReadByte() == 'S' && stream.ReadByte() == 'J' && stream.ReadByte() == 'B'; - stream.Position = 0; - return result; - } - - private static bool IsPE(Stream stream) - { - bool result = stream.ReadByte() == 'M' && stream.ReadByte() == 'Z'; - stream.Position = 0; - return result; - } - - private IPdbReader CreateFromPortableExecutable(Stream peStream, string pePath) - { - using (var peReader = new PEReader(peStream)) - { - MetadataReaderProvider pdbProvider; - string pdbPath; - if (peReader.TryOpenAssociatedPortablePdb(pePath, TryOpenRead, out pdbProvider, out pdbPath)) - { - return new PortablePdbReader(pdbProvider); - } - - return MissingPdbReader.Instance; - } - } - - private static Stream OpenRead(string path) - { - try - { - return File.OpenRead(path); - } - catch (Exception e) when (!(e is IOException)) - { - throw new IOException(e.Message, e); - } - } - - private static Stream TryOpenRead(string path) - { - if (!File.Exists(path)) - { - return null; - } - - try - { - return File.OpenRead(path); - } - catch (FileNotFoundException) - { - return null; - } - catch (Exception e) when (!(e is IOException)) - { - throw new IOException(e.Message, e); - } - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/PortablePdbReader.cs b/src/Microsoft.Extensions.Testing.Abstractions/PortablePdbReader.cs deleted file mode 100644 index 7b6d11220..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/PortablePdbReader.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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.IO; -using System.Linq; -using System.Reflection; -using System.Reflection.Metadata; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class PortablePdbReader : IPdbReader - { - private MetadataReader _reader; - private MetadataReaderProvider _provider; - - public PortablePdbReader(Stream stream) - : this(MetadataReaderProvider.FromPortablePdbStream(stream)) - { - } - - internal PortablePdbReader(MetadataReaderProvider provider) - { - _provider = provider; - _reader = provider.GetMetadataReader(); - } - - public SourceInformation GetSourceInformation(MethodInfo methodInfo) - { - if (methodInfo == null) - { - return null; - } - - var handle = methodInfo.GetMethodDebugInformationHandle(); - - return GetSourceInformation(handle); - } - - private SourceInformation GetSourceInformation(MethodDebugInformationHandle handle) - { - if (_reader == null) - { - throw new ObjectDisposedException(nameof(PortablePdbReader)); - } - - SourceInformation sourceInformation = null; - try - { - var methodDebugDefinition = _reader.GetMethodDebugInformation(handle); - var fileName = GetMethodFileName(methodDebugDefinition); - var lineNumber = GetMethodStartLineNumber(methodDebugDefinition); - - sourceInformation = new SourceInformation(fileName, lineNumber); - } - catch (BadImageFormatException) - { - } - - return sourceInformation; - } - - private static int GetMethodStartLineNumber(MethodDebugInformation methodDebugDefinition) - { - var sequencePoint = - methodDebugDefinition.GetSequencePoints().OrderBy(s => s.StartLine).FirstOrDefault(); - var lineNumber = sequencePoint.StartLine; - return lineNumber; - } - - private string GetMethodFileName(MethodDebugInformation methodDebugDefinition) - { - var fileName = string.Empty; - if (!methodDebugDefinition.Document.IsNil) - { - var document = _reader.GetDocument(methodDebugDefinition.Document); - fileName = _reader.GetString(document.Name); - } - - return fileName; - } - - public void Dispose() - { - _provider?.Dispose(); - _provider = null; - _reader = null; - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Properties/AssemblyInfo.cs b/src/Microsoft.Extensions.Testing.Abstractions/Properties/AssemblyInfo.cs deleted file mode 100644 index 722c59c6b..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -// 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.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] diff --git a/src/Microsoft.Extensions.Testing.Abstractions/SourceInformation.cs b/src/Microsoft.Extensions.Testing.Abstractions/SourceInformation.cs deleted file mode 100644 index 3245b291e..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/SourceInformation.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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.Extensions.Testing.Abstractions -{ - public class SourceInformation - { - public SourceInformation(string filename, int lineNumber) - { - Filename = filename; - LineNumber = lineNumber; - } - - public string Filename { get; } - - public int LineNumber { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/SourceInformationProvider.cs b/src/Microsoft.Extensions.Testing.Abstractions/SourceInformationProvider.cs deleted file mode 100644 index eadfaa743..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/SourceInformationProvider.cs +++ /dev/null @@ -1,104 +0,0 @@ -// 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.IO; -using System.Reflection; -using System.Runtime.CompilerServices; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class SourceInformationProvider : ISourceInformationProvider - { - private readonly string _filePath; - private readonly IPdbReader _pdbReader; - - /// - /// Creates a source info provide from a specified file path. - /// - /// - /// Path to the .pdb file or a PE file that refers to the .pdb file in its Debug Directory Table. - /// - public SourceInformationProvider(string pdbPath) : - this(pdbPath, new PdbReaderFactory()) - { - } - - /// - /// Creates a source info provide from a specified file path. - /// - /// - /// Path to the .pdb file or a PE file that refers to the .pdb file in its Debug Directory Table. - /// - /// - /// Factory that creates instance used to read the PDB. - /// - /// File does not exist or can't be read. - /// or is null. - public SourceInformationProvider(string pdbPath, IPdbReaderFactory pdbReaderFactory) - { - if (pdbPath == null) - { - throw new ArgumentNullException(nameof(pdbPath)); - } - - if (pdbReaderFactory == null) - { - throw new ArgumentNullException(nameof(pdbReaderFactory)); - } - - _filePath = pdbPath; - _pdbReader = pdbReaderFactory.Create(pdbPath); - } - - public SourceInformation GetSourceInformation(MethodInfo method) - { - if (method == null) - { - throw new ArgumentNullException(nameof(method)); - } - - // We need a MethodInfo so we can deal with cases where no user code shows up for provided - // method and class name. In particular: - // - // 1) inherited test methods (method.DeclaringType) - // 2) async test methods (see StateMachineAttribute).t. - // - // Note that this doesn't deal gracefully with overloaded methods. Symbol APIs don't provide - // a way to match overloads. We'd really need MetadataTokens to do this correctly (missing in - // CoreCLR). - method = ResolveBestMethodInfo(method); - - try - { - return _pdbReader.GetSourceInformation(method); - } - catch (Exception ex) - { - Console.WriteLine("Failed to access source information in symbol.", ex); - return null; - } - } - - private MethodInfo ResolveBestMethodInfo(MethodInfo method) - { - // If a method has a StateMachineAttribute, then all of the user code will show up - // in the symbols associated with the compiler-generated code. So, we need to look - // for the 'MoveNext' on the generated type and resolve symbols for that. - var attribute = method.GetCustomAttribute(); - if (attribute?.StateMachineType == null) - { - return method; - } - - return attribute.StateMachineType.GetMethod( - "MoveNext", - BindingFlags.Instance | BindingFlags.NonPublic); - } - - public void Dispose() - { - _pdbReader.Dispose(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestDiscoverySink.cs b/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestDiscoverySink.cs deleted file mode 100644 index 5e49f67f2..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestDiscoverySink.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.IO; -using Newtonsoft.Json.Linq; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class StreamingTestDiscoverySink : StreamingTestSink, ITestDiscoverySink - { - public StreamingTestDiscoverySink(Stream stream) : base(stream) - { - } - - public void SendTestFound(Test test) - { - if (test == null) - { - throw new ArgumentNullException(nameof(test)); - } - - Stream.Send(new Message - { - MessageType = "TestDiscovery.TestFound", - Payload = JToken.FromObject(test), - }); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestExecutionSink.cs b/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestExecutionSink.cs deleted file mode 100644 index 74a9b679f..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestExecutionSink.cs +++ /dev/null @@ -1,72 +0,0 @@ -// 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.Concurrent; -using System.IO; -using Newtonsoft.Json.Linq; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class StreamingTestExecutionSink : StreamingTestSink, ITestExecutionSink - { - private readonly ConcurrentDictionary _runningTests; - - public StreamingTestExecutionSink(Stream stream) : base(stream) - { - _runningTests = new ConcurrentDictionary(); - } - - public void SendTestStarted(Test test) - { - if (test == null) - { - throw new ArgumentNullException(nameof(test)); - } - - if (test.FullyQualifiedName != null) - { - var state = new TestState() { StartTime = DateTimeOffset.Now, }; - _runningTests.TryAdd(test.FullyQualifiedName, state); - } - - Stream.Send(new Message - { - MessageType = "TestExecution.TestStarted", - Payload = JToken.FromObject(test), - }); - } - - public void SendTestResult(TestResult testResult) - { - if (testResult == null) - { - throw new ArgumentNullException(nameof(testResult)); - } - - if (testResult.StartTime == default(DateTimeOffset) && testResult.Test.FullyQualifiedName != null) - { - TestState state; - _runningTests.TryRemove(testResult.Test.FullyQualifiedName, out state); - - testResult.StartTime = state.StartTime; - } - - if (testResult.EndTime == default(DateTimeOffset)) - { - testResult.EndTime = DateTimeOffset.Now; - } - - Stream.Send(new Message - { - MessageType = "TestExecution.TestResult", - Payload = JToken.FromObject(testResult), - }); - } - - private class TestState - { - public DateTimeOffset StartTime { get; set; } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestSink.cs b/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestSink.cs deleted file mode 100644 index e5f2a9752..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/StreamingTestSink.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.IO; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public abstract class StreamingTestSink : ITestSink - { - protected LineDelimitedJsonStream Stream { get; } - - protected StreamingTestSink(Stream stream) - { - Stream = new LineDelimitedJsonStream(stream); - } - - public void SendTestCompleted() - { - Stream.Send(new Message - { - MessageType = "TestRunner.TestCompleted" - }); - } - - public void SendWaitingCommand() - { - Stream.Send(new Message - { - MessageType = "TestRunner.WaitingCommand" - }); - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/SymUnmanagedReaderExtensions.cs b/src/Microsoft.Extensions.Testing.Abstractions/SymUnmanagedReaderExtensions.cs deleted file mode 100644 index ade63a7c6..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/SymUnmanagedReaderExtensions.cs +++ /dev/null @@ -1,116 +0,0 @@ -// 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.Immutable; -using System.Runtime.InteropServices; -using Microsoft.DiaSymReader; -using System.Linq; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - internal static class SymUnmanagedReaderExtensions - { - internal const int E_FAIL = unchecked((int)0x80004005); - internal const int E_NOTIMPL = unchecked((int)0x80004001); - - private static readonly IntPtr s_ignoreIErrorInfo = new IntPtr(-1); - private delegate int ItemsGetter(TEntity entity, int bufferLength, out int count, TItem[] buffer); - - internal static void ThrowExceptionForHR(int hr) - { - // E_FAIL indicates "no info". - // E_NOTIMPL indicates a lack of ISymUnmanagedReader support (in a particular implementation). - if (hr < 0 && hr != E_FAIL && hr != E_NOTIMPL) - { - Marshal.ThrowExceptionForHR(hr, s_ignoreIErrorInfo); - } - } - - internal static SourceInformation GetSourceInformation(this ISymUnmanagedMethod method) - { - var sequencePoint = method.GetSequencePoints().OrderBy(s => s.StartLine).FirstOrDefault(); - var fileName = sequencePoint.Document.GetName(); - var lineNumber = sequencePoint.StartLine; - - return new SourceInformation(fileName, lineNumber); - } - - internal static ImmutableArray GetSequencePoints(this ISymUnmanagedMethod method) - { - // NB: method.GetSequencePoints(0, out numAvailable, ...) always returns 0. - int numAvailable; - int hr = method.GetSequencePointCount(out numAvailable); - SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr); - if (numAvailable == 0) - { - return ImmutableArray.Empty; - } - - int[] offsets = new int[numAvailable]; - ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[numAvailable]; - int[] startLines = new int[numAvailable]; - int[] startColumns = new int[numAvailable]; - int[] endLines = new int[numAvailable]; - int[] endColumns = new int[numAvailable]; - - int numRead; - hr = method.GetSequencePoints(numAvailable, out numRead, offsets, documents, startLines, startColumns, endLines, endColumns); - SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr); - if (numRead != numAvailable) - { - throw new InvalidOperationException($"Read only {numRead} of {numAvailable} sequence points."); - } - - var builder = ImmutableArray.CreateBuilder(numRead); - for (int i = 0; i < numRead; i++) - { - builder.Add(new SymUnmanagedSequencePoint( - offsets[i], - documents[i], - startLines[i], - startColumns[i], - endLines[i], - endColumns[i])); - } - - return builder.ToImmutable(); - } - - internal static string GetName(this ISymUnmanagedDocument document) - { - return ToString(GetItems(document, - (ISymUnmanagedDocument a, int b, out int c, char[] d) => a.GetUrl(b, out c, d))); - } - - private static TItem[] GetItems(TEntity entity, ItemsGetter getter) - { - int count; - int hr = getter(entity, 0, out count, null); - ThrowExceptionForHR(hr); - if (count == 0) - { - return null; - } - - var result = new TItem[count]; - hr = getter(entity, count, out count, result); - ThrowExceptionForHR(hr); - ValidateItems(count, result.Length); - return result; - } - - private static void ValidateItems(int actualCount, int bufferLength) - { - if (actualCount != bufferLength) - { - throw new InvalidOperationException(string.Format("Read only {0} of {1} items.", actualCount, bufferLength)); - } - } - - private static string ToString(char[] buffer) - { - return new string(buffer, 0, buffer.Length - 1); - } - } -} diff --git a/src/Microsoft.Extensions.Testing.Abstractions/Test.cs b/src/Microsoft.Extensions.Testing.Abstractions/Test.cs deleted file mode 100644 index 06622eda5..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/Test.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public class Test - { - public Test() - { - Properties = new Dictionary(StringComparer.Ordinal); - } - - public string CodeFilePath { get; set; } - - public string DisplayName { get; set; } - - public string FullyQualifiedName { get; set; } - - public Guid? Id { get; set; } - - public int? LineNumber { get; set; } - - public IDictionary Properties { get; private set; } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/TestHostServices.cs b/src/Microsoft.Extensions.Testing.Abstractions/TestHostServices.cs deleted file mode 100644 index 32a4ad841..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/TestHostServices.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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.Extensions.Testing.Abstractions -{ - public abstract class TestHostServices - { - public abstract ITestDiscoverySink TestDiscoverySink { get; } - - public abstract ITestExecutionSink TestExecutionSink { get; } - - public abstract ISourceInformationProvider SourceInformationProvider { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/TestOutcome.cs b/src/Microsoft.Extensions.Testing.Abstractions/TestOutcome.cs deleted file mode 100644 index a3124a1d6..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/TestOutcome.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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.Extensions.Testing.Abstractions -{ - public enum TestOutcome - { - None, - Passed, - Failed, - Skipped, - NotFound - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/TestResult.cs b/src/Microsoft.Extensions.Testing.Abstractions/TestResult.cs deleted file mode 100644 index c91cdeeb0..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/TestResult.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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.ObjectModel; - -namespace Microsoft.Extensions.Testing.Abstractions -{ - public sealed class TestResult - { - public TestResult(Test test) - { - if (test == null) - { - throw new ArgumentNullException(nameof(test)); - } - - Test = test; - Messages = new Collection(); - } - - public Test Test { get; private set; } - - public TestOutcome Outcome { get; set; } - - public string ErrorMessage { get; set; } - - public string ErrorStackTrace { get; set; } - - public string DisplayName { get; set; } - - public Collection Messages { get; private set; } - - public string ComputerName { get; set; } - - public TimeSpan Duration { get; set; } - - public DateTimeOffset StartTime { get; set; } - - public DateTimeOffset EndTime { get; set; } - } -} \ No newline at end of file diff --git a/src/Microsoft.Extensions.Testing.Abstractions/project.json b/src/Microsoft.Extensions.Testing.Abstractions/project.json deleted file mode 100644 index 63c42f277..000000000 --- a/src/Microsoft.Extensions.Testing.Abstractions/project.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "description": "Abstractions for test runners to communicate to a tool, such as Visual Studio.", - "version": "1.0.1-featmsbuild-*", - "buildOptions": { - "warningsAsErrors": true, - "allowUnsafe": true, - "keyFile": "../../tools/Key.snk" - }, - "dependencies": { - "Newtonsoft.Json": "9.0.1", - "Microsoft.DotNet.ProjectModel": { - "target": "project" - }, - "Microsoft.DiaSymReader": "1.0.8", - "Microsoft.DiaSymReader.Native": "1.4.0-rc2", - "System.Reflection.Metadata": "1.4.1-beta-24426-02" - }, - "frameworks": { - "netstandard1.3": { - "imports": [ - "portable-net45+wp80+win8+wpa81+dnxcore50", - "portable-net45+win8" - ], - "dependencies": { - "System.Resources.ResourceManager": "4.0.1", - "System.Reflection.TypeExtensions": "4.1.0" - } - } - }, - "scripts": {}, - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/dotnet/cli" - } - } -} diff --git a/src/dotnet/ForwardingApp.cs b/src/dotnet/ForwardingApp.cs index 871f98b21..607c0f43a 100644 --- a/src/dotnet/ForwardingApp.cs +++ b/src/dotnet/ForwardingApp.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; namespace Microsoft.DotNet.Cli { diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index 9117e2fd0..436dbff63 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -9,26 +9,20 @@ using System.Text; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Configurer; using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.DotNet.ProjectModel.Server; using Microsoft.DotNet.Tools.Build; -using Microsoft.DotNet.Tools.Build3; -using Microsoft.DotNet.Tools.Clean3; -using Microsoft.DotNet.Tools.Compiler; -using Microsoft.DotNet.Tools.Compiler.Csc; +using Microsoft.DotNet.Tools.Clean; using Microsoft.DotNet.Tools.Help; using Microsoft.DotNet.Tools.Migrate; using Microsoft.DotNet.Tools.MSBuild; using Microsoft.DotNet.Tools.New; using Microsoft.DotNet.Tools.NuGet; -using Microsoft.DotNet.Tools.Pack3; +using Microsoft.DotNet.Tools.Pack; using Microsoft.DotNet.Tools.Publish; -using Microsoft.DotNet.Tools.Publish3; using Microsoft.DotNet.Tools.Restore; -using Microsoft.DotNet.Tools.Restore3; +using Microsoft.DotNet.Tools.RestoreProjectJson; using Microsoft.DotNet.Tools.Run; using Microsoft.DotNet.Tools.Test; using Microsoft.DotNet.Tools.VSTest; -using Microsoft.DotNet.Tools.Test3; using NuGet.Frameworks; namespace Microsoft.DotNet.Cli @@ -38,26 +32,19 @@ namespace Microsoft.DotNet.Cli private static Dictionary> s_builtIns = new Dictionary> { ["build"] = BuildCommand.Run, - ["compile-csc"] = CompileCscCommand.Run, + ["clean"] = CleanCommand.Run, ["help"] = HelpCommand.Run, + ["migrate"] = MigrateCommand.Run, + ["msbuild"] = MSBuildCommand.Run, ["new"] = NewCommand.Run, ["nuget"] = NuGetCommand.Run, ["pack"] = PackCommand.Run, ["publish"] = PublishCommand.Run, ["restore"] = RestoreCommand.Run, + ["restore-projectjson"] = RestoreProjectJsonCommand.Run, ["run"] = RunCommand.Run, ["test"] = TestCommand.Run, - ["build3"] = Build3Command.Run, - ["clean3"] = Clean3Command.Run, - ["msbuild"] = MSBuildCommand.Run, - ["run3"] = Run3Command.Run, - ["restore3"] = Restore3Command.Run, - ["publish3"] = Publish3Command.Run, ["vstest"] = VSTestCommand.Run, - ["test3"] = Test3Command.Run, - ["pack3"] = Pack3Command.Run, - ["migrate"] = MigrateCommand.Run, - ["projectmodel-server"] = ProjectModelServerCommand.Run, }; public static int Main(string[] args) diff --git a/src/dotnet/ProjectGlobbingResolver.cs b/src/dotnet/ProjectGlobbingResolver.cs index 66f10db67..2a3054489 100644 --- a/src/dotnet/ProjectGlobbingResolver.cs +++ b/src/dotnet/ProjectGlobbingResolver.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; +using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing; +using Microsoft.DotNet.Internal.ProjectModel.FileSystemGlobbing.Abstractions; namespace Microsoft.DotNet.Tools.Compiler { diff --git a/src/dotnet/commands/dotnet-build/BuildCommandApp.cs b/src/dotnet/commands/dotnet-build/BuildCommandApp.cs deleted file mode 100644 index b05156d3f..000000000 --- a/src/dotnet/commands/dotnet-build/BuildCommandApp.cs +++ /dev/null @@ -1,143 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.InternalAbstractions; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Common; -using NuGet.Frameworks; - -// This class is responsible with defining the arguments for the Compile verb. -// It knows how to interpret them and set default values -namespace Microsoft.DotNet.Tools.Compiler -{ - public delegate bool OnExecute(IEnumerable files, IEnumerable frameworks, BuildCommandApp buildCommand); - - public class BuildCommandApp - { - public static readonly string NoIncrementalFlag = "--no-incremental"; - public static readonly string BuildProfileFlag = "--build-profile"; - - private readonly CommandLineApplication _app; - - // options and arguments for compilation - private CommandOption _outputOption; - private CommandOption _buildBasePath; - private CommandOption _frameworkOption; - private CommandOption _runtimeOption; - private CommandOption _versionSuffixOption; - private CommandOption _configurationOption; - private CommandArgument _projectArgument; - - private CommandOption _shouldPrintIncrementalPreconditionsArgument; - private CommandOption _shouldNotUseIncrementalityArgument; - private CommandOption _shouldSkipDependenciesArgument; - - - public string BuildBasePathValue { get; set; } - public string RuntimeValue { get; set; } - public string OutputValue { get; set; } - public string VersionSuffixValue { get; set; } - public string ConfigValue { get; set; } - public bool IsNativeValue { get; set; } - public bool ShouldPrintIncrementalPreconditions { get; set; } - public bool ShouldNotUseIncrementality { get; set; } - public bool ShouldSkipDependencies { get; set; } - - public BuildWorkspace Workspace { get; private set; } - - // workaround: CommandLineApplication is internal therefore I cannot make _app protected so baseclasses can add their own params - private readonly Dictionary baseClassOptions; - - public BuildCommandApp(string name, string fullName, string description) : this(name, fullName, description, workspace: null) { } - - public BuildCommandApp(string name, string fullName, string description, BuildWorkspace workspace) - { - Workspace = workspace; - _app = new CommandLineApplication - { - Name = name, - FullName = fullName, - Description = description - }; - - baseClassOptions = new Dictionary(); - - AddCompileParameters(); - } - - private void AddCompileParameters() - { - _app.HelpOption("-h|--help"); - - _outputOption = _app.Option("-o|--output ", "Directory in which to place outputs", CommandOptionType.SingleValue); - _buildBasePath = _app.Option("-b|--build-base-path ", "Directory in which to place temporary outputs", CommandOptionType.SingleValue); - _frameworkOption = _app.Option("-f|--framework ", "Compile a specific framework", CommandOptionType.SingleValue); - _runtimeOption = _app.Option("-r|--runtime ", "Produce runtime-specific assets for the specified runtime", CommandOptionType.SingleValue); - _configurationOption = _app.Option("-c|--configuration ", "Configuration under which to build", CommandOptionType.SingleValue); - _versionSuffixOption = _app.Option("--version-suffix ", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue); - _projectArgument = _app.Argument("", "The project to compile, defaults to the current directory. " + - "Can be one or multiple paths to project.json, project directory " + - "or globbing pattern that matches project.json files", multipleValues: true); - - _shouldPrintIncrementalPreconditionsArgument = _app.Option(BuildProfileFlag, "Set this flag to print the incremental safety checks that prevent incremental compilation", CommandOptionType.NoValue); - _shouldNotUseIncrementalityArgument = _app.Option(NoIncrementalFlag, "Set this flag to turn off incremental build", CommandOptionType.NoValue); - _shouldSkipDependenciesArgument = _app.Option("--no-dependencies", "Set this flag to ignore project to project references and only build the root project", CommandOptionType.NoValue); - } - - public int Execute(OnExecute execute, string[] args) - { - _app.OnExecute(() => - { - if (_outputOption.HasValue() && !_frameworkOption.HasValue()) - { - Reporter.Error.WriteLine("When the '--output' option is provided, the '--framework' option must also be provided."); - return 1; - } - - OutputValue = _outputOption.Value(); - BuildBasePathValue = PathUtility.GetFullPath(_buildBasePath.Value()); - ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration; - RuntimeValue = _runtimeOption.Value(); - VersionSuffixValue = _versionSuffixOption.Value(); - ShouldPrintIncrementalPreconditions = _shouldPrintIncrementalPreconditionsArgument.HasValue(); - ShouldNotUseIncrementality = _shouldNotUseIncrementalityArgument.HasValue(); - ShouldSkipDependencies = _shouldSkipDependenciesArgument.HasValue(); - - // Set defaults based on the environment - if (Workspace == null) - { - Workspace = BuildWorkspace.Create(VersionSuffixValue); - } - - var files = new ProjectGlobbingResolver().Resolve(_projectArgument.Values); - IEnumerable frameworks = null; - if (_frameworkOption.HasValue()) - { - frameworks = new[] { NuGetFramework.Parse(_frameworkOption.Value()) }; - } - var success = execute(files, frameworks, this); - - return success ? 0 : 1; - }); - - return _app.Execute(args); - } - - public IEnumerable GetRuntimes() - { - var rids = new List(); - if (string.IsNullOrEmpty(RuntimeValue)) - { - return DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject); - } - else - { - return new[] { RuntimeValue }; - } - } - } -} diff --git a/src/dotnet/commands/dotnet-build/CompilationResult.cs b/src/dotnet/commands/dotnet-build/CompilationResult.cs deleted file mode 100644 index c6f6f78e6..000000000 --- a/src/dotnet/commands/dotnet-build/CompilationResult.cs +++ /dev/null @@ -1,10 +0,0 @@ -// 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.Tools.Build -{ - internal enum CompilationResult - { - IncrementalSkip, Success, Failure - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/CompilerIO.cs b/src/dotnet/commands/dotnet-build/CompilerIO.cs deleted file mode 100644 index 87db75356..000000000 --- a/src/dotnet/commands/dotnet-build/CompilerIO.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class CompilerIO - { - public readonly IEnumerable Inputs; - public readonly IEnumerable Outputs; - - public CompilerIO(IEnumerable inputs, IEnumerable outputs) - { - Inputs = inputs; - Outputs = outputs; - } - - public DiffResult DiffInputs(CompilerIO other) - { - var myInputSet = new HashSet(Inputs); - var otherInputSet = new HashSet(other.Inputs); - - var additions = myInputSet.Except(otherInputSet); - var deletions = otherInputSet.Except(myInputSet); - - return new DiffResult(additions, deletions); - } - - internal class DiffResult - { - public IEnumerable Additions { get; private set; } - public IEnumerable Deletions { get; private set; } - - public DiffResult(IEnumerable additions, IEnumerable deletions) - { - Additions = additions; - Deletions = deletions; - } - } - - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/CompilerIOManager.cs b/src/dotnet/commands/dotnet-build/CompilerIOManager.cs deleted file mode 100644 index 77e35002b..000000000 --- a/src/dotnet/commands/dotnet-build/CompilerIOManager.cs +++ /dev/null @@ -1,183 +0,0 @@ -// 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.Concurrent; -using System.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Compiler; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class CompilerIOManager - { - private readonly string _configuration; - private readonly string _outputPath; - private readonly string _buildBasePath; - private readonly IList _runtimes; - private readonly BuildWorkspace _workspace; - private readonly ConcurrentDictionary _cache; - - public CompilerIOManager(string configuration, - string outputPath, - string buildBasePath, - IEnumerable runtimes, - BuildWorkspace workspace) - { - _configuration = configuration; - _outputPath = outputPath; - _buildBasePath = buildBasePath; - _runtimes = runtimes.ToList(); - _workspace = workspace; - - _cache = new ConcurrentDictionary(); - } - - - // computes all the inputs and outputs that would be used in the compilation of a project - public CompilerIO GetCompileIO(ProjectGraphNode graphNode) - { - return _cache.GetOrAdd(graphNode.ProjectContext.Identity, i => ComputeIO(graphNode)); - } - - private CompilerIO ComputeIO(ProjectGraphNode graphNode) - { - var inputs = new List(); - var outputs = new List(); - - var isRootProject = graphNode.IsRoot; - var project = graphNode.ProjectContext; - - var calculator = project.GetOutputPaths(_configuration, _buildBasePath, _outputPath); - var binariesOutputPath = calculator.CompilationOutputPath; - var compilerOptions = project.ProjectFile.GetCompilerOptions(project.TargetFramework, _configuration); - - // input: project.json - inputs.Add(project.ProjectFile.ProjectFilePath); - - // input: lock file; find when dependencies change - AddLockFile(project, inputs); - - // input: source files - inputs.AddRange(CompilerUtil.GetCompilationSources(project, compilerOptions)); - - var allOutputPath = new HashSet(calculator.CompilationFiles.All()); - if (isRootProject && project.ProjectFile.HasRuntimeOutput(_configuration)) - { - var runtimeContext = _workspace.GetRuntimeContext(project, _runtimes); - foreach (var path in runtimeContext.GetOutputPaths(_configuration, _buildBasePath, _outputPath).RuntimeFiles.All()) - { - allOutputPath.Add(path); - } - } - foreach (var dependency in graphNode.Dependencies) - { - var outputFiles = dependency.ProjectContext - .GetOutputPaths(_configuration, _buildBasePath, _outputPath) - .CompilationFiles; - - inputs.Add(outputFiles.Assembly); - } - - // output: compiler outputs - foreach (var path in allOutputPath) - { - outputs.Add(path); - } - - // input compilation options files - AddCompilationOptions(project, _configuration, inputs); - - // input / output: resources with culture - AddNonCultureResources(project, calculator.IntermediateOutputDirectoryPath, inputs, outputs, compilerOptions); - - // input / output: resources without culture - AddCultureResources(project, binariesOutputPath, inputs, outputs, compilerOptions); - - return new CompilerIO(inputs, outputs); - } - - private static void AddLockFile(ProjectContext project, List inputs) - { - if (project.LockFile == null) - { - var errorMessage = $"Project {project.ProjectName()} does not have a lock file. Please run \"dotnet restore\" to generate a new lock file."; - Reporter.Error.WriteLine(errorMessage); - throw new InvalidOperationException(errorMessage); - } - - inputs.Add(project.LockFile.Path); - } - - - private static void AddCompilationOptions(ProjectContext project, string config, List inputs) - { - var compilerOptions = project.ResolveCompilationOptions(config); - - // input: key file - if (compilerOptions.KeyFile != null) - { - inputs.Add(compilerOptions.KeyFile); - } - } - - private static void AddNonCultureResources( - ProjectContext project, - string intermediaryOutputPath, - List inputs, - IList outputs, - CommonCompilerOptions compilationOptions) - { - List resources = null; - if (compilationOptions.EmbedInclude == null) - { - resources = CompilerUtil.GetNonCultureResources(project.ProjectFile, intermediaryOutputPath); - } - else - { - resources = CompilerUtil.GetNonCultureResourcesFromIncludeEntries(project.ProjectFile, intermediaryOutputPath, compilationOptions); - } - - foreach (var resourceIO in resources) - { - inputs.Add(resourceIO.InputFile); - - if (resourceIO.OutputFile != null) - { - outputs.Add(resourceIO.OutputFile); - } - } - } - - private static void AddCultureResources( - ProjectContext project, - string outputPath, - List inputs, - List outputs, - CommonCompilerOptions compilationOptions) - { - List resources = null; - if (compilationOptions.EmbedInclude == null) - { - resources = CompilerUtil.GetCultureResources(project.ProjectFile, outputPath); - } - else - { - resources = CompilerUtil.GetCultureResourcesFromIncludeEntries(project.ProjectFile, outputPath, compilationOptions); - } - - foreach (var cultureResourceIO in resources) - { - inputs.AddRange(cultureResourceIO.InputFileToMetadata.Keys); - - if (cultureResourceIO.OutputFile != null) - { - outputs.Add(cultureResourceIO.OutputFile); - } - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs b/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs deleted file mode 100644 index 0b1937321..000000000 --- a/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs +++ /dev/null @@ -1,218 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Compiler; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class DotNetProjectBuilder : ProjectBuilder - { - private readonly BuildCommandApp _args; - private readonly IncrementalPreconditionManager _preconditionManager; - private readonly CompilerIOManager _compilerIOManager; - private readonly ScriptRunner _scriptRunner; - private readonly DotNetCommandFactory _commandFactory; - private readonly IncrementalManager _incrementalManager; - - public DotNetProjectBuilder(BuildCommandApp args) : base(args.ShouldSkipDependencies) - { - _args = args; - - _preconditionManager = new IncrementalPreconditionManager( - args.ShouldPrintIncrementalPreconditions, - args.ShouldNotUseIncrementality, - args.ShouldSkipDependencies); - - _compilerIOManager = new CompilerIOManager( - args.ConfigValue, - args.OutputValue, - args.BuildBasePathValue, - args.GetRuntimes(), - args.Workspace - ); - - _incrementalManager = new IncrementalManager( - this, - _compilerIOManager, - _preconditionManager, - _args.ShouldSkipDependencies, - _args.ConfigValue, - _args.BuildBasePathValue, - _args.OutputValue, - BuildIncrementalArgumentList(_args) - ); - - _scriptRunner = new ScriptRunner(); - - _commandFactory = new DotNetCommandFactory(); - } - - private static IDictionary BuildIncrementalArgumentList(BuildCommandApp args) => new Dictionary() - { - ["version-suffix"] = args.VersionSuffixValue - }; - - private void StampProjectWithSDKVersion(ProjectContext project) - { - if (File.Exists(DotnetFiles.VersionFile)) - { - var projectVersionFile = project.GetSDKVersionFile(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue); - var parentDirectory = Path.GetDirectoryName(projectVersionFile); - - if (!Directory.Exists(parentDirectory)) - { - Directory.CreateDirectory(parentDirectory); - } - - string content = DotnetFiles.ReadAndInterpretVersionFile(); - - File.WriteAllText(projectVersionFile, content); - } - else - { - Reporter.Verbose.WriteLine($"Project {project.GetDisplayName()} was not stamped with a CLI version because the version file does not exist: {DotnetFiles.VersionFile}"); - } - } - - private void PrintSummary(ProjectGraphNode projectNode, bool success) - { - // todo: Ideally it's the builder's responsibility for adding the time elapsed. That way we avoid cross cutting display concerns between compile and build for printing time elapsed - if (success) - { - var preconditions = _preconditionManager.GetIncrementalPreconditions(projectNode); - Reporter.Output.Write(" " + preconditions.LogMessage()); - Reporter.Output.WriteLine(); - } - - Reporter.Output.WriteLine(); - } - - - private void CopyCompilationOutput(OutputPaths outputPaths) - { - var dest = outputPaths.RuntimeOutputPath; - var source = outputPaths.CompilationOutputPath; - - // No need to copy if dest and source are the same - if (string.Equals(dest, source, StringComparison.OrdinalIgnoreCase)) - { - return; - } - - foreach (var file in outputPaths.CompilationFiles.All()) - { - var destFileName = file.Replace(source, dest); - var directoryName = Path.GetDirectoryName(destFileName); - if (!Directory.Exists(directoryName)) - { - Directory.CreateDirectory(directoryName); - } - File.Copy(file, destFileName, true); - } - } - - private void MakeRunnable(ProjectGraphNode graphNode) - { - try - { - var runtimeContext = graphNode.ProjectContext.ProjectFile.HasRuntimeOutput(_args.ConfigValue) ? - _args.Workspace.GetRuntimeContext(graphNode.ProjectContext, _args.GetRuntimes()) : - graphNode.ProjectContext; - - var outputPaths = runtimeContext.GetOutputPaths(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue); - var libraryExporter = runtimeContext.CreateExporter(_args.ConfigValue, _args.BuildBasePathValue); - - CopyCompilationOutput(outputPaths); - - var executable = new Executable(runtimeContext, outputPaths, libraryExporter, _args.ConfigValue); - executable.MakeCompilationOutputRunnable(); - } - catch (Exception e) - { - throw new Exception($"Failed to make the following project runnable: {graphNode.ProjectContext.GetDisplayName()} reason: {e.Message}", e); - } - } - - protected override CompilationResult Build(ProjectGraphNode projectNode) - { - var result = base.Build(projectNode); - AfterRootBuild(projectNode, result); - return result; - } - - protected void AfterRootBuild(ProjectGraphNode projectNode, CompilationResult result) - { - if (result != CompilationResult.IncrementalSkip && projectNode.IsRoot) - { - var success = result == CompilationResult.Success; - if (success) - { - MakeRunnable(projectNode); - } - PrintSummary(projectNode, success); - } - } - - protected override CompilationResult RunCompile(ProjectGraphNode projectNode) - { - try - { - var managedCompiler = new ManagedCompiler(_scriptRunner, _commandFactory); - - var success = managedCompiler.Compile(projectNode.ProjectContext, _args); - return success ? CompilationResult.Success : CompilationResult.Failure; - } - finally - { - StampProjectWithSDKVersion(projectNode.ProjectContext); - _incrementalManager.CacheIncrementalState(projectNode); - } - } - - protected override void ProjectSkiped(ProjectGraphNode projectNode) - { - StampProjectWithSDKVersion(projectNode.ProjectContext); - _incrementalManager.CacheIncrementalState(projectNode); - } - - protected override bool NeedsRebuilding(ProjectGraphNode graphNode) - { - var result = _incrementalManager.NeedsRebuilding(graphNode); - - PrintIncrementalResult(graphNode.ProjectContext.GetDisplayName(), result); - - return result.NeedsRebuilding; - } - - private void PrintIncrementalResult(string projectName, IncrementalResult result) - { - if (result.NeedsRebuilding) - { - Reporter.Output.WriteLine($"Project {projectName} will be compiled because {result.Reason}"); - PrintIncrementalItems(result); - } - else - { - Reporter.Output.WriteLine($"Project {projectName} was previously compiled. Skipping compilation."); - } - } - - private static void PrintIncrementalItems(IncrementalResult result) - { - if (Reporter.IsVerbose) - { - foreach (var item in result.Items) - { - Reporter.Verbose.WriteLine($"\t{item}"); - } - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/IncrementalCache.cs b/src/dotnet/commands/dotnet-build/IncrementalCache.cs deleted file mode 100644 index 13335af17..000000000 --- a/src/dotnet/commands/dotnet-build/IncrementalCache.cs +++ /dev/null @@ -1,114 +0,0 @@ -// 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.IO; -using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class IncrementalCache - { - private const string BuildArgumentsKeyName = "buildArguments"; - private const string InputsKeyName = "inputs"; - private const string OutputsKeyNane = "outputs"; - - public CompilerIO CompilerIO { get; } - - /// - /// Captures parameters that affect compilation outputs. - /// - public IDictionary BuildArguments { get; } - - public IncrementalCache(CompilerIO compilerIO, IEnumerable> parameters) - { - CompilerIO = compilerIO; - BuildArguments = parameters.ToDictionary(p => p.Key, p => p.Value); - } - - public void WriteToFile(string cacheFile) - { - try - { - CreatePathIfAbsent(cacheFile); - - using (var streamWriter = new StreamWriter(new FileStream(cacheFile, FileMode.Create, FileAccess.Write, FileShare.None))) - { - var rootObject = new JObject(); - rootObject[InputsKeyName] = new JArray(CompilerIO.Inputs); - rootObject[OutputsKeyNane] = new JArray(CompilerIO.Outputs); - rootObject[BuildArgumentsKeyName] = JObject.FromObject(BuildArguments); - - JsonSerializer.Create().Serialize(streamWriter, rootObject); - } - } - catch (Exception e) - { - throw new InvalidDataException($"Could not write the incremental cache file: {cacheFile}", e); - } - } - - private static void CreatePathIfAbsent(string filePath) - { - var parentDir = Path.GetDirectoryName(filePath); - - if (!Directory.Exists(parentDir)) - { - Directory.CreateDirectory(parentDir); - } - } - - public static IncrementalCache ReadFromFile(string cacheFile) - { - try - { - using (var streamReader = new StreamReader(new FileStream(cacheFile, FileMode.Open, FileAccess.Read, FileShare.Read))) - { - var jObject = JObject.Parse(streamReader.ReadToEnd()); - - if (jObject == null) - { - throw new InvalidDataException(); - } - - var inputs = ReadArray(jObject, InputsKeyName); - var outputs = ReadArray(jObject, OutputsKeyNane); - var parameters = ReadDictionary(jObject, BuildArgumentsKeyName); - - return new IncrementalCache(new CompilerIO(inputs, outputs), parameters); - } - } - catch (Exception e) - { - throw new InvalidDataException($"Could not read the incremental cache file: {cacheFile}", e); - } - } - - private static IEnumerable> ReadDictionary(JObject jObject, string keyName) - { - var obj = jObject[keyName] as JObject; - - if(obj == null) - { - return Enumerable.Empty>(); - } - - return obj.Properties().ToDictionary(p => p.Name, p => p.Value.ToString()); - } - - private static IEnumerable ReadArray(JObject jObject, string keyName) - { - var array = jObject.Value(keyName)?.Values(); - - if (array == null) - { - throw new InvalidDataException($"Could not read key {keyName}"); - } - - return array; - } - } -} diff --git a/src/dotnet/commands/dotnet-build/IncrementalManager.cs b/src/dotnet/commands/dotnet-build/IncrementalManager.cs deleted file mode 100644 index 2fa71fcc5..000000000 --- a/src/dotnet/commands/dotnet-build/IncrementalManager.cs +++ /dev/null @@ -1,220 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.Tools.Compiler; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class IncrementalManager - { - private readonly ProjectBuilder _projectBuilder; - private readonly CompilerIOManager _compilerIoManager; - private readonly IncrementalPreconditionManager _preconditionManager; - private readonly bool _shouldSkipDependencies; - private readonly string _configuration; - private readonly string _buildBasePath; - private readonly string _outputPath; - private readonly IDictionary _incrementalAffectingArguments; - - public IncrementalManager( - ProjectBuilder projectBuilder, - CompilerIOManager compilerIOManager, - IncrementalPreconditionManager incrementalPreconditionManager, - bool shouldSkipDependencies, - string configuration, - string buildBasePath, - string outputPath, - IDictionary incrementalAffectingArguments) - { - _projectBuilder = projectBuilder; - _compilerIoManager = compilerIOManager; - _preconditionManager = incrementalPreconditionManager; - _shouldSkipDependencies = shouldSkipDependencies; - _configuration = configuration; - _buildBasePath = buildBasePath; - _outputPath = outputPath; - _incrementalAffectingArguments = incrementalAffectingArguments; - } - - public IncrementalResult NeedsRebuilding(ProjectGraphNode graphNode) - { - if (!_shouldSkipDependencies && - graphNode.Dependencies.Any(d => _projectBuilder.GetCompilationResult(d) != CompilationResult.IncrementalSkip)) - { - return new IncrementalResult("dependencies changed"); - } - - var preconditions = _preconditionManager.GetIncrementalPreconditions(graphNode); - if (preconditions.PreconditionsDetected()) - { - return new IncrementalResult($"project is not safe for incremental compilation. Use {BuildCommandApp.BuildProfileFlag} flag for more information."); - } - - var compilerIO = _compilerIoManager.GetCompileIO(graphNode); - - var result = CLIChanged(graphNode); - if (result.NeedsRebuilding) - { - return result; - } - - result = InputItemsChanged(graphNode, compilerIO); - if (result.NeedsRebuilding) - { - return result; - } - - result = TimestampsChanged(compilerIO); - if (result.NeedsRebuilding) - { - return result; - } - - return IncrementalResult.DoesNotNeedRebuild; - } - - private IncrementalResult CLIChanged(ProjectGraphNode graphNode) - { - var currentVersionFile = DotnetFiles.VersionFile; - var versionFileFromLastCompile = graphNode.ProjectContext.GetSDKVersionFile(_configuration, _buildBasePath, _outputPath); - - if (!File.Exists(currentVersionFile)) - { - // this CLI does not have a version file; cannot tell if CLI changed - return IncrementalResult.DoesNotNeedRebuild; - } - - if (!File.Exists(versionFileFromLastCompile)) - { - // this is the first compilation; cannot tell if CLI changed - return IncrementalResult.DoesNotNeedRebuild; - } - - var currentContent = DotnetFiles.ReadAndInterpretVersionFile(); - - var versionsAreEqual = string.Equals(currentContent, File.ReadAllText(versionFileFromLastCompile), StringComparison.OrdinalIgnoreCase); - - return versionsAreEqual - ? IncrementalResult.DoesNotNeedRebuild - : new IncrementalResult("the version or bitness of the CLI changed since the last build"); - } - - private IncrementalResult InputItemsChanged(ProjectGraphNode graphNode, CompilerIO compilerIO) - { - // check empty inputs / outputs - if (!compilerIO.Inputs.Any()) - { - return new IncrementalResult("the project has no inputs"); - } - - if (!compilerIO.Outputs.Any()) - { - return new IncrementalResult("the project has no outputs"); - } - - // check non existent items - var result = CheckMissingIO(compilerIO.Inputs, "inputs"); - if (result.NeedsRebuilding) - { - return result; - } - - result = CheckMissingIO(compilerIO.Outputs, "outputs"); - if (result.NeedsRebuilding) - { - return result; - } - - return CheckInputGlobChanges(graphNode, compilerIO); - } - - private IncrementalResult CheckInputGlobChanges(ProjectGraphNode graphNode, CompilerIO compilerIO) - { - // check cache against input glob pattern changes - var incrementalCacheFile = graphNode.ProjectContext.IncrementalCacheFile(_configuration, _buildBasePath, _outputPath); - - if (!File.Exists(incrementalCacheFile)) - { - // cache is not present (first compilation); can't determine if globs changed; cache will be generated after build processes project - return IncrementalResult.DoesNotNeedRebuild; - } - - var incrementalCache = IncrementalCache.ReadFromFile(incrementalCacheFile); - - var diffResult = compilerIO.DiffInputs(incrementalCache.CompilerIO); - - if (diffResult.Deletions.Any()) - { - return new IncrementalResult("Input items removed from last build", diffResult.Deletions); - } - - if (diffResult.Additions.Any()) - { - return new IncrementalResult("Input items added from last build", diffResult.Additions); - } - - var keys = incrementalCache.BuildArguments.Keys.Union(_incrementalAffectingArguments.Keys); - var mismatchedKeys = keys.Where(k => - { - string cachedVal; - string currentVal; - - return !incrementalCache.BuildArguments.TryGetValue(k, out cachedVal) || - !_incrementalAffectingArguments.TryGetValue(k, out currentVal) || - !string.Equals(cachedVal ?? string.Empty, currentVal ?? string.Empty, StringComparison.Ordinal); - }); - if (mismatchedKeys.Any()) - { - return new IncrementalResult("Build arguments changed since last build", mismatchedKeys); - } - - return IncrementalResult.DoesNotNeedRebuild; - } - - private IncrementalResult CheckMissingIO(IEnumerable items, string itemsType) - { - var missingItems = items.Where(i => !File.Exists(i)).ToList(); - - return missingItems.Any() - ? new IncrementalResult($"expected {itemsType} are missing", missingItems) - : IncrementalResult.DoesNotNeedRebuild; - } - - private IncrementalResult TimestampsChanged(CompilerIO compilerIO) - { - // find the output with the earliest write time - var minDateUtc = DateTime.MaxValue; - - foreach (var outputPath in compilerIO.Outputs) - { - var lastWriteTimeUtc = File.GetLastWriteTimeUtc(outputPath); - - if (lastWriteTimeUtc < minDateUtc) - { - minDateUtc = lastWriteTimeUtc; - } - } - - // find inputs that are newer than the earliest output - var newInputs = compilerIO.Inputs.Where(p => File.GetLastWriteTimeUtc(p) >= minDateUtc); - - return newInputs.Any() - ? new IncrementalResult("inputs were modified", newInputs) - : IncrementalResult.DoesNotNeedRebuild; - } - - public void CacheIncrementalState(ProjectGraphNode graphNode) - { - var incrementalCacheFile = graphNode.ProjectContext.IncrementalCacheFile(_configuration, _buildBasePath, _outputPath); - - var incrementalCache = new IncrementalCache(_compilerIoManager.GetCompileIO(graphNode), _incrementalAffectingArguments); - incrementalCache.WriteToFile(incrementalCacheFile); - } - } -} diff --git a/src/dotnet/commands/dotnet-build/IncrementalPreconditionManager.cs b/src/dotnet/commands/dotnet-build/IncrementalPreconditionManager.cs deleted file mode 100644 index c63ad77e2..000000000 --- a/src/dotnet/commands/dotnet-build/IncrementalPreconditionManager.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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; -using Microsoft.DotNet.Tools.Compiler; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.ProjectModel.Utilities; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class IncrementalPreconditionManager - { - private readonly bool _printPreconditions; - private readonly bool _forceNonIncremental; - private readonly bool _skipDependencies; - private Dictionary _preconditions; - - public IncrementalPreconditionManager(bool printPreconditions, bool forceNonIncremental, bool skipDependencies) - { - _printPreconditions = printPreconditions; - _forceNonIncremental = forceNonIncremental; - _skipDependencies = skipDependencies; - _preconditions = new Dictionary(); - } - - public static readonly string[] KnownCompilers = { "csc", "vbc", "fsc" }; - - public IncrementalPreconditions GetIncrementalPreconditions(ProjectGraphNode projectNode) - { - IncrementalPreconditions preconditions; - if (_preconditions.TryGetValue(projectNode.ProjectContext.Identity, out preconditions)) - { - return preconditions; - } - - preconditions = new IncrementalPreconditions(_printPreconditions); - - if (_forceNonIncremental) - { - preconditions.AddForceUnsafePrecondition(); - } - - var project = projectNode.ProjectContext; - CollectScriptPreconditions(project, preconditions); - CollectCompilerNamePreconditions(project, preconditions); - CollectCheckPathProbingPreconditions(project, preconditions); - _preconditions[projectNode.ProjectContext.Identity] = preconditions; - return preconditions; - } - - private void CollectCheckPathProbingPreconditions(ProjectContext project, IncrementalPreconditions preconditions) - { - var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project) - .Select(commandName => Command.CreateDotNet(commandName, Enumerable.Empty(), project.TargetFramework)) - .Where(c => c.ResolutionStrategy.Equals(CommandResolutionStrategy.Path)); - - foreach (var pathCommand in pathCommands) - { - preconditions.AddPathProbingPrecondition(project.ProjectName(), pathCommand.CommandName); - } - } - - private void CollectCompilerNamePreconditions(ProjectContext project, IncrementalPreconditions preconditions) - { - if (project.ProjectFile != null) - { - var compilerOptions = project.ProjectFile.GetCompilerOptions(project.TargetFramework, null); - var projectCompiler = compilerOptions.CompilerName; - - if (!KnownCompilers.Any(knownCompiler => knownCompiler.Equals(projectCompiler, StringComparison.Ordinal))) - { - preconditions.AddUnknownCompilerPrecondition(project.ProjectName(), projectCompiler); - } - } - } - - private void CollectScriptPreconditions(ProjectContext project, IncrementalPreconditions preconditions) - { - if (project.ProjectFile != null) - { - var preCompileScripts = project.ProjectFile.Scripts.GetOrEmpty(ScriptNames.PreCompile); - var postCompileScripts = project.ProjectFile.Scripts.GetOrEmpty(ScriptNames.PostCompile); - - if (preCompileScripts.Any()) - { - preconditions.AddPrePostScriptPrecondition(project.ProjectName(), ScriptNames.PreCompile); - } - - if (postCompileScripts.Any()) - { - preconditions.AddPrePostScriptPrecondition(project.ProjectName(), ScriptNames.PostCompile); - } - } - } - - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/IncrementalPreconditions.cs b/src/dotnet/commands/dotnet-build/IncrementalPreconditions.cs deleted file mode 100644 index 64af10cf2..000000000 --- a/src/dotnet/commands/dotnet-build/IncrementalPreconditions.cs +++ /dev/null @@ -1,84 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Tools.Compiler; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class IncrementalPreconditions - { - private readonly ISet _preconditions; - private readonly bool _isProfile; - - public IncrementalPreconditions(bool isProfile) - { - _isProfile = isProfile; - _preconditions = new HashSet(); - } - - public void AddPrePostScriptPrecondition(string projectName, string scriptType) - { - _preconditions.Add($"[Pre / Post Scripts] Project {projectName} is using {scriptType} scripts."); - } - - public void AddUnknownCompilerPrecondition(string projectName, string compilerName) - { - _preconditions.Add($"[Unknown Compiler] Project {projectName} is using unknown compiler {compilerName}."); - } - - public void AddPathProbingPrecondition(string projectName, string commandName) - { - _preconditions.Add($"[PATH Probing] Project {projectName} is loading tool \"{commandName}\" from PATH"); - } - - public void AddForceUnsafePrecondition() - { - _preconditions.Add($"[Forced Unsafe] The build was marked as unsafe. Remove the {BuildCommandApp.NoIncrementalFlag} flag to enable incremental compilation"); - } - - public bool PreconditionsDetected() - { - return _preconditions.Any(); - } - - private string PreconditionsMessage() - { - var log = new StringBuilder(); - - log.AppendLine(); - log.Append("Incremental compilation has been disabled due to the following project properties:"); - - foreach (var precondition in _preconditions) - { - log.AppendLine(); - log.Append("\t" + precondition); - } - - log.AppendLine(); - log.AppendLine(); - - log.Append( - "Incremental compilation will be automatically enabled if the above mentioned project properties are not used. " + - "For more information on the properties and how to address them, please consult https://aka.ms/dotnet-build."); - - log.AppendLine(); - log.AppendLine(); - - return log.ToString(); - } - - public string LogMessage() - { - if (PreconditionsDetected()) - { - return _isProfile ? PreconditionsMessage().Yellow() : $"(The compilation time can be improved. Run \"dotnet build {BuildCommandApp.BuildProfileFlag}\" for more information)"; - } - - return ""; - } - } -} diff --git a/src/dotnet/commands/dotnet-build/IncrementalResult.cs b/src/dotnet/commands/dotnet-build/IncrementalResult.cs deleted file mode 100644 index 712de6176..000000000 --- a/src/dotnet/commands/dotnet-build/IncrementalResult.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class IncrementalResult - { - public static readonly IncrementalResult DoesNotNeedRebuild = new IncrementalResult(false, "", Enumerable.Empty()); - - public bool NeedsRebuilding { get; } - public string Reason { get; } - public IEnumerable Items { get; } - - private IncrementalResult(bool needsRebuilding, string reason, IEnumerable items) - { - NeedsRebuilding = needsRebuilding; - Reason = reason; - Items = items; - } - - public IncrementalResult(string reason) - : this(true, reason, Enumerable.Empty()) - { - } - - public IncrementalResult(string reason, IEnumerable items) - : this(true, reason, items) - { - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/Program.cs b/src/dotnet/commands/dotnet-build/Program.cs index 132804192..d5251a19f 100644 --- a/src/dotnet/commands/dotnet-build/Program.cs +++ b/src/dotnet/commands/dotnet-build/Program.cs @@ -1,113 +1,88 @@ // 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; -using System.Threading.Tasks; +using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Compiler; -using NuGet.Frameworks; +using Microsoft.DotNet.Tools.MSBuild; namespace Microsoft.DotNet.Tools.Build { public class BuildCommand { - public static int Run(string[] args) => Run(args, null); - - public static int Run(string[] args, BuildWorkspace workspace) + public static int Run(string[] args) { DebugHelper.HandleDebugSwitch(ref args); - try - { - var app = new BuildCommandApp( - "dotnet build", - ".NET Builder", - "Builder for the .NET Platform. It performs incremental compilation if it's safe to do so. Otherwise it delegates to dotnet-compile which performs non-incremental compilation", - workspace); - return app.Execute(OnExecute, args); - } - catch (Exception ex) - { -#if DEBUG - Console.Error.WriteLine(ex); -#else - Console.Error.WriteLine(ex.Message); -#endif - return 1; - } - } + CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false); + app.Name = "dotnet build"; + app.FullName = ".NET Builder"; + app.Description = "Builder for the .NET Platform. Delegates to the MSBuild 'Build' target in the project file."; + app.AllowArgumentSeparator = true; + app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText; + app.HelpOption("-h|--help"); - private static bool OnExecute(IEnumerable files, IEnumerable frameworks, BuildCommandApp args) - { - var builderCommandApp = args; - var graphCollector = new ProjectGraphCollector( - !builderCommandApp.ShouldSkipDependencies, - (project, target) => args.Workspace.GetProjectContext(project, target)); + CommandArgument projectArgument = app.Argument("", + "The MSBuild project file to build. If a project file is not specified," + + " MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file."); - IEnumerable contexts; - using (PerfTrace.Current.CaptureTiming(string.Empty, nameof(ResolveRootContexts))) + CommandOption outputOption = app.Option("-o|--output ", "Directory in which to place outputs", CommandOptionType.SingleValue); + CommandOption frameworkOption = app.Option("-f|--framework ", "Compile a specific framework", CommandOptionType.SingleValue); + CommandOption configurationOption = app.Option("-c|--configuration ", "Configuration under which to build", CommandOptionType.SingleValue); + CommandOption versionSuffixOption = app.Option("--version-suffix ", "Defines the value for the $(VersionSuffix) property in the project", CommandOptionType.SingleValue); + + CommandOption noIncrementalOption = app.Option("--no-incremental", "Set this flag to turn off incremental build", CommandOptionType.NoValue); + CommandOption noDependenciesOption = app.Option("--no-dependencies", "Set this flag to ignore project to project references and only build the root project", CommandOptionType.NoValue); + + app.OnExecute(() => { - contexts = ResolveRootContexts(files, frameworks, args); - } + List msbuildArgs = new List(); - ProjectGraphNode[] graph; - using (PerfTrace.Current.CaptureTiming(string.Empty, "Collect graph")) - { - graph = graphCollector.Collect(contexts).ToArray(); - } - var builder = new DotNetProjectBuilder(builderCommandApp); - return builder.Build(graph).ToArray().All(r => r != CompilationResult.Failure); - } - - private static IEnumerable ResolveRootContexts( - IEnumerable files, - IEnumerable frameworks, - BuildCommandApp args) - { - List> tasks = new List>(); - - foreach (var file in files) - { - Project project; - using (PerfTrace.Current.CaptureTiming(file, "Loading project.json")) + if (!string.IsNullOrEmpty(projectArgument.Value)) { - project = args.Workspace.GetProject(file); + msbuildArgs.Add(projectArgument.Value); } - var projectFrameworks = project.GetTargetFrameworks().Select(f => f.FrameworkName); - if (!projectFrameworks.Any()) - { - throw new InvalidOperationException( - $"Project '{file}' does not have any frameworks listed in the 'frameworks' section."); - } - IEnumerable selectedFrameworks; - if (frameworks != null) - { - var unsupportedByProject = frameworks.Where(f => !projectFrameworks.Contains(f)); - if (unsupportedByProject.Any()) - { - throw new InvalidOperationException( - $"Project \'{file}\' does not support framework: {string.Join(", ", unsupportedByProject.Select(fx => fx.DotNetFrameworkName))}."); - } - selectedFrameworks = frameworks; + if (noIncrementalOption.HasValue()) + { + msbuildArgs.Add("/t:Rebuild"); } else { - selectedFrameworks = projectFrameworks; + msbuildArgs.Add("/t:Build"); } - foreach (var framework in selectedFrameworks) + if (outputOption.HasValue()) { - tasks.Add(Task.Run(() => args.Workspace.GetProjectContext(file, framework))); + msbuildArgs.Add($"/p:OutputPath={outputOption.Value()}"); } - } - using (PerfTrace.Current.CaptureTiming(string.Empty, "Waiting for project contexts to finish loading")) - { - return Task.WhenAll(tasks).GetAwaiter().GetResult(); - } + + if (frameworkOption.HasValue()) + { + msbuildArgs.Add($"/p:TargetFramework={frameworkOption.Value()}"); + } + + if (configurationOption.HasValue()) + { + msbuildArgs.Add($"/p:Configuration={configurationOption.Value()}"); + } + + if (versionSuffixOption.HasValue()) + { + msbuildArgs.Add($"/p:VersionSuffix={versionSuffixOption.Value()}"); + } + + if (noDependenciesOption.HasValue()) + { + msbuildArgs.Add("/p:BuildProjectReferences=false"); + } + + msbuildArgs.AddRange(app.RemainingArguments); + + return new MSBuildForwardingApp(msbuildArgs).Execute(); + }); + + return app.Execute(args); } } } diff --git a/src/dotnet/commands/dotnet-build/ProjectBuilder.cs b/src/dotnet/commands/dotnet-build/ProjectBuilder.cs deleted file mode 100644 index fe9d20864..000000000 --- a/src/dotnet/commands/dotnet-build/ProjectBuilder.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; -using NuGet.Frameworks; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Cli.Compiler.Common; - -namespace Microsoft.DotNet.Tools.Build -{ - internal abstract class ProjectBuilder - { - private readonly bool _skipDependencies; - - public ProjectBuilder(bool skipDependencies) - { - _skipDependencies = skipDependencies; - } - - private Dictionary _compilationResults = new Dictionary(); - - public IEnumerable Build(IEnumerable roots) - { - foreach (var projectNode in roots) - { - using (PerfTrace.Current.CaptureTiming($"{projectNode.ProjectContext.ProjectName()}")) - { - yield return Build(projectNode); - } - } - } - - public CompilationResult? GetCompilationResult(ProjectGraphNode projectNode) - { - CompilationResult result; - if (_compilationResults.TryGetValue(projectNode.ProjectContext.Identity, out result)) - { - return result; - } - return null; - } - - protected virtual bool NeedsRebuilding(ProjectGraphNode projectNode) - { - return true; - } - - protected virtual void ProjectSkiped(ProjectGraphNode projectNode) - { - } - - protected abstract CompilationResult RunCompile(ProjectGraphNode projectNode); - - protected virtual CompilationResult Build(ProjectGraphNode projectNode) - { - CompilationResult result; - if (_compilationResults.TryGetValue(projectNode.ProjectContext.Identity, out result)) - { - return result; - } - result = CompileWithDependencies(projectNode); - - _compilationResults[projectNode.ProjectContext.Identity] = result; - - return result; - } - - private CompilationResult CompileWithDependencies(ProjectGraphNode projectNode) - { - if (!_skipDependencies) - { - foreach (var dependency in projectNode.Dependencies) - { - var result = Build(dependency); - if (result == CompilationResult.Failure) - { - return CompilationResult.Failure; - } - } - } - - var context = projectNode.ProjectContext; - using (PerfTrace.Current.CaptureTiming($"{projectNode.ProjectContext.ProjectName()}", nameof(HasSourceFiles))) - { - if (!HasSourceFiles(context)) - { - return CompilationResult.IncrementalSkip; - } - } - - bool needsRebuilding; - using (PerfTrace.Current.CaptureTiming($"{projectNode.ProjectContext.ProjectName()}", nameof(NeedsRebuilding))) - { - needsRebuilding = NeedsRebuilding(projectNode); - } - - if (needsRebuilding) - { - using (PerfTrace.Current.CaptureTiming($"{projectNode.ProjectContext.ProjectName()}",nameof(RunCompile))) - { - return RunCompile(projectNode); - } - } - else - { - using (PerfTrace.Current.CaptureTiming($"{projectNode.ProjectContext.ProjectName()}", nameof(ProjectSkiped))) - { - ProjectSkiped(projectNode); - } - return CompilationResult.IncrementalSkip; - } - } - - private static bool HasSourceFiles(ProjectContext context) - { - var compilerOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, null); - - if (compilerOptions.CompileInclude == null) - { - return context.ProjectFile.Files.SourceFiles.Any(); - } - - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); - - return includeFiles.Any(); - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/ProjectGraphCollector.cs b/src/dotnet/commands/dotnet-build/ProjectGraphCollector.cs deleted file mode 100644 index a9035e253..000000000 --- a/src/dotnet/commands/dotnet-build/ProjectGraphCollector.cs +++ /dev/null @@ -1,97 +0,0 @@ -// 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 NuGet.Frameworks; -using Microsoft.DotNet.ProjectModel; -using System.Linq; -using System.Threading.Tasks; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class ProjectGraphCollector - { - private readonly bool _collectDependencies; - private readonly Func _projectContextFactory; - - public ProjectGraphCollector(bool collectDependencies, - Func projectContextFactory) - { - _collectDependencies = collectDependencies; - _projectContextFactory = projectContextFactory; - } - - public IEnumerable Collect(IEnumerable contexts) - { - foreach (var context in contexts) - { - var libraries = context.LibraryManager.GetLibraries(); - var lookup = libraries.ToDictionary(l => l.Identity.Name, StringComparer.OrdinalIgnoreCase); - var root = lookup[context.ProjectFile.Name]; - yield return TraverseProject((ProjectDescription) root, lookup, context); - } - } - - private ProjectGraphNode TraverseProject(ProjectDescription project, IDictionary lookup, ProjectContext context = null) - { - var isRoot = context != null; - var deps = new List(); - if (isRoot || _collectDependencies) - { - foreach (var dependency in project.Dependencies) - { - LibraryDescription libraryDescription; - if ((lookup.TryGetValue(dependency.Name, out libraryDescription)) && (!libraryDescription.Identity.Name.Equals(project.Identity.Name))) - { - if (libraryDescription.Resolved && libraryDescription.Identity.Type.Equals(LibraryType.Project)) - { - deps.Add(TraverseProject((ProjectDescription)libraryDescription, lookup)); - } - else - { - deps.AddRange(TraverseNonProject(libraryDescription, lookup)); - } - } - } - } - - var task = context != null ? Task.FromResult(context) : Task.Run(() => _projectContextFactory(project.Path, project.Framework)); - return new ProjectGraphNode(task, deps, isRoot); - } - - private IEnumerable TraverseNonProject(LibraryDescription root, IDictionary lookup) - { - Stack libraries = new Stack(); - libraries.Push(root); - while (libraries.Count > 0) - { - var current = libraries.Pop(); - bool foundProject = false; - foreach (var dependency in current.Dependencies) - { - LibraryDescription libraryDescription; - if (lookup.TryGetValue(dependency.Name, out libraryDescription)) - { - if (libraryDescription.Identity.Type.Equals(LibraryType.Project)) - { - foundProject = true; - yield return TraverseProject((ProjectDescription) libraryDescription, lookup); - } - else - { - libraries.Push(libraryDescription); - } - } - } - // if package didn't have any project dependencies inside remove it from lookup - // and do not traverse anymore - if (!foundProject) - { - lookup.Remove(current.Identity.Name); - } - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/ProjectGraphNode.cs b/src/dotnet/commands/dotnet-build/ProjectGraphNode.cs deleted file mode 100644 index 88aa8f841..000000000 --- a/src/dotnet/commands/dotnet-build/ProjectGraphNode.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.DotNet.Tools.Build -{ - internal class ProjectGraphNode - { - private readonly Task _projectContextCreator; - - public ProjectGraphNode(Task projectContext, IEnumerable dependencies, bool isRoot = false) - { - _projectContextCreator = projectContext; - Dependencies = dependencies.ToList(); - IsRoot = isRoot; - } - - public ProjectContext ProjectContext - { - get - { - using (_projectContextCreator.IsCompleted ? null : PerfTrace.Current.CaptureTiming("", "Blocking ProjectContext wait")) - { - return _projectContextCreator.GetAwaiter().GetResult(); - } - } - } - - public IReadOnlyList Dependencies { get; } - - public bool IsRoot { get; } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/README.md b/src/dotnet/commands/dotnet-build/README.md deleted file mode 100644 index b12c482e0..000000000 --- a/src/dotnet/commands/dotnet-build/README.md +++ /dev/null @@ -1,81 +0,0 @@ -% DOTNET-BUILD(1) -% Microsoft Corporation dotnetclifeedback@microsoft.com -% April 2016 - -## NAME -dotnet-build -- Builds a project and all of its dependencies - -## SYNOPSIS - -`dotnet build [--output] - [--build-base-path] [--framework] - [--configuration] [--runtime] [--version-suffix] - [--build-profile] [--no-incremental] [--no-dependencies] - []` - -## DESCRIPTION - -The `dotnet build` command builds multiple source file from a source project and its dependencies into a binary. -The binary will be in Intermediate Language (IL) by default and will have a DLL extension. -`dotnet build` will also drop a `\*.deps` file which outlines what the host needs to run the application. - -Building requires the existence of a lock file, which means that you have to run [`dotnet restore`](../dotnet-restore/README.md) prior to building your code. - -Before any compilation begins, the build verb analyzes the project and its dependencies for incremental safety checks. -If all checks pass, then build proceeds with incremental compilation of the project and its dependencies; -otherwise, it falls back to non-incremental compilation. Via a profile flag, users can choose to receive additional -information on how they can improve their build times. - -All projects in the dependency graph that need compilation must pass the following safety checks in order for the -compilation process to be incremental: -- not use pre/post compile scripts -- not load compilation tools from PATH (for example, resgen, compilers) -- use only known compilers (csc, vbc, fsc) - -In order to build an executable application, you need a special configuration section in your project.json file: - -```json -{ - "compilerOptions": { - "emitEntryPoint": true - } -} -``` - -## OPTIONS - -`-o`, `--output` [DIR] - -Directory in which to place the built binaries. - -`-b`, `--build-base-path` [DIR] - -Directory in which to place temporary outputs. - -`-f`, `--framework` [FRAMEWORK] - -Compiles for a specific framework. The framework needs to be defined in the project.json file. - -`-c`, `--configuration` [Debug|Release] - -Defines a configuration under which to build. If omitted, it defaults to Debug. - -`-r`, `--runtime` [RUNTIME_IDENTIFIER] - -Target runtime to build for. - ---version-suffix [VERSION_SUFFIX] - -Defines what `*` should be replaced with in the version field in the project.json file. The format follows NuGet's version guidelines. - -`--build-profile` - -Prints out the incremental safety checks that users need to address in order for incremental compilation to be automatically turned on. - -`--no-incremental` - -Marks the build as unsafe for incremental build. This turns off incremental compilation and forces a clean rebuild of the project dependency graph. - -`--no-dependencies` - -Ignores project-to-project references and only builds the root project specified to build. diff --git a/src/dotnet/commands/dotnet-build3/Program.cs b/src/dotnet/commands/dotnet-build3/Program.cs deleted file mode 100644 index 8d44f980e..000000000 --- a/src/dotnet/commands/dotnet-build3/Program.cs +++ /dev/null @@ -1,88 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Tools.MSBuild; - -namespace Microsoft.DotNet.Tools.Build3 -{ - public class Build3Command - { - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false); - app.Name = "dotnet build3"; - app.FullName = ".NET Builder"; - app.Description = "Builder for the .NET Platform. Delegates to the MSBuild 'Build' target in the project file."; - app.AllowArgumentSeparator = true; - app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText; - app.HelpOption("-h|--help"); - - CommandArgument projectArgument = app.Argument("", - "The MSBuild project file to build. If a project file is not specified," + - " MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file."); - - CommandOption outputOption = app.Option("-o|--output ", "Directory in which to place outputs", CommandOptionType.SingleValue); - CommandOption frameworkOption = app.Option("-f|--framework ", "Compile a specific framework", CommandOptionType.SingleValue); - CommandOption configurationOption = app.Option("-c|--configuration ", "Configuration under which to build", CommandOptionType.SingleValue); - CommandOption versionSuffixOption = app.Option("--version-suffix ", "Defines the value for the $(VersionSuffix) property in the project", CommandOptionType.SingleValue); - - CommandOption noIncrementalOption = app.Option("--no-incremental", "Set this flag to turn off incremental build", CommandOptionType.NoValue); - CommandOption noDependenciesOption = app.Option("--no-dependencies", "Set this flag to ignore project to project references and only build the root project", CommandOptionType.NoValue); - - app.OnExecute(() => - { - List msbuildArgs = new List(); - - if (!string.IsNullOrEmpty(projectArgument.Value)) - { - msbuildArgs.Add(projectArgument.Value); - } - - if (noIncrementalOption.HasValue()) - { - msbuildArgs.Add("/t:Rebuild"); - } - else - { - msbuildArgs.Add("/t:Build"); - } - - if (outputOption.HasValue()) - { - msbuildArgs.Add($"/p:OutputPath={outputOption.Value()}"); - } - - if (frameworkOption.HasValue()) - { - msbuildArgs.Add($"/p:TargetFramework={frameworkOption.Value()}"); - } - - if (configurationOption.HasValue()) - { - msbuildArgs.Add($"/p:Configuration={configurationOption.Value()}"); - } - - if (versionSuffixOption.HasValue()) - { - msbuildArgs.Add($"/p:VersionSuffix={versionSuffixOption.Value()}"); - } - - if (noDependenciesOption.HasValue()) - { - msbuildArgs.Add("/p:BuildProjectReferences=false"); - } - - msbuildArgs.AddRange(app.RemainingArguments); - - return new MSBuildForwardingApp(msbuildArgs).Execute(); - }); - - return app.Execute(args); - } - } -} diff --git a/src/dotnet/commands/dotnet-clean3/Program.cs b/src/dotnet/commands/dotnet-clean/Program.cs similarity index 96% rename from src/dotnet/commands/dotnet-clean3/Program.cs rename to src/dotnet/commands/dotnet-clean/Program.cs index 7824ed9a9..2c8995166 100644 --- a/src/dotnet/commands/dotnet-clean3/Program.cs +++ b/src/dotnet/commands/dotnet-clean/Program.cs @@ -6,9 +6,9 @@ using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools.MSBuild; -namespace Microsoft.DotNet.Tools.Clean3 +namespace Microsoft.DotNet.Tools.Clean { - public class Clean3Command + public class CleanCommand { public static int Run(string[] args) { @@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Tools.Clean3 CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false) { - Name = "dotnet clean3", + Name = "dotnet clean", FullName = ".NET Clean Command", Description = "Command to clean previously generated build outputs.", AllowArgumentSeparator = true, diff --git a/src/dotnet/commands/dotnet-compile-csc/AssemblyInfoOptionsCommandLine.cs b/src/dotnet/commands/dotnet-compile-csc/AssemblyInfoOptionsCommandLine.cs deleted file mode 100644 index a3c297e13..000000000 --- a/src/dotnet/commands/dotnet-compile-csc/AssemblyInfoOptionsCommandLine.cs +++ /dev/null @@ -1,78 +0,0 @@ -// 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.Cli.CommandLine; -using Microsoft.DotNet.Cli.Compiler.Common; -using static Microsoft.DotNet.Cli.Compiler.Common.AssemblyInfoOptions; - -namespace Microsoft.DotNet.Tools.Compiler -{ - internal class AssemblyInfoOptionsCommandLine - { - public CommandOption VersionOption { get; set; } - public CommandOption TitleOption { get; set; } - public CommandOption DescriptionOption { get; set; } - public CommandOption CopyrightOption { get; set; } - public CommandOption NeutralCultureOption { get; set; } - public CommandOption CultureOption { get; set; } - public CommandOption InformationalVersionOption { get; set; } - public CommandOption FileVersionOption { get; set; } - public CommandOption TargetFrameworkOption { get; set; } - - public static AssemblyInfoOptionsCommandLine AddOptions(CommandLineApplication app) - { - AssemblyInfoOptionsCommandLine commandLineOptions = new AssemblyInfoOptionsCommandLine(); - - commandLineOptions.VersionOption = AddOption(app, AssemblyVersionOptionName, "Assembly version"); - - commandLineOptions.TitleOption = AddOption(app, TitleOptionName, "Assembly title"); - - commandLineOptions.DescriptionOption = AddOption(app, DescriptionOptionName, "Assembly description"); - - commandLineOptions.CopyrightOption = AddOption(app, CopyrightOptionName, "Assembly copyright"); - - commandLineOptions.NeutralCultureOption = AddOption(app, NeutralCultureOptionName, "Assembly neutral culture"); - - commandLineOptions.CultureOption = AddOption(app, CultureOptionName, "Assembly culture"); - - commandLineOptions.InformationalVersionOption = AddOption(app, InformationalVersionOptionName, "Assembly informational version"); - - commandLineOptions.FileVersionOption = AddOption(app, AssemblyFileVersionOptionName, "Assembly file version"); - - commandLineOptions.TargetFrameworkOption = AddOption(app, TargetFrameworkOptionName, "Assembly target framework"); - - return commandLineOptions; - } - - private static CommandOption AddOption(CommandLineApplication app, string optionName, string description) - { - return app.Option($"--{optionName} ", description, CommandOptionType.SingleValue); - } - - public AssemblyInfoOptions GetOptionValues() - { - return new AssemblyInfoOptions() - { - AssemblyVersion = UnescapeNewlines(VersionOption.Value()), - Title = UnescapeNewlines(TitleOption.Value()), - Description = UnescapeNewlines(DescriptionOption.Value()), - Copyright = UnescapeNewlines(CopyrightOption.Value()), - NeutralLanguage = UnescapeNewlines(NeutralCultureOption.Value()), - Culture = UnescapeNewlines(CultureOption.Value()), - InformationalVersion = UnescapeNewlines(InformationalVersionOption.Value()), - AssemblyFileVersion = UnescapeNewlines(FileVersionOption.Value()), - TargetFramework = UnescapeNewlines(TargetFrameworkOption.Value()), - }; - } - - private static string UnescapeNewlines(string text) - { - if (string.IsNullOrEmpty(text)) - { - return text; - } - - return text.Replace("\\r", "\r").Replace("\\n", "\n"); - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-csc/CommonCompilerOptionsCommandLine.cs b/src/dotnet/commands/dotnet-compile-csc/CommonCompilerOptionsCommandLine.cs deleted file mode 100644 index 83d0ceee4..000000000 --- a/src/dotnet/commands/dotnet-compile-csc/CommonCompilerOptionsCommandLine.cs +++ /dev/null @@ -1,110 +0,0 @@ -// 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.Cli.CommandLine; -using Microsoft.DotNet.ProjectModel; -using static Microsoft.DotNet.Cli.Compiler.Common.CommonCompilerOptionsExtensions; - -namespace Microsoft.DotNet.Tools.Compiler -{ - internal class CommonCompilerOptionsCommandLine - { - public CommandOption DefineOption { get; set; } - public CommandOption SuppressWarningOption { get; set; } - public CommandOption LanguageVersionOption { get; set; } - public CommandOption PlatformOption { get; set; } - public CommandOption AllowUnsafeOption { get; set; } - public CommandOption WarningsAsErrorsOption { get; set; } - public CommandOption OptimizeOption { get; set; } - public CommandOption KeyFileOption { get; set; } - public CommandOption DelaySignOption { get; set; } - public CommandOption PublicSignOption { get; set; } - public CommandOption DebugTypeOption { get; set; } - public CommandOption EmitEntryPointOption { get; set; } - public CommandOption GenerateXmlDocumentationOption { get; set; } - public CommandOption AdditionalArgumentsOption { get; set; } - public CommandOption OutputNameOption { get; set; } - - public static CommonCompilerOptionsCommandLine AddOptions(CommandLineApplication app) - { - CommonCompilerOptionsCommandLine commandLineOptions = new CommonCompilerOptionsCommandLine(); - - commandLineOptions.DefineOption = - AddOption(app, DefineOptionName, "Preprocessor definitions", CommandOptionType.MultipleValue); - - commandLineOptions.SuppressWarningOption = - AddOption(app, SuppressWarningOptionName, "Suppresses the specified warning", CommandOptionType.MultipleValue); - - commandLineOptions.LanguageVersionOption = - AddOption(app, LanguageVersionOptionName, "The version of the language used to compile", CommandOptionType.SingleValue); - - commandLineOptions.PlatformOption = - AddOption(app, PlatformOptionName, "The target platform", CommandOptionType.SingleValue); - - commandLineOptions.AllowUnsafeOption = - AddOption(app, AllowUnsafeOptionName, "Allow unsafe code", CommandOptionType.BoolValue); - - commandLineOptions.WarningsAsErrorsOption = - AddOption(app, WarningsAsErrorsOptionName, "Turn all warnings into errors", CommandOptionType.BoolValue); - - commandLineOptions.OptimizeOption = - AddOption(app, OptimizeOptionName, "Enable compiler optimizations", CommandOptionType.BoolValue); - - commandLineOptions.KeyFileOption = - AddOption(app, KeyFileOptionName, "Path to file containing the key to strong-name sign the output assembly", CommandOptionType.SingleValue); - - commandLineOptions.DelaySignOption = - AddOption(app, DelaySignOptionName, "Delay-sign the output assembly", CommandOptionType.BoolValue); - - commandLineOptions.PublicSignOption = - AddOption(app, PublicSignOptionName, "Public-sign the output assembly", CommandOptionType.BoolValue); - - commandLineOptions.DebugTypeOption = - AddOption(app, DebugTypeOptionName, "The type of PDB to emit: portable or full", CommandOptionType.SingleValue); - - commandLineOptions.EmitEntryPointOption = - AddOption(app, EmitEntryPointOptionName, "Output an executable console program", CommandOptionType.BoolValue); - - commandLineOptions.GenerateXmlDocumentationOption = - AddOption(app, GenerateXmlDocumentationOptionName, "Generate XML documentation file", CommandOptionType.BoolValue); - - commandLineOptions.AdditionalArgumentsOption = - AddOption(app, AdditionalArgumentsOptionName, "Pass the additional argument directly to the compiler", CommandOptionType.MultipleValue); - - commandLineOptions.OutputNameOption = - AddOption(app, OutputNameOptionName, "Output assembly name", CommandOptionType.SingleValue); - - return commandLineOptions; - } - - private static CommandOption AddOption(CommandLineApplication app, string optionName, string description, CommandOptionType optionType) - { - string argSuffix = optionType == CommandOptionType.MultipleValue ? "..." : null; - string argString = optionType == CommandOptionType.BoolValue ? null : $" {argSuffix}"; - - return app.Option($"--{optionName}{argString}", description, optionType); - } - - public CommonCompilerOptions GetOptionValues() - { - return new CommonCompilerOptions() - { - Defines = DefineOption.Values, - SuppressWarnings = SuppressWarningOption.Values, - LanguageVersion = LanguageVersionOption.Value(), - Platform = PlatformOption.Value(), - AllowUnsafe = AllowUnsafeOption.BoolValue, - WarningsAsErrors = WarningsAsErrorsOption.BoolValue, - Optimize = OptimizeOption.BoolValue, - KeyFile = KeyFileOption.Value(), - DelaySign = DelaySignOption.BoolValue, - PublicSign = PublicSignOption.BoolValue, - DebugType = DebugTypeOption.Value(), - EmitEntryPoint = EmitEntryPointOption.BoolValue, - GenerateXmlDocumentation = GenerateXmlDocumentationOption.BoolValue, - AdditionalArguments = AdditionalArgumentsOption.Values, - OutputName = OutputNameOption.Value(), - }; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-csc/Program.cs b/src/dotnet/commands/dotnet-compile-csc/Program.cs deleted file mode 100644 index b369241a8..000000000 --- a/src/dotnet/commands/dotnet-compile-csc/Program.cs +++ /dev/null @@ -1,232 +0,0 @@ -// 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.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Compiler.Csc -{ - public class CompileCscCommand - { - private const int ExitFailed = 1; - - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - CommandLineApplication app = new CommandLineApplication(); - app.Name = "dotnet compile-csc"; - app.FullName = ".NET C# Compiler"; - app.Description = "C# Compiler for the .NET Platform"; - app.HandleResponseFiles = true; - app.HelpOption("-h|--help"); - - CommonCompilerOptionsCommandLine commonCompilerCommandLine = CommonCompilerOptionsCommandLine.AddOptions(app); - AssemblyInfoOptionsCommandLine assemblyInfoCommandLine = AssemblyInfoOptionsCommandLine.AddOptions(app); - - CommandOption tempOutput = app.Option("--temp-output ", "Compilation temporary directory", CommandOptionType.SingleValue); - CommandOption outputName = app.Option("--out ", "Name of the output assembly", CommandOptionType.SingleValue); - CommandOption references = app.Option("--reference ...", "Path to a compiler metadata reference", CommandOptionType.MultipleValue); - CommandOption analyzers = app.Option("--analyzer ...", "Path to an analyzer assembly", CommandOptionType.MultipleValue); - CommandOption resources = app.Option("--resource ...", "Resources to embed", CommandOptionType.MultipleValue); - CommandArgument sources = app.Argument("...", "Compilation sources", multipleValues: true); - - app.OnExecute(() => - { - if (!tempOutput.HasValue()) - { - Reporter.Error.WriteLine("Option '--temp-output' is required"); - return ExitFailed; - } - - CommonCompilerOptions commonOptions = commonCompilerCommandLine.GetOptionValues(); - - AssemblyInfoOptions assemblyInfoOptions = assemblyInfoCommandLine.GetOptionValues(); - - var translated = TranslateCommonOptions(commonOptions, outputName.Value()); - - var allArgs = new List(translated); - allArgs.AddRange(GetDefaultOptions()); - - // Generate assembly info - var assemblyInfo = Path.Combine(tempOutput.Value(), $"dotnet-compile.assemblyinfo.cs"); - - File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateCSharp(assemblyInfoOptions, sources.Values)); - - allArgs.Add($"\"{assemblyInfo}\""); - - if (outputName.HasValue()) - { - allArgs.Add($"-out:\"{outputName.Value()}\""); - } - - allArgs.AddRange(analyzers.Values.Select(a => $"-a:\"{a}\"")); - allArgs.AddRange(references.Values.Select(r => $"-r:\"{r}\"")); - - // Resource has two parts separated by a comma - // Only the first should be quoted. This is handled - // in dotnet-compile where the information is present. - allArgs.AddRange(resources.Values.Select(resource => $"-resource:{resource}")); - - allArgs.AddRange(sources.Values.Select(s => $"\"{s}\"")); - - var rsp = Path.Combine(tempOutput.Value(), "dotnet-compile-csc.rsp"); - - File.WriteAllLines(rsp, allArgs, Encoding.UTF8); - - // Execute CSC! - var result = RunCsc(new string[] { $"-noconfig", "@" + $"{rsp}" }) - .WorkingDirectory(Directory.GetCurrentDirectory()) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - }); - - try - { - return app.Execute(args); - } - catch (Exception ex) - { -#if DEBUG - Reporter.Error.WriteLine(ex.ToString()); -#else - Reporter.Error.WriteLine(ex.Message); -#endif - return ExitFailed; - } - } - - // TODO: Review if this is the place for default options - private static IEnumerable GetDefaultOptions() - { - var args = new List() - { - "-nostdlib", - "-nologo", - }; - - return args; - } - - private static IEnumerable TranslateCommonOptions(CommonCompilerOptions options, string outputName) - { - List commonArgs = new List(); - - if (options.Defines != null) - { - commonArgs.AddRange(options.Defines.Select(def => $"-d:{def}")); - } - - if (options.SuppressWarnings != null) - { - commonArgs.AddRange(options.SuppressWarnings.Select(w => $"-nowarn:{w}")); - } - - // Additional arguments are added verbatim - if (options.AdditionalArguments != null) - { - commonArgs.AddRange(options.AdditionalArguments); - } - - if (options.LanguageVersion != null) - { - commonArgs.Add($"-langversion:{GetLanguageVersion(options.LanguageVersion)}"); - } - - if (options.Platform != null) - { - commonArgs.Add($"-platform:{options.Platform}"); - } - - if (options.AllowUnsafe == true) - { - commonArgs.Add("-unsafe"); - } - - if (options.WarningsAsErrors == true) - { - commonArgs.Add("-warnaserror"); - } - - if (options.Optimize == true) - { - commonArgs.Add("-optimize"); - } - - if (options.KeyFile != null) - { - commonArgs.Add($"-keyfile:\"{options.KeyFile}\""); - - // If we're not on Windows, full signing isn't supported, so we'll - // public sign, unless the public sign switch has explicitly been - // set to false - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - options.PublicSign == null) - { - commonArgs.Add("-publicsign"); - } - } - - if (options.DelaySign == true) - { - commonArgs.Add("-delaysign"); - } - - if (options.PublicSign == true) - { - commonArgs.Add("-publicsign"); - } - - if (options.GenerateXmlDocumentation == true) - { - commonArgs.Add($"-doc:\"{Path.ChangeExtension(outputName, "xml")}\""); - } - - if (options.EmitEntryPoint != true) - { - commonArgs.Add("-t:library"); - } - - string debugType; - if (string.IsNullOrEmpty(options.DebugType)) - { - debugType = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "full" : "portable"; - } - else - { - debugType = options.DebugType; - } - - commonArgs.Add("-debug:" + debugType); - return commonArgs; - } - - private static string GetLanguageVersion(string languageVersion) - { - // project.json supports the enum that the roslyn APIs expose - if (languageVersion?.StartsWith("csharp", StringComparison.OrdinalIgnoreCase) == true) - { - // We'll be left with the number csharp6 = 6 - return languageVersion.Substring("csharp".Length); - } - return languageVersion; - } - - private static Command RunCsc(string[] cscArgs) - { - // Locate CoreRun - return Command.Create("csc.dll", cscArgs); - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/ArgValues.cs b/src/dotnet/commands/dotnet-compile-native/ArgValues.cs deleted file mode 100644 index 625ec65e9..000000000 --- a/src/dotnet/commands/dotnet-compile-native/ArgValues.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Collections.Generic; -using System.IO; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - internal class ArgValues - { - public string LogPath { get; set; } - public string InputManagedAssemblyPath { get; set; } - public string OutputDirectory { get; set; } - public string IntermediateDirectory { get; set; } - public BuildConfiguration? BuildConfiguration { get; set; } - public ArchitectureMode Architecture { get; set; } - public NativeIntermediateMode? NativeMode { get; set; } - public IEnumerable ReferencePaths { get; set; } - public IEnumerable IlcArgs { get; set; } - public IEnumerable LinkLibPaths { get; set; } - public string AppDepSDKPath { get; set; } - public string IlcPath { get; set; } - public string IlcSdkPath { get; set; } - public string CppCompilerFlags { get; set; } - - public bool IsHelp { get; set; } - public int ReturnCode { get; set; } - - public NativeCompileSettings GetNativeCompileSettings() - { - var config = NativeCompileSettings.Default; - - config.InputManagedAssemblyPath = InputManagedAssemblyPath; - config.Architecture = Architecture; - - if (BuildConfiguration.HasValue) - { - config.BuildType = BuildConfiguration.Value; - } - - if (!string.IsNullOrEmpty(OutputDirectory)) - { - config.OutputDirectory = OutputDirectory; - } - - if (!string.IsNullOrEmpty(IntermediateDirectory)) - { - config.IntermediateDirectory = IntermediateDirectory; - } - - if (NativeMode.HasValue) - { - config.NativeMode = NativeMode.Value; - } - - if (!string.IsNullOrEmpty(AppDepSDKPath)) - { - config.AppDepSDKPath = AppDepSDKPath; - } - - if (!string.IsNullOrEmpty(IlcPath)) - { - // We want a directory path. If the user gave us the exact path to the executable - // then we can be helpful and convert that to the directory rather than forcing - // the command to be re-typed. - string ilcDir = IlcPath; - if (File.Exists(IlcPath) && !Directory.Exists(IlcPath)) - { - string potentialIlcDir = Path.GetDirectoryName(IlcPath); - if (Directory.Exists(potentialIlcDir)) - { - ilcDir = potentialIlcDir; - } - } - config.IlcPath = ilcDir; - config.IlcSdkPath = ilcDir; - } - - if (!string.IsNullOrEmpty(IlcSdkPath)) - { - config.IlcSdkPath = IlcSdkPath; - } - - // Get the directory name to ensure there are no trailing slashes as they may conflict - // with the terminating " we suffix to account for paths with spaces in them. - char[] charsToTrim = {'\\', '/'}; - config.IlcSdkPath = config.IlcSdkPath.TrimEnd(charsToTrim); - - if (!string.IsNullOrEmpty(LogPath)) - { - config.LogPath = LogPath; - } - - if (IlcArgs != null) - { - config.IlcArgs = IlcArgs; - } - - if (!string.IsNullOrWhiteSpace(CppCompilerFlags)) - { - config.CppCompilerFlags = CppCompilerFlags; - } - - foreach (var reference in ReferencePaths) - { - config.AddReference(reference); - } - - foreach (var lib in LinkLibPaths) - { - config.AddLinkLibPath(lib); - } - - return config; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/ArgumentsParser.cs b/src/dotnet/commands/dotnet-compile-native/ArgumentsParser.cs deleted file mode 100644 index 1b64b294c..000000000 --- a/src/dotnet/commands/dotnet-compile-native/ArgumentsParser.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - internal static class ArgumentsParser - { - internal static ArgValues Parse(IEnumerable args) - { - CommandLineApplication app = new CommandLineApplication(); - app.HelpOption("-h|--help"); - - CommandOption output = app.Option("--output ", "Output Directory for native executable.", CommandOptionType.SingleValue); - CommandOption tempOutput = app.Option("--temp-output ", "Directory for intermediate files.", CommandOptionType.SingleValue); - - CommandOption configuration = app.Option("--configuration ", "debug/release build configuration. Defaults to debug.", CommandOptionType.SingleValue); - CommandOption mode = app.Option("--mode ", "Code Generation mode. Defaults to ryujit.", CommandOptionType.SingleValue); - - CommandOption reference = app.Option("--reference ...", "Use to specify Managed DLL references of the app.", CommandOptionType.MultipleValue); - - // Custom Extensibility Points to support CoreRT workflow TODO better descriptions - CommandOption ilcarg = app.Option("--ilcarg ...", "Use to specify custom arguments for the IL Compiler.", CommandOptionType.MultipleValue); - CommandOption ilcpath = app.Option("--ilcpath ", "Use to specify a custom build of IL Compiler.", CommandOptionType.SingleValue); - CommandOption ilcsdkpath = app.Option("ilcsdkpath ", "Use to specify a custom build of IL Compiler SDK", CommandOptionType.SingleValue); - - CommandOption linklib = app.Option("--linklib ...", "Use to link in additional static libs", CommandOptionType.MultipleValue); - - // TEMPORARY Hack until CoreRT compatible Framework Libs are available - CommandOption appdepsdk = app.Option("--appdepsdk ", "Use to plug in custom appdepsdk path", CommandOptionType.SingleValue); - - // Optional Log Path - CommandOption logpath = app.Option("--logpath ", "Use to dump Native Compilation Logs to a file.", CommandOptionType.SingleValue); - - // Optional flags to be passed to the native compiler - CommandOption cppcompilerflags = app.Option("--cppcompilerflags ", "Additional flags to be passed to the native compiler.", CommandOptionType.SingleValue); - - CommandArgument inputAssembly = app.Argument("INPUT_ASSEMBLY", "The managed input assembly to compile to native."); - - ArgValues argValues = new ArgValues(); - app.OnExecute(() => - { - if (string.IsNullOrEmpty(inputAssembly.Value)) - { - Reporter.Error.WriteLine("Input Assembly is a required parameter."); - return 1; - } - - if (configuration.HasValue()) - { - try - { - argValues.BuildConfiguration = EnumExtensions.Parse(configuration.Value()); - } - catch (ArgumentException) - { - Reporter.Error.WriteLine($"Invalid Configuration Option: {configuration}"); - return 1; - } - } - - if (mode.HasValue()) - { - try - { - argValues.NativeMode = EnumExtensions.Parse(mode.Value()); - } - catch (ArgumentException) - { - Reporter.Error.WriteLine($"Invalid Mode Option: {mode}"); - return 1; - } - } - - argValues.InputManagedAssemblyPath = inputAssembly.Value; - argValues.OutputDirectory = output.Value(); - argValues.IntermediateDirectory = tempOutput.Value(); - argValues.Architecture = ArchitectureMode.x64; - argValues.ReferencePaths = reference.Values; - argValues.IlcArgs = ilcarg.Values.Select(s => - { - if (!s.StartsWith("\"") || !s.EndsWith("\"")) - { - throw new ArgumentException("--ilcarg must be specified in double quotes", "ilcarg"); - } - return s.Substring(1, s.Length - 2); - }); - argValues.IlcPath = ilcpath.Value(); - argValues.IlcSdkPath = ilcsdkpath.Value(); - argValues.LinkLibPaths = linklib.Values; - argValues.AppDepSDKPath = appdepsdk.Value(); - argValues.LogPath = logpath.Value(); - argValues.CppCompilerFlags = cppcompilerflags.Value(); - - Reporter.Output.WriteLine($"Input Assembly: {inputAssembly}"); - - return 0; - }); - - try - { - argValues.ReturnCode = app.Execute(args.ToArray()); - } - catch (Exception ex) - { -#if DEBUG - Console.Error.WriteLine(ex); -#else - Console.Error.WriteLine(ex.Message); -#endif - argValues.ReturnCode = 1; - } - - if (argValues.ReturnCode != 0) - { - argValues.IsHelp = true; - } - - return argValues; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/DirectoryExtensions.cs b/src/dotnet/commands/dotnet-compile-native/DirectoryExtensions.cs deleted file mode 100644 index 4b84e2eba..000000000 --- a/src/dotnet/commands/dotnet-compile-native/DirectoryExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.IO; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public static class DirectoryExtensions - { - internal static void CleanOrCreateDirectory(string path) - { - if (Directory.Exists(path)) - { - try - { - Directory.Delete(path, recursive: true); - Directory.CreateDirectory(path); - } - catch (Exception e) - { - Console.WriteLine("Unable to remove directory: " + path); - Console.WriteLine(e.Message); - } - } - else - { - Directory.CreateDirectory(path); - } - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/EnumExtensions.cs b/src/dotnet/commands/dotnet-compile-native/EnumExtensions.cs deleted file mode 100644 index a0f345a0c..000000000 --- a/src/dotnet/commands/dotnet-compile-native/EnumExtensions.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public static class EnumExtensions - { - internal static T Parse(string value) - { - return (T)Enum.Parse(typeof(T), value, true); - } - } - -} diff --git a/src/dotnet/commands/dotnet-compile-native/ILCompilerInvoker.cs b/src/dotnet/commands/dotnet-compile-native/ILCompilerInvoker.cs deleted file mode 100644 index b4183c321..000000000 --- a/src/dotnet/commands/dotnet-compile-native/ILCompilerInvoker.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class ILCompilerInvoker - { - private static readonly string HostExeName = "corerun" + Constants.ExeSuffix; - private static readonly string ILCompiler = "ilc.exe"; - - private IEnumerable Args; - private NativeCompileSettings config; - - private static readonly Dictionary ModeOutputExtensionMap = new Dictionary - { - { NativeIntermediateMode.cpp, ".cpp" }, - { NativeIntermediateMode.ryujit, ".obj" } - }; - - public ILCompilerInvoker(NativeCompileSettings config) - { - this.config = config; - InitializeArgs(config); - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - // Input File - var inputFilePath = config.InputManagedAssemblyPath; - argsList.Add($"{inputFilePath}"); - - // System.Private.* References - var coreLibsPath = Path.Combine(config.IlcSdkPath, "sdk"); - foreach (var reference in Directory.EnumerateFiles(coreLibsPath, "*.dll")) - { - argsList.Add($"-r:{reference}"); - } - - // AppDep References - foreach (var reference in config.ReferencePaths) - { - argsList.Add($"-r:{reference}"); - } - - // Set Output DetermineOutFile - var outFile = DetermineOutputFile(config); - argsList.Add($"-o:{outFile}"); - - // Add Mode Flag TODO - if (config.NativeMode == NativeIntermediateMode.cpp) - { - argsList.Add("--cpp"); - } - - // Custom Ilc Args support - foreach (var ilcArg in config.IlcArgs) - { - argsList.Add(ilcArg); - } - - Args = argsList; - } - - public int Invoke() - { - // Check if ILCompiler is present - var ilcExePath = Path.Combine(config.IlcPath, ILCompiler); - if (!File.Exists(ilcExePath)) - { - throw new FileNotFoundException("Unable to find ILCompiler at " + ilcExePath); - } - - // Write the response file - var intermediateDirectory = config.IntermediateDirectory; - var rsp = Path.Combine(intermediateDirectory, "dotnet-compile-native-ilc.rsp"); - File.WriteAllLines(rsp, Args, Encoding.UTF8); - - var hostPath = Path.Combine(config.IlcPath, HostExeName); - var result = Command.Create(hostPath, new string[] { ilcExePath, "@" + $"{rsp}" }) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var extension = ModeOutputExtensionMap[config.NativeMode]; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outFile = Path.Combine(intermediateDirectory, filename + extension); - - return outFile; - } - - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IPlatformNativeStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IPlatformNativeStep.cs deleted file mode 100644 index 1bc1c668a..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IPlatformNativeStep.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public interface IPlatformNativeStep - { - int Invoke(); - string DetermineOutputFile(NativeCompileSettings config); - bool CheckPreReqs(); - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IntermediateCompiler.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IntermediateCompiler.cs deleted file mode 100644 index b11657e8e..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/IntermediateCompiler.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class IntermediateCompiler - { - public static IntermediateCompiler Create(NativeCompileSettings config) - { - var platformStepList = CreatePlatformNativeSteps(config); - - return new IntermediateCompiler(platformStepList); - } - - private static List CreatePlatformNativeSteps(NativeCompileSettings config) - { - if (config.NativeMode == NativeIntermediateMode.cpp) - { - return CreateCppSteps(config); - } - else if (config.NativeMode == NativeIntermediateMode.ryujit) - { - return CreateJitSteps(config); - } - else - { - throw new Exception("Unrecognized Mode"); - } - } - - private static List CreateCppSteps(NativeCompileSettings config) - { - var stepList = new List(); - - if (config.OS == OSMode.Windows) - { - stepList.Add(new WindowsCppCompileStep(config)); - stepList.Add(new WindowsLinkStep(config)); - } - else if (config.OS == OSMode.Linux) - { - stepList.Add(new LinuxCppCompileStep(config)); - } - else if (config.OS == OSMode.Mac) - { - stepList.Add(new MacCppCompileStep(config)); - } - else - { - throw new Exception("Unrecognized Operating System. Unable to create Intermediate Compiler."); - } - - return stepList; - } - - private static List CreateJitSteps(NativeCompileSettings config) - { - var stepList = new List(); - - if (config.OS == OSMode.Windows) - { - stepList.Add(new WindowsLinkStep(config)); - } - else if (config.OS == OSMode.Linux) - { - stepList.Add(new LinuxRyuJitCompileStep(config)); - } - else if (config.OS == OSMode.Mac) - { - stepList.Add(new MacRyuJitCompileStep(config)); - } - else - { - throw new Exception("Unrecognized Operating System. Unable to create Intermediate Compiler."); - } - - return stepList; - } - - private List StepList { get; set; } - - private IntermediateCompiler(List stepList) - { - if (stepList == null || stepList.Count < 1) - { - throw new Exception("Intermediate step list must not be empty."); - } - - this.StepList = stepList; - } - - public int Invoke() - { - foreach(var step in StepList) - { - int result = step.Invoke(); - - if (result != 0) - { - return result; - } - } - - return 0; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - return config.DetermineFinalOutputPath(); - } - - public bool CheckPreReqs() - { - var check = true; - - foreach(var step in StepList) - { - check = check && step.CheckPreReqs(); - } - - return check; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxCppCompileStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxCppCompileStep.cs deleted file mode 100644 index 6197c0adc..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxCppCompileStep.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class LinuxCppCompileStep : IPlatformNativeStep - { - private const string CompilerName = "clang-3.5"; - private const string InputExtension = ".cpp"; - - // TODO: debug/release support - private readonly string [] _cLibsFlags = { "-lm", "-ldl"}; - private readonly string [] _cflags = { "-g", "-lstdc++", "-lrt", "-Wno-invalid-offsetof", "-lpthread"}; - - public IEnumerable CompilerArgs { get; set; } - - private readonly string[] _ilcSdkLibs = - { - "libbootstrappercpp.a", - "libPortableRuntime.a", - "libSystem.Private.CoreLib.Native.a" - }; - - private readonly string[] _appdeplibs = - { - "System.Native.a" - }; - - public LinuxCppCompileStep(NativeCompileSettings config) - { - InitializeArgs(config); - } - - public int Invoke() - { - var result = InvokeCompiler(); - if (result != 0) - { - Reporter.Error.WriteLine("Compilation of intermediate files failed."); - } - - return result; - } - - public bool CheckPreReqs() - { - // TODO check for clang - return true; - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - // Flags - argsList.AddRange(_cflags); - - var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc"); - argsList.Add("-I"); - argsList.Add($"{ilcSdkIncPath}"); - - // Input File - var inCppFile = DetermineInFile(config); - argsList.Add(inCppFile); - - // Pass the optional native compiler flags if specified - if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) - { - argsList.Add(config.CppCompilerFlags); - } - - // ILC SDK Libs - var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); - argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib))); - - // AppDep Libs - var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04/x64"); - argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib))); - - argsList.AddRange(_cLibsFlags); - - // Output - var libOut = DetermineOutputFile(config); - argsList.Add($"-o"); - argsList.Add($"{libOut}"); - - CompilerArgs = argsList; - } - - private int InvokeCompiler() - { - var result = Command.Create(CompilerName, CompilerArgs) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - } - - private string DetermineInFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var infile = Path.Combine(intermediateDirectory, filename + InputExtension); - - return infile; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.OutputDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outfile = Path.Combine(intermediateDirectory, filename); - - return outfile; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxRyuJitCompileStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxRyuJitCompileStep.cs deleted file mode 100644 index bf54a1d0b..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Linux/LinuxRyuJitCompileStep.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using Microsoft.DotNet.Cli.Utils; -using System.Linq; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class LinuxRyuJitCompileStep : IPlatformNativeStep - { - private const string CompilerName = "clang-3.5"; - private const string InputExtension = ".obj"; - private const string CompilerOutputExtension = ""; - - public List CompilerArgs { get; set; } - - // TODO: debug/release support - private readonly string[] _cflags = {"-lstdc++", "-lpthread", "-ldl", "-lm", "-lrt"}; - private readonly string[] _ilcSdkLibs = - { - "libbootstrapper.a", - "libRuntime.a", - "libSystem.Private.CoreLib.Native.a" - }; - - private readonly string[] _appdeplibs = - { - "System.Native.a" - }; - - public LinuxRyuJitCompileStep(NativeCompileSettings config) - { - InitializeArgs(config); - } - - public int Invoke() - { - var result = InvokeCompiler(); - if (result != 0) - { - Reporter.Error.WriteLine("Compilation of intermediate files failed."); - } - - return result; - } - - public bool CheckPreReqs() - { - // TODO check for clang - return true; - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - // Flags - argsList.AddRange(_cflags); - - // Input File - var inLibFile = DetermineInFile(config); - argsList.Add(inLibFile); - - // Pass the optional native compiler flags if specified - if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) - { - argsList.Add(config.CppCompilerFlags); - } - - // ILC SDK Libs - var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); - argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib))); - - // Optional linker script - var linkerScriptFile = Path.Combine(ilcSdkLibPath, "linkerscript"); - if (File.Exists(linkerScriptFile)) - { - argsList.Add(linkerScriptFile); - } - - // AppDep Libs - var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04", config.Architecture.ToString()); - argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib))); - - // Output - var libOut = DetermineOutputFile(config); - argsList.Add($"-o"); - argsList.Add($"{libOut}"); - - CompilerArgs = argsList; - } - - private int InvokeCompiler() - { - var result = Command.Create(CompilerName, CompilerArgs) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - } - - private string DetermineInFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var infile = Path.Combine(intermediateDirectory, filename + InputExtension); - - return infile; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.OutputDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outfile = Path.Combine(intermediateDirectory, filename + CompilerOutputExtension); - - return outfile; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacCppCompileStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacCppCompileStep.cs deleted file mode 100644 index 654cdeee9..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacCppCompileStep.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class MacCppCompileStep : IPlatformNativeStep - { - private const string CompilerName = "clang"; - public const string InputExtension = ".cpp"; - - // TODO: debug/release support - private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-lpthread"}; - - // Link to iconv APIs - private const string LibFlags = "-liconv"; - - private readonly string[] _ilcSdkLibs = - { - "libbootstrappercpp.a", - "libPortableRuntime.a", - "libSystem.Private.CoreLib.Native.a" - }; - - private readonly string[] _appdeplibs = - { - "System.Native.a" - }; - - - private List CompilerArgs { get; set; } - - public MacCppCompileStep(NativeCompileSettings config) - { - InitializeArgs(config); - } - - public int Invoke() - { - var result = InvokeCompiler(); - if (result != 0) - { - Reporter.Error.WriteLine("Compilation of intermediate files failed."); - } - - return result; - } - - public bool CheckPreReqs() - { - // TODO check for clang - return true; - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - // Flags - argsList.AddRange(_cflags); - - var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc"); - argsList.Add("-I"); - argsList.Add($"{ilcSdkIncPath}"); - - // Input File - var inCppFile = DetermineInFile(config); - argsList.Add(inCppFile); - - // Lib flags - argsList.Add(LibFlags); - - // Pass the optional native compiler flags if specified - if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) - { - argsList.Add(config.CppCompilerFlags); - } - - // ILC SDK Libs - var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); - foreach (var libPath in _ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib))) - { - // Forward the library to linked to the linker - argsList.Add(libPath); - } - - // AppDep Libs - var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10/x64"); - foreach (var appDeplibPath in _appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib))) - { - argsList.Add(appDeplibPath); - } - - // Output - var libOut = DetermineOutputFile(config); - argsList.Add($"-o"); - argsList.Add($"{libOut}"); - - CompilerArgs = argsList; - } - - private int InvokeCompiler() - { - var result = Command.Create(CompilerName, CompilerArgs) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - } - - private string DetermineInFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var infile = Path.Combine(intermediateDirectory, filename + InputExtension); - - return infile; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.OutputDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outfile = Path.Combine(intermediateDirectory, filename); - - return outfile; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacRyuJitCompileStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacRyuJitCompileStep.cs deleted file mode 100644 index 0076ddb27..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Mac/MacRyuJitCompileStep.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using Microsoft.DotNet.Cli.Utils; -using System.Linq; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class MacRyuJitCompileStep : IPlatformNativeStep - { - private const string CompilerName = "clang"; - private const string InputExtension = ".obj"; - - private const string CompilerOutputExtension = ""; - - private IEnumerable CompilerArgs; - - // TODO: debug/release support - private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-lpthread", "-ldl", "-lm", "-liconv" }; - - private readonly string[] _ilcSdkLibs = - { - "libbootstrapper.a", - "libRuntime.a", - "libSystem.Private.CoreLib.Native.a" - }; - - private readonly string[] appdeplibs = - { - "System.Native.a" - }; - - public MacRyuJitCompileStep(NativeCompileSettings config) - { - InitializeArgs(config); - } - - public int Invoke() - { - var result = InvokeCompiler(); - if (result != 0) - { - Reporter.Error.WriteLine("Compilation of intermediate files failed."); - } - - return result; - } - - public bool CheckPreReqs() - { - // TODO check for clang - return true; - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - // Flags - argsList.AddRange(_cflags); - - // Pass the optional native compiler flags if specified - if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) - { - argsList.Add(config.CppCompilerFlags); - } - - // Input File - var inLibFile = DetermineInFile(config); - argsList.Add(inLibFile); - - // ILC SDK Libs - var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); - argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib))); - - // Optional linker script - var linkerScriptFile = Path.Combine(ilcSdkLibPath, "linkerscript"); - if (File.Exists(linkerScriptFile)) - { - argsList.Add(linkerScriptFile); - } - - // AppDep Libs - var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10", config.Architecture.ToString()); - argsList.AddRange(appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib))); - - // Output - var libOut = DetermineOutputFile(config); - argsList.Add($"-o"); - argsList.Add($"{libOut}"); - - this.CompilerArgs = argsList; - } - - private int InvokeCompiler() - { - var result = Command.Create(CompilerName, CompilerArgs) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - } - - private string DetermineInFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var infile = Path.Combine(intermediateDirectory, filename + InputExtension); - - return infile; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.OutputDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outfile = Path.Combine(intermediateDirectory, filename + CompilerOutputExtension); - - return outfile; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCommon.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCommon.cs deleted file mode 100644 index a48a385a5..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCommon.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - class WindowsCommon - { - internal static int SetVCVars() - { - // TODO: This is not working because it sets the environment variables in a child process - // For now get around this by using x86_amd64 cross tools - - // var commonToolsPath = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); - - // var scriptPath = Path.Combine(commonToolsPath, "..\\..\\VC\\vcvarsall.bat"); - // var scriptArgs = "x86_amd64"; - - // var result = Command.Create(scriptPath, scriptArgs) - // .ForwardStdErr() - // .ForwardStdOut() - // .Execute(); - - // return result.ExitCode; - return 0; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCppCompileStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCppCompileStep.cs deleted file mode 100644 index 1be36ae63..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsCppCompileStep.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class WindowsCppCompileStep : IPlatformNativeStep - { - //TODO support x86 - private readonly string CompilerName = "cl.exe"; - - private readonly string VSBin = "..\\..\\VC\\bin\\amd64"; - private readonly string InputExtension = ".cpp"; - - private readonly string CompilerOutputExtension = ".obj"; - - private static readonly string[] DefaultCompilerOptions = { "/nologo", "/W3", "/GS", "/DCPPCODEGEN", "/EHs", "/MT", "/Zi" }; - - private static readonly Dictionary ConfigurationCompilerOptionsMap = new Dictionary - { - { BuildConfiguration.debug, new string[] { "/Od" } }, - { BuildConfiguration.release, new string[] { "/O2" } } - }; - - private IEnumerable CompilerArgs { get; set; } - - private NativeCompileSettings config; - - public WindowsCppCompileStep(NativeCompileSettings config) - { - this.config = config; - InitializeArgs(config); - } - - public int Invoke() - { - var result = WindowsCommon.SetVCVars(); - if (result != 0) - { - Reporter.Error.WriteLine("vcvarsall.bat invocation failed."); - return result; - } - - result = InvokeCompiler(); - if (result != 0) - { - Reporter.Error.WriteLine("Compilation of intermediate files failed."); - } - - return result; - } - - public bool CheckPreReqs() - { - var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); - return !string.IsNullOrEmpty(vcInstallDir); - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - // Use a Custom Link Step - argsList.Add("/c"); - - // Add Includes - var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc"); - argsList.Add("/I"); - argsList.Add($"{ilcSdkIncPath}"); - - argsList.AddRange(DefaultCompilerOptions); - - // Configuration Based Compiler Options - argsList.AddRange(ConfigurationCompilerOptionsMap[config.BuildType]); - - // Pass the optional native compiler flags if specified - if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) - { - argsList.Add(config.CppCompilerFlags); - } - - // Output - var objOut = DetermineOutputFile(config); - argsList.Add($"/Fo{objOut}"); - - // Input File - var inCppFile = DetermineInFile(config); - argsList.Add($"{inCppFile}"); - - this.CompilerArgs = argsList; - } - - private int InvokeCompiler() - { - var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); - var compilerPath = Path.Combine(vcInstallDir, VSBin, CompilerName); - - var result = Command.Create(compilerPath, CompilerArgs.ToArray()) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - - return result.ExitCode; - } - - private string DetermineInFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var infile = Path.Combine(intermediateDirectory, filename + InputExtension); - - return infile; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outfile = Path.Combine(intermediateDirectory, filename + CompilerOutputExtension); - - return outfile; - } - - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsLinkStep.cs b/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsLinkStep.cs deleted file mode 100644 index 07b340695..000000000 --- a/src/dotnet/commands/dotnet-compile-native/IntermediateCompilation/Windows/WindowsLinkStep.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class WindowsLinkStep : IPlatformNativeStep - { - private readonly string LinkerName = "link.exe"; - private readonly string LinkerOutputExtension = ".exe"; - private readonly string VSBin = "..\\..\\VC\\bin\\amd64"; - - private readonly string InputExtension = ".obj"; - - private static readonly string[] DefaultLinkerOptions = new string[] { "/NOLOGO", "/DEBUG", "/MANIFEST:NO" }; - - private static readonly Dictionary ConfigurationLinkerOptionsMap = new Dictionary - { - { BuildConfiguration.debug, new string[] { } }, - { BuildConfiguration.release, new string[] { "/INCREMENTAL:NO", "/OPT:REF", "/OPT:ICF" } } - }; - - private static readonly Dictionary IlcSdkLibMap = new Dictionary - { - { NativeIntermediateMode.cpp, new string[] { "PortableRuntime.lib", "bootstrappercpp.lib" } }, - { NativeIntermediateMode.ryujit, new string[] { "Runtime.lib", "bootstrapper.lib" } } - }; - - private static readonly string[] ConstantLinkLibs = new string[] - { - "kernel32.lib", - "user32.lib", - "gdi32.lib", - "winspool.lib", - "comdlg32.lib", - "advapi32.lib", - "shell32.lib", - "ole32.lib", - "oleaut32.lib", - "uuid.lib", - "odbc32.lib", - "odbccp32.lib" - }; - - private IEnumerable Args { get; set; } - private NativeCompileSettings config; - - public WindowsLinkStep(NativeCompileSettings config) - { - this.config = config; - InitializeArgs(config); - } - - public int Invoke() - { - var result = WindowsCommon.SetVCVars(); - if (result != 0) - { - Reporter.Error.WriteLine("vcvarsall.bat invocation failed."); - return result; - } - - result = InvokeLinker(); - if (result != 0) - { - Reporter.Error.WriteLine("Linking of intermediate files failed."); - } - return result; - } - - public bool CheckPreReqs() - { - var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); - return !string.IsNullOrEmpty(vcInstallDir); - } - - private void InitializeArgs(NativeCompileSettings config) - { - var argsList = new List(); - - argsList.AddRange(DefaultLinkerOptions); - - // Configuration Based Linker Options - argsList.AddRange(ConfigurationLinkerOptionsMap[config.BuildType]); - - //Output - var outFile = DetermineOutputFile(config); - argsList.Add($"/out:{outFile}"); - - // Constant Libs - foreach (var lib in ConstantLinkLibs) - { - argsList.Add(lib); - } - - // ILC SDK Libs - var SDKLibs = IlcSdkLibMap[config.NativeMode]; - var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); - foreach (var lib in SDKLibs) - { - var sdkLibPath = Path.Combine(IlcSdkLibPath, lib); - argsList.Add($"{sdkLibPath}"); - } - - // Link Libs - foreach(var path in config.LinkLibPaths){ - argsList.Add($"{path}"); - } - - //arch - argsList.Add($"/MACHINE:{config.Architecture}"); - - //Input Obj file - var inputFile = DetermineInputFile(config); - argsList.Add($"{inputFile}"); - - this.Args = argsList; - } - - private int InvokeLinker() - { - var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); - var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName); - - var result = Command.Create(linkerPath, Args.ToArray()) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - return result.ExitCode; - } - - public string DetermineOutputFile(NativeCompileSettings config) - { - var outputDirectory = config.OutputDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var outFile = Path.Combine(outputDirectory, filename + LinkerOutputExtension); - - return outFile; - } - - private string DetermineInputFile(NativeCompileSettings config) - { - var intermediateDirectory = config.IntermediateDirectory; - - var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath); - - var infile = Path.Combine(intermediateDirectory, filename + InputExtension); - - return infile; - } - - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/NativeCompileSettings.cs b/src/dotnet/commands/dotnet-compile-native/NativeCompileSettings.cs deleted file mode 100644 index ee260ab23..000000000 --- a/src/dotnet/commands/dotnet-compile-native/NativeCompileSettings.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class NativeCompileSettings - { - private const BuildConfiguration DefaultBuiltType = BuildConfiguration.debug; - private const NativeIntermediateMode DefaultNativeModel = NativeIntermediateMode.ryujit; - private const ArchitectureMode DefaultArchitectureMode = ArchitectureMode.x64; - - private string _inputManagedAssemblyPath; - private string _appDepSdkPath; - private string _ilcPath; - private string _ilcSdkPath; - private string _outputDirectory; - private string _intermediateDirectory; - private string _logPath; - private IEnumerable _ilcArgs; - private readonly Dictionary _referencePaths; - private readonly List _linkLibPaths; - private string _cppCompilerFlags; - - public string LogPath - { - get { return _logPath; } - set { _logPath = Path.GetFullPath(value); } - } - - public string InputManagedAssemblyPath - { - get - { - return _inputManagedAssemblyPath; - } - set - { - if(!File.Exists(value)) - { - throw new Exception($"Could not find the input managed assembly: {value}"); - } - - _inputManagedAssemblyPath = Path.GetFullPath(value); - } - } - - public string OutputDirectory - { - get - { - return _outputDirectory ?? GetDefaultOutputDirectory(); - } - set - { - _outputDirectory = value; - } - } - - public string IntermediateDirectory - { - get - { - return _intermediateDirectory ?? GetDefaultIntermediateDirectory(); - } - set - { - _intermediateDirectory = value; - } - } - - public BuildConfiguration BuildType { get; set; } - - public ArchitectureMode Architecture { get; set; } - public NativeIntermediateMode NativeMode { get; set; } - public OSMode OS { get; set; } - - public IEnumerable ReferencePaths - { - get - { - return _referencePaths.Values; - } - } - - // Optional Customization Points (Can be null) - public IEnumerable IlcArgs - { - get { return _ilcArgs; } - set { _ilcArgs = value; } - } - public IEnumerable LinkLibPaths => _linkLibPaths; - - // Required Customization Points (Must have default) - public string AppDepSDKPath { - get - { - return _appDepSdkPath; - } - set - { - if (!Directory.Exists(value)) - { - throw new Exception($"AppDepSDK Directory does not exist: {value}."); - } - - _appDepSdkPath = value; - } - } - - public string IlcPath - { - get - { - return _ilcPath; - } - set - { - if (!Directory.Exists(value)) - { - throw new Exception($"ILC Directory does not exist: {value}."); - } - - _ilcPath = value; - } - } - - public string IlcSdkPath - { - get - { - return _ilcSdkPath; - } - set - { - if (!Directory.Exists(value)) - { - throw new Exception($"ILC SDK Directory does not exist: {value}."); - } - - _ilcSdkPath = value; - } - } - - public string CppCompilerFlags - { - get - { - return _cppCompilerFlags; - } - set - { - _cppCompilerFlags = value; - } - } - - private NativeCompileSettings() - { - _linkLibPaths = new List(); - - IlcPath = AppContext.BaseDirectory; - - // By default, ILC SDK Path is assumed to be the same folder as ILC path - IlcSdkPath = IlcPath; - Architecture = DefaultArchitectureMode; - BuildType = DefaultBuiltType; - NativeMode = DefaultNativeModel; - AppDepSDKPath = Path.Combine(AppContext.BaseDirectory, "appdepsdk"); - _referencePaths = new Dictionary(); - foreach (var file in Directory.EnumerateFiles(AppDepSDKPath, "*.dll")) - { - _referencePaths.Add(Path.GetFileName(file), file); - } - } - - public static NativeCompileSettings Default - { - get - { - var defaultNativeCompileSettings = new NativeCompileSettings - { - OS = RuntimeInformationExtensions.GetCurrentOS() - }; - - return defaultNativeCompileSettings; - } - } - - public string DetermineFinalOutputPath() - { - var outputDirectory = OutputDirectory; - - var filename = Path.GetFileNameWithoutExtension(InputManagedAssemblyPath); - - var outFile = Path.Combine(outputDirectory, filename + Constants.ExeSuffix); - - return outFile; - } - - public void AddReference(string reference) - { - var path = Path.GetFullPath(reference); - var simpleName = Path.GetFileName(path); - if (!_referencePaths.ContainsKey(simpleName)) - { - _referencePaths.Add(simpleName, path); - } - } - - public void AddLinkLibPath(string linkLibPath) - { - _linkLibPaths.Add(linkLibPath); - } - - private string GetDefaultOutputDirectory() - { - return GetOutputDirectory(Constants.BinDirectoryName); - } - - private string GetDefaultIntermediateDirectory() - { - return GetOutputDirectory(Constants.ObjDirectoryName); - } - - private string GetOutputDirectory(string beginsWith) - { - var dir = Path.Combine(beginsWith, Architecture.ToString(), BuildType.ToString(), "native"); - - return Path.GetFullPath(dir); - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/NativeCompiler.cs b/src/dotnet/commands/dotnet-compile-native/NativeCompiler.cs deleted file mode 100644 index d2df03448..000000000 --- a/src/dotnet/commands/dotnet-compile-native/NativeCompiler.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class NativeCompiler - { - public static NativeCompiler Create(NativeCompileSettings config) - { - var invoker = new ILCompilerInvoker(config); - var intCompiler = IntermediateCompiler.Create(config); - - var nc = new NativeCompiler() - { - invoker = invoker, - intermediateCompiler = intCompiler - }; - - return nc; - } - - private ILCompilerInvoker invoker; - private IntermediateCompiler intermediateCompiler; - - public bool CompileToNative(NativeCompileSettings config) - { - int result = invoker.Invoke(); - if(result != 0) - { - return false; - } - - result = intermediateCompiler.Invoke(); - if (result != 0) - { - return false; - } - - return true; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-native/Program.cs b/src/dotnet/commands/dotnet-compile-native/Program.cs deleted file mode 100644 index c43a289a5..000000000 --- a/src/dotnet/commands/dotnet-compile-native/Program.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.IO; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public class CompileNativeCommand - { - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - return ExecuteApp(args); - } - - private static int ExecuteApp(string[] args) - { - // Support Response File - foreach(var arg in args) - { - if(arg.Contains(".rsp")) - { - args = ParseResponseFile(arg); - - if (args == null) - { - return 1; - } - } - } - - try - { - var cmdLineArgs = ArgumentsParser.Parse(args); - - if (cmdLineArgs.IsHelp) return cmdLineArgs.ReturnCode; - - var config = cmdLineArgs.GetNativeCompileSettings(); - - DirectoryExtensions.CleanOrCreateDirectory(config.OutputDirectory); - DirectoryExtensions.CleanOrCreateDirectory(config.IntermediateDirectory); - - var nativeCompiler = NativeCompiler.Create(config); - - var result = nativeCompiler.CompileToNative(config); - - return result ? 0 : 1; - } - catch (Exception ex) - { -#if DEBUG - Console.WriteLine(ex); -#else - Reporter.Error.WriteLine(ex.Message); -#endif - return 1; - } - } - - private static string[] ParseResponseFile(string rspPath) - { - if (!File.Exists(rspPath)) - { - Reporter.Error.WriteLine("Invalid Response File Path"); - return null; - } - - string content; - try - { - content = File.ReadAllText(rspPath); - } - catch (Exception) - { - Reporter.Error.WriteLine("Unable to Read Response File"); - return null; - } - - var nArgs = content.Split(new [] {"\r\n", "\n"}, StringSplitOptions.RemoveEmptyEntries); - return nArgs; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/RuntimeExtensions.cs b/src/dotnet/commands/dotnet-compile-native/RuntimeExtensions.cs deleted file mode 100644 index 452f23230..000000000 --- a/src/dotnet/commands/dotnet-compile-native/RuntimeExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - static class RuntimeExtensions - { - internal static ArchitectureMode GetCurrentArchitecture() - { -#if NET451 - return Environment.Is64BitProcess ? ArchitectureMode.x64 : ArchitectureMode.x86; -#else - return IntPtr.Size == 8 ? ArchitectureMode.x64 : ArchitectureMode.x86; -#endif - } - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/RuntimeInformationExtensions.cs b/src/dotnet/commands/dotnet-compile-native/RuntimeInformationExtensions.cs deleted file mode 100644 index c55e7f527..000000000 --- a/src/dotnet/commands/dotnet-compile-native/RuntimeInformationExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - static class RuntimeInformationExtensions - { - internal static OSMode GetCurrentOS() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return OSMode.Windows; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return OSMode.Mac; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return OSMode.Linux; - } - else - { - throw new Exception("Unrecognized OS. dotnet-compile-native is compatible with Windows, OSX, and Linux"); - } - } - - } -} diff --git a/src/dotnet/commands/dotnet-compile-native/enums/ArchitectureMode.cs b/src/dotnet/commands/dotnet-compile-native/enums/ArchitectureMode.cs deleted file mode 100644 index a9253bf66..000000000 --- a/src/dotnet/commands/dotnet-compile-native/enums/ArchitectureMode.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public enum ArchitectureMode - { - x86, - x64 - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-native/enums/BuildConfiguration.cs b/src/dotnet/commands/dotnet-compile-native/enums/BuildConfiguration.cs deleted file mode 100644 index 621581baf..000000000 --- a/src/dotnet/commands/dotnet-compile-native/enums/BuildConfiguration.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public enum BuildConfiguration - { - debug, - release - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-native/enums/NativeIntermediateMode.cs b/src/dotnet/commands/dotnet-compile-native/enums/NativeIntermediateMode.cs deleted file mode 100644 index 961ae5271..000000000 --- a/src/dotnet/commands/dotnet-compile-native/enums/NativeIntermediateMode.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public enum NativeIntermediateMode - { - cpp, - ryujit, - custom - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile-native/enums/OSMode.cs b/src/dotnet/commands/dotnet-compile-native/enums/OSMode.cs deleted file mode 100644 index ff5a5af2f..000000000 --- a/src/dotnet/commands/dotnet-compile-native/enums/OSMode.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.DotNet.Tools.Compiler.Native -{ - public enum OSMode - { - Linux, - Windows, - Mac - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile/CanonicalError.cs b/src/dotnet/commands/dotnet-compile/CanonicalError.cs deleted file mode 100644 index e9e9d357b..000000000 --- a/src/dotnet/commands/dotnet-compile/CanonicalError.cs +++ /dev/null @@ -1,418 +0,0 @@ -// 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.Globalization; -using System.Text.RegularExpressions; - -// https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/MSBuildTask/CanonicalError.cs - -namespace Microsoft.DotNet.Tools.Compiler -{ - /// - /// Functions for dealing with the specially formatted errors returned by - /// build tools. - /// - /// - /// Various tools produce and consume CanonicalErrors in various formats. - /// - /// DEVENV Format When Clicking on Items in the Output Window - /// (taken from env\msenv\core\findutil.cpp ParseLocation function) - /// - /// v:\dir\file.ext (loc) : msg - /// \\server\share\dir\file.ext(loc):msg - /// url - /// - /// loc: - /// (line) - /// (line-line) - /// (line,col) - /// (line,col-col) - /// (line,col,len) - /// (line,col,line,col) - /// - /// DevDiv Build Process - /// (taken from tools\devdiv2.def) - /// - /// To echo warnings and errors to the build console, the - /// "description block" must be recognized by build. To do this, - /// add a $(ECHO_COMPILING_COMMAND) or $(ECHO_PROCESSING_COMMAND) - /// to the first line of the description block, e.g. - /// - /// $(ECHO_COMPILING_CMD) Resgen_$< - /// - /// Errors must have the format: - /// - /// <text> : error [num]: <msg> - /// - /// Warnings must have the format: - /// - /// <text> : warning [num]: <msg> - /// - /// JomoF - internal static class CanonicalError - { - // Defines the main pattern for matching messages. - private static readonly Regex s_originCategoryCodeTextExpression = new Regex - ( - // Beginning of line and any amount of whitespace. - @"^\s*" - // Match a [optional project number prefix 'ddd>'], single letter + colon + remaining filename, or - // string with no colon followed by a colon. - + @"(((?(((\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)" - // Origin may also be empty. In this case there's no trailing colon. - + "|())" - // Match the empty string or a string without a colon that ends with a space - + "(?(()|([^:]*? )))" - // Match 'error' or 'warning'. - + @"(?(error|warning))" - // Match anything starting with a space that's not a colon/space, followed by a colon. - // Error code is optional in which case "error"/"warning" can be followed immediately by a colon. - + @"( \s*(?[^: ]*))?\s*:" - // Whatever's left on this line, including colons. - + "(?.*)$", - RegexOptions.IgnoreCase - ); - - // Matches and extracts filename and location from an 'origin' element. - private static readonly Regex s_filenameLocationFromOrigin = new Regex - ( - "^" // Beginning of line - + @"(\d+>)?" // Optional ddd> project number prefix - + "(?.*)" // Match anything. - + @"\(" // Find a parenthesis. - + @"(?[\,,0-9,-]*)" // Match any combination of numbers and ',' and '-' - + @"\)\s*" // Find the closing paren then any amount of spaces. - + "$", // End-of-line - RegexOptions.IgnoreCase - ); - - // Matches location that is a simple number. - private static readonly Regex s_lineFromLocation = new Regex // Example: line - ( - "^" // Beginning of line - + "(?[0-9]*)" // Match any number. - + "$", // End-of-line - RegexOptions.IgnoreCase - ); - - // Matches location that is a range of lines. - private static readonly Regex s_lineLineFromLocation = new Regex // Example: line-line - ( - "^" // Beginning of line - + "(?[0-9]*)" // Match any number. - + "-" // Dash - + "(?[0-9]*)" // Match any number. - + "$", // End-of-line - RegexOptions.IgnoreCase - ); - - // Matches location that is a line and column - private static readonly Regex s_lineColFromLocation = new Regex // Example: line,col - ( - "^" // Beginning of line - + "(?[0-9]*)" // Match any number. - + "," // Comma - + "(?[0-9]*)" // Match any number. - + "$", // End-of-line - RegexOptions.IgnoreCase - ); - - // Matches location that is a line and column-range - private static readonly Regex s_lineColColFromLocation = new Regex // Example: line,col-col - ( - "^" // Beginning of line - + "(?[0-9]*)" // Match any number. - + "," // Comma - + "(?[0-9]*)" // Match any number. - + "-" // Dash - + "(?[0-9]*)" // Match any number. - + "$", // End-of-line - RegexOptions.IgnoreCase - ); - - // Matches location that is line,col,line,col - private static readonly Regex s_lineColLineColFromLocation = new Regex // Example: line,col,line,col - ( - "^" // Beginning of line - + "(?[0-9]*)" // Match any number. - + "," // Comma - + "(?[0-9]*)" // Match any number. - + "," // Dash - + "(?[0-9]*)" // Match any number. - + "," // Dash - + "(?[0-9]*)" // Match any number. - + "$", // End-of-line - RegexOptions.IgnoreCase - ); - - /// - /// Represents the parts of a decomposed canonical message. - /// - /// JomoF - internal sealed class Parts - { - /// - /// Defines the error category\severity level. - /// - internal enum Category - { - Warning, - Error - } - - /// - /// Value used for unspecified line and column numbers, which are 1-relative. - /// - internal const int numberNotSpecified = 0; - - /// - /// Initializes a new instance of the class. - /// - internal Parts() - { - } - - /// - /// Name of the file or tool (not localized) - /// - internal string origin; - - /// - /// The line number. - /// - internal int line = Parts.numberNotSpecified; - - /// - /// The column number. - /// - internal int column = Parts.numberNotSpecified; - - /// - /// The ending line number. - /// - internal int endLine = Parts.numberNotSpecified; - - /// - /// The ending column number. - /// - internal int endColumn = Parts.numberNotSpecified; - - /// - /// The category/severity level - /// - internal Category category; - - /// - /// The sub category (localized) - /// - internal string subcategory; - - /// - /// The error code (not localized) - /// - internal string code; - - /// - /// The error message text (localized) - /// - internal string text; - -#if NEVER - internal new string ToString() - { - return String.Format - ( - "Origin='{0}'\n" - +"Filename='{1}'\n" - +"Line='{2}'\n" - +"Column='{3}'\n" - +"EndLine='{4}'\n" - +"EndColumn='{5}'\n" - +"Category='{6}'\n" - +"Subcategory='{7}'\n" - +"Text='{8}'\n" - , origin, line, column, endLine, endColumn, category.ToString(), subcategory, code, text - ); - - } -#endif - } - - /// - /// A small custom int conversion method that treats invalid entries as missing (0). This is done to work around tools - /// that don't fully conform to the canonical message format - we still want to salvage what we can from the message. - /// - /// - /// 'value' converted to int or 0 if it can't be parsed or is negative - /// LukaszG - private static int ConvertToIntWithDefault(string value) - { - int result; - bool success = int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); - - if (!success || (result < 0)) - { - result = CanonicalError.Parts.numberNotSpecified; - } - - return result; - } - - /// - /// Decompose an error or warning message into constituent parts. If the message isn't in the canonical form, return null. - /// - /// This method is thread-safe, because the Regex class is thread-safe (per MSDN). - /// JomoF - /// - /// Decomposed canonical message, or null. - internal static Parts Parse(string message) - { - // An unusually long string causes pathologically slow Regex back-tracking. - // To avoid that, only scan the first 400 characters. That's enough for - // the longest possible prefix: MAX_PATH, plus a huge subcategory string, and an error location. - // After the regex is done, we can append the overflow. - string messageOverflow = String.Empty; - if (message.Length > 400) - { - messageOverflow = message.Substring(400); - message = message.Substring(0, 400); - } - - // If a tool has a large amount of output that isn't an error or warning (eg., "dir /s %hugetree%") - // the regex below is slow. It's faster to pre-scan for "warning" and "error" - // and bail out if neither are present. - if (message.IndexOf("warning", StringComparison.OrdinalIgnoreCase) == -1 && - message.IndexOf("error", StringComparison.OrdinalIgnoreCase) == -1) - { - return null; - } - - Parts parsedMessage = new Parts(); - - // First, split the message into three parts--Origin, Category, Code, Text. - // Example, - // Main.cs(17,20):Command line warning CS0168: The variable 'foo' is declared but never used - // -------------- ------------ ------- ------ ---------------------------------------------- - // Origin SubCategory Cat. Code Text - // - // To accommodate absolute filenames in Origin, tolerate a colon in the second position - // as long as its preceded by a letter. - // - // Localization Note: - // Even in foreign-language versions of tools, the category field needs to be in English. - // Also, if origin is a tool name, then that needs to be in English. - // - // Here's an example from the Japanese version of CL.EXE: - // cl : ???? ??? warning D4024 : ?????????? 'AssemblyInfo.cs' ?????????????????? ??????????? - // - // Here's an example from the Japanese version of LINK.EXE: - // AssemblyInfo.cpp : fatal error LNK1106: ???????????? ??????????????: 0x6580 ?????????? - // - Match match = s_originCategoryCodeTextExpression.Match(message); - - if (!match.Success) - { - // If no match here, then this message is not an error or warning. - return null; - } - - string origin = match.Groups["ORIGIN"].Value.Trim(); - string category = match.Groups["CATEGORY"].Value.Trim(); - parsedMessage.code = match.Groups["CODE"].Value.Trim(); - parsedMessage.text = (match.Groups["TEXT"].Value + messageOverflow).Trim(); - parsedMessage.subcategory = match.Groups["SUBCATEGORY"].Value.Trim(); - - // Next, see if category is something that is recognized. - if (0 == String.Compare(category, "error", StringComparison.OrdinalIgnoreCase)) - { - parsedMessage.category = Parts.Category.Error; - } - else if (0 == String.Compare(category, "warning", StringComparison.OrdinalIgnoreCase)) - { - parsedMessage.category = Parts.Category.Warning; - } - else - { - // Not an error\warning message. - return null; - } - - // Origin is not a simple file, but it still could be of the form, - // foo.cpp(location) - match = s_filenameLocationFromOrigin.Match(origin); - - if (match.Success) - { - // The origin is in the form, - // foo.cpp(location) - // Assume the filename exists, but don't verify it. What else could it be? - string location = match.Groups["LOCATION"].Value.Trim(); - parsedMessage.origin = match.Groups["FILENAME"].Value.Trim(); - - // Now, take apart the location. It can be one of these: - // loc: - // (line) - // (line-line) - // (line,col) - // (line,col-col) - // (line,col,len) - // (line,col,line,col) - if (location.Length > 0) - { - match = s_lineFromLocation.Match(location); - if (match.Success) - { - parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim()); - } - else - { - match = s_lineLineFromLocation.Match(location); - if (match.Success) - { - parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim()); - parsedMessage.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim()); - } - else - { - match = s_lineColFromLocation.Match(location); - if (match.Success) - { - parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim()); - parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim()); - } - else - { - match = s_lineColColFromLocation.Match(location); - if (match.Success) - { - parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim()); - parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim()); - parsedMessage.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim()); - } - else - { - match = s_lineColLineColFromLocation.Match(location); - if (match.Success) - { - parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim()); - parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim()); - parsedMessage.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim()); - parsedMessage.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim()); - } - } - } - } - } - } - } - else - { - // The origin does not fit the filename(location) pattern. - parsedMessage.origin = origin; - } - - return parsedMessage; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile/CompilationDriver.cs b/src/dotnet/commands/dotnet-compile/CompilationDriver.cs deleted file mode 100644 index 5f679fc34..000000000 --- a/src/dotnet/commands/dotnet-compile/CompilationDriver.cs +++ /dev/null @@ -1,37 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public class CompilationDriver - { - private readonly ICompiler _managedCompiler; - private readonly ICompiler _nativeCompiler; - - public CompilationDriver(ICompiler managedCompiler, ICompiler nativeCompiler) - { - _managedCompiler = managedCompiler; - _nativeCompiler = nativeCompiler; - } - - public bool Compile(IEnumerable contexts, BuildCommandApp args) - { - var success = true; - - foreach (var context in contexts) - { - success &= _managedCompiler.Compile(context, args); - if (args.IsNativeValue && success) - { - var runtimeContext = args.Workspace.GetRuntimeContext(context, args.GetRuntimes()); - success &= _nativeCompiler.Compile(runtimeContext, args); - } - } - - return success; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile/Compiler.cs b/src/dotnet/commands/dotnet-compile/Compiler.cs deleted file mode 100644 index f5cb7c121..000000000 --- a/src/dotnet/commands/dotnet-compile/Compiler.cs +++ /dev/null @@ -1,213 +0,0 @@ -// 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.Diagnostics; -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Resources; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public abstract class Compiler : ICompiler - { - public abstract bool Compile(ProjectContext context, BuildCommandApp args); - - protected static bool PrintSummary(List diagnostics, Stopwatch sw, bool success = true) - { - PrintDiagnostics(diagnostics); - - Reporter.Output.WriteLine(); - - var errorCount = diagnostics.Count(d => d.Severity == DiagnosticMessageSeverity.Error); - var warningCount = diagnostics.Count(d => d.Severity == DiagnosticMessageSeverity.Warning); - - if (errorCount > 0 || !success) - { - Reporter.Output.WriteLine("Compilation failed.".Red()); - success = false; - } - else - { - Reporter.Output.WriteLine("Compilation succeeded.".Green()); - } - - Reporter.Output.WriteLine($" {warningCount} Warning(s)"); - Reporter.Output.WriteLine($" {errorCount} Error(s)"); - - Reporter.Output.WriteLine(); - - Reporter.Output.WriteLine($"Time elapsed {sw.Elapsed}"); - - return success; - } - - protected static bool AddNonCultureResources( - Project project, - List compilerArgs, - string intermediateOutputPath, - CommonCompilerOptions compilationOptions) - { - List resgenFiles = null; - if (compilationOptions.EmbedInclude == null) - { - resgenFiles = CompilerUtil.GetNonCultureResources(project, intermediateOutputPath); - } - else - { - resgenFiles = CompilerUtil.GetNonCultureResourcesFromIncludeEntries(project, intermediateOutputPath, compilationOptions); - } - - foreach (var resgenFile in resgenFiles) - { - if (ResourceUtility.IsResxFile(resgenFile.InputFile)) - { - var result = Resgen.ResgenCommand.Run( - new[] { resgenFile.InputFile }, - culture: null, - outputFile: resgenFile.OutputFile, - version: project.Version.Version.ToString(), - compilationReferences: null); - - if (result != 0) - { - return false; - } - - compilerArgs.Add($"--resource:\"{resgenFile.OutputFile}\",{Path.GetFileName(resgenFile.MetadataName)}"); - } - else - { - compilerArgs.Add($"--resource:\"{resgenFile.InputFile}\",{Path.GetFileName(resgenFile.MetadataName)}"); - } - } - - return true; - } - - protected static bool GenerateCultureResourceAssemblies( - Project project, - List dependencies, - string outputPath, - CommonCompilerOptions compilationOptions) - { - var referencePaths = CompilerUtil.GetReferencePathsForCultureResgen(dependencies); - - List cultureResgenFiles = null; - if (compilationOptions.EmbedInclude == null) - { - cultureResgenFiles = CompilerUtil.GetCultureResources(project, outputPath); - } - else - { - cultureResgenFiles = CompilerUtil.GetCultureResourcesFromIncludeEntries(project, outputPath, compilationOptions); - } - - foreach (var resgenFile in cultureResgenFiles) - { - var resourceOutputPath = Path.GetDirectoryName(resgenFile.OutputFile); - - if (!Directory.Exists(resourceOutputPath)) - { - Directory.CreateDirectory(resourceOutputPath); - } - - var result = Resgen.ResgenCommand.Run( - resgenFile.InputFileToMetadata.Select(fileToMetadata => $"{fileToMetadata.Key},{fileToMetadata.Value}"), - resgenFile.Culture, - resgenFile.OutputFile, - project.Version.Version.ToString(), - referencePaths); - - if (result != 0) - { - return false; - } - } - - return true; - } - - protected static DiagnosticMessage ParseDiagnostic(string projectRootPath, string line) - { - var error = CanonicalError.Parse(line); - - if (error != null) - { - var severity = error.category == CanonicalError.Parts.Category.Error ? - DiagnosticMessageSeverity.Error : DiagnosticMessageSeverity.Warning; - - return new DiagnosticMessage( - error.code, - error.text, - Path.IsPathRooted(error.origin) ? line : projectRootPath + Path.DirectorySeparatorChar + line, - Path.Combine(projectRootPath, error.origin), - severity, - error.line, - error.column, - error.endColumn, - error.endLine, - source: null); - } - - return null; - } - - private static void PrintDiagnostics(List diagnostics) - { - foreach (var diag in diagnostics) - { - PrintDiagnostic(diag); - } - } - - private static void PrintDiagnostic(DiagnosticMessage diag) - { - switch (diag.Severity) - { - case DiagnosticMessageSeverity.Info: - Reporter.Error.WriteLine(diag.FormattedMessage); - break; - case DiagnosticMessageSeverity.Warning: - Reporter.Error.WriteLine(diag.FormattedMessage.Yellow().Bold()); - break; - case DiagnosticMessageSeverity.Error: - Reporter.Error.WriteLine(diag.FormattedMessage.Red().Bold()); - break; - } - } - - private static void CopyFiles(IEnumerable files, string outputPath) - { - foreach (var file in files) - { - File.Copy(file.ResolvedPath, Path.Combine(outputPath, Path.GetFileName(file.ResolvedPath)), overwrite: true); - } - } - - private static string EnsureTrailingSlash(string path) - { - return EnsureTrailingCharacter(path, Path.DirectorySeparatorChar); - } - - private static string EnsureTrailingCharacter(string path, char trailingCharacter) - { - if (path == null) - { - throw new ArgumentNullException(nameof(path)); - } - - // if the path is empty, we want to return the original string instead of a single trailing character. - if (path.Length == 0 || path[path.Length - 1] == trailingCharacter) - { - return path; - } - - return path + trailingCharacter; - } - } -} diff --git a/src/dotnet/commands/dotnet-compile/CompilerUtil.cs b/src/dotnet/commands/dotnet-compile/CompilerUtil.cs deleted file mode 100644 index 3f3a39fe6..000000000 --- a/src/dotnet/commands/dotnet-compile/CompilerUtil.cs +++ /dev/null @@ -1,181 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.Resources; -using Microsoft.DotNet.Tools.Common; - -// This class is responsible with defining the arguments for the Compile verb. -// It knows how to interpret them and set default values - -namespace Microsoft.DotNet.Tools.Compiler -{ - public static class CompilerUtil - { - public static string ResolveLanguageId(ProjectContext context) - { - var languageId = context.ProjectFile.AnalyzerOptions?.LanguageId; - if (languageId == null) - { - languageId = context.ProjectFile.GetSourceCodeLanguage(); - } - - return languageId; - } - - public struct NonCultureResgenIO - { - public readonly string InputFile; - public readonly string MetadataName; - - // is non-null only when resgen needs to be invoked (inputFile is .resx) - public readonly string OutputFile; - - public NonCultureResgenIO(string inputFile, string outputFile, string metadataName) - { - InputFile = inputFile; - OutputFile = outputFile; - MetadataName = metadataName; - } - } - - // used in incremental compilation - public static List GetNonCultureResources(Project project, string intermediateOutputPath) - { - return - (from resourceFile in project.Files.ResourceFiles - let inputFile = resourceFile.Key - where string.IsNullOrEmpty(ResourceUtility.GetResourceCultureName(inputFile)) - let metadataName = GetResourceFileMetadataName(project, resourceFile.Key, resourceFile.Value) - let outputFile = ResourceUtility.IsResxFile(inputFile) ? Path.Combine(intermediateOutputPath, metadataName) : null - select new NonCultureResgenIO(inputFile, outputFile, metadataName) - ).ToList(); - } - - // used in incremental compilation - public static List GetNonCultureResourcesFromIncludeEntries( - Project project, - string intermediateOutputPath, - CommonCompilerOptions compilationOptions) - { - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilationOptions.EmbedInclude, "/", diagnostics: null); - return - (from resourceFile in includeFiles - let inputFile = resourceFile.SourcePath - where string.IsNullOrEmpty(ResourceUtility.GetResourceCultureName(inputFile)) - let target = resourceFile.IsCustomTarget ? resourceFile.TargetPath : null - let metadataName = GetResourceFileMetadataName(project, resourceFile.SourcePath, target) - let outputFile = ResourceUtility.IsResxFile(inputFile) ? Path.Combine(intermediateOutputPath, metadataName) : null - select new NonCultureResgenIO(inputFile, outputFile, metadataName) - ).ToList(); - } - - public struct CultureResgenIO - { - public readonly string Culture; - public readonly Dictionary InputFileToMetadata; - public readonly string OutputFile; - - public CultureResgenIO(string culture, Dictionary inputFileToMetadata, string outputFile) - { - Culture = culture; - InputFileToMetadata = inputFileToMetadata; - OutputFile = outputFile; - } - } - - // used in incremental compilation - public static List GetCultureResources(Project project, string outputPath) - { - return - (from resourceFileGroup in project.Files.ResourceFiles.GroupBy( - resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key)) - let culture = resourceFileGroup.Key - where !string.IsNullOrEmpty(culture) - let inputFileToMetadata = resourceFileGroup.ToDictionary( - r => r.Key, - r => GetResourceFileMetadataName(project, r.Key, r.Value)) - let resourceOutputPath = Path.Combine(outputPath, culture) - let outputFile = Path.Combine(resourceOutputPath, project.Name + ".resources.dll") - select new CultureResgenIO(culture, inputFileToMetadata, outputFile) - ).ToList(); - } - - // used in incremental compilation - public static List GetCultureResourcesFromIncludeEntries( - Project project, - string outputPath, - CommonCompilerOptions compilationOptions) - { - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilationOptions.EmbedInclude, "/", diagnostics: null); - return - (from resourceFileGroup in includeFiles - .GroupBy(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.SourcePath)) - let culture = resourceFileGroup.Key - where !string.IsNullOrEmpty(culture) - let inputFileToMetadata = resourceFileGroup.ToDictionary( - r => r.SourcePath, r => GetResourceFileMetadataName(project, r.SourcePath, r.IsCustomTarget ? r.TargetPath : null)) - let resourceOutputPath = Path.Combine(outputPath, culture) - let outputFile = Path.Combine(resourceOutputPath, project.Name + ".resources.dll") - select new CultureResgenIO(culture, inputFileToMetadata, outputFile) - ).ToList(); - } - - // used in incremental compilation - public static IList GetReferencePathsForCultureResgen(List dependencies) - { - return dependencies.SelectMany(libraryExport => libraryExport.CompilationAssemblies).Select(r => r.ResolvedPath).ToList(); - } - - public static string GetResourceFileMetadataName(Project project, string resourceFileSource, string resourceFileTarget) - { - string resourceName = null; - string rootNamespace = null; - - string root = PathUtility.EnsureTrailingSlash(project.ProjectDirectory); - string resourcePath = resourceFileSource; - if (string.IsNullOrEmpty(resourceFileTarget)) - { - // No logical name, so use the file name - resourceName = ResourceUtility.GetResourceName(root, resourcePath); - rootNamespace = project.Name; - } - else - { - resourceName = ResourceManifestName.EnsureResourceExtension(resourceFileTarget, resourcePath); - rootNamespace = null; - } - - var name = ResourceManifestName.CreateManifestName(resourceName, rootNamespace); - return name; - } - - // used in incremental compilation - public static IEnumerable GetCompilationSources(ProjectContext project, CommonCompilerOptions compilerOptions) - { - if (compilerOptions.CompileInclude == null) - { - return project.ProjectFile.Files.SourceFiles; - } - - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); - - return includeFiles.Select(f => f.SourcePath); - } - - //used in incremental precondition checks - public static IEnumerable GetCommandsInvokedByCompile(ProjectContext project) - { - var compilerOptions = project.ProjectFile.GetCompilerOptions(project.TargetFramework, configurationName: null); - return new List { compilerOptions.CompilerName, "compile" }; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile/ICompiler.cs b/src/dotnet/commands/dotnet-compile/ICompiler.cs deleted file mode 100644 index dd256590d..000000000 --- a/src/dotnet/commands/dotnet-compile/ICompiler.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.ProjectModel; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public interface ICompiler - { - bool Compile(ProjectContext context, BuildCommandApp args); - } -} diff --git a/src/dotnet/commands/dotnet-compile/IScriptRunner.cs b/src/dotnet/commands/dotnet-compile/IScriptRunner.cs deleted file mode 100644 index 05910cebc..000000000 --- a/src/dotnet/commands/dotnet-compile/IScriptRunner.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.ProjectModel; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public interface IScriptRunner - { - void RunScripts(ProjectContext context, string name, Dictionary contextVariables); - } -} diff --git a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs deleted file mode 100644 index 782c3a653..000000000 --- a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs +++ /dev/null @@ -1,236 +0,0 @@ -// 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.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.Extensions.DependencyModel; -using NuGet.Frameworks; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public class ManagedCompiler : Compiler - { - private readonly IScriptRunner _scriptRunner; - private readonly ICommandFactory _commandFactory; - - public ManagedCompiler(IScriptRunner scriptRunner, ICommandFactory commandFactory) - { - _scriptRunner = scriptRunner; - _commandFactory = commandFactory; - } - - public override bool Compile(ProjectContext context, BuildCommandApp args) - { - // Set up Output Paths - var outputPaths = context.GetOutputPaths(args.ConfigValue, args.BuildBasePathValue); - var outputPath = outputPaths.CompilationOutputPath; - var intermediateOutputPath = outputPaths.IntermediateOutputDirectoryPath; - - Directory.CreateDirectory(outputPath); - Directory.CreateDirectory(intermediateOutputPath); - - // Create the library exporter - var exporter = context.CreateExporter(args.ConfigValue, args.BuildBasePathValue); - - // Gather exports for the project - var dependencies = exporter.GetDependencies().ToList(); - - Reporter.Output.WriteLine($"Compiling {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}"); - var sw = Stopwatch.StartNew(); - - var diagnostics = new List(); - var missingFrameworkDiagnostics = new List(); - - // Collect dependency diagnostics - foreach (var diag in context.LibraryManager.GetAllDiagnostics()) - { - if (diag.ErrorCode == ErrorCodes.DOTNET1011 || - diag.ErrorCode == ErrorCodes.DOTNET1012) - { - missingFrameworkDiagnostics.Add(diag); - } - - diagnostics.Add(diag); - } - - if(diagnostics.Any(d => d.Severity == DiagnosticMessageSeverity.Error)) - { - // We got an unresolved dependency or missing framework. Don't continue the compilation. - PrintSummary(diagnostics, sw); - return false; - } - - // Get compilation options - var outputName = outputPaths.CompilationFiles.Assembly; - - // Assemble args - var compilerArgs = new List() - { - $"--temp-output:{intermediateOutputPath}", - $"--out:{outputName}" - }; - - var compilationOptions = context.ResolveCompilationOptions(args.ConfigValue); - - // Set default platform if it isn't already set and we're on desktop - if (compilationOptions.EmitEntryPoint == true && string.IsNullOrEmpty(compilationOptions.Platform) && context.TargetFramework.IsDesktop()) - { - // See https://github.com/dotnet/cli/issues/2428 for more details. - compilationOptions.Platform = RuntimeInformation.ProcessArchitecture == Architecture.X64 ? - "x64" : "anycpu32bitpreferred"; - } - - var languageId = CompilerUtil.ResolveLanguageId(context); - - var references = new List(); - - // Add compilation options to the args - compilerArgs.AddRange(compilationOptions.SerializeToArgs()); - - // Add metadata options - compilerArgs.AddRange(AssemblyInfoOptions.SerializeToArgs(AssemblyInfoOptions.CreateForProject(context))); - - foreach (var dependency in dependencies) - { - references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath)); - - compilerArgs.AddRange(dependency.SourceReferences.Select(s => s.GetTransformedFile(intermediateOutputPath))); - - foreach (var resourceFile in dependency.EmbeddedResources) - { - var transformedResource = resourceFile.GetTransformedFile(intermediateOutputPath); - var resourceName = ResourceManifestName.CreateManifestName( - Path.GetFileName(resourceFile.ResolvedPath), compilationOptions.OutputName); - compilerArgs.Add($"--resource:\"{transformedResource}\",{resourceName}"); - } - - // Add analyzer references - compilerArgs.AddRange(dependency.AnalyzerReferences - .Where(a => a.AnalyzerLanguage == languageId) - .Select(a => $"--analyzer:{a.AssemblyPath}")); - } - - compilerArgs.AddRange(references.Select(r => $"--reference:{r}")); - - if (compilationOptions.PreserveCompilationContext == true) - { - var allExports = exporter.GetAllExports().ToList(); - var exportsLookup = allExports.ToDictionary( - e => e.Library.Identity.Name, - StringComparer.OrdinalIgnoreCase); - var buildExclusionList = context.GetTypeBuildExclusionList(exportsLookup); - var filteredExports = allExports - .Where(e => e.Library.Identity.Type.Equals(LibraryType.Reference) || - !buildExclusionList.Contains(e.Library.Identity.Name)); - - var dependencyContext = new DependencyContextBuilder().Build(compilationOptions, - filteredExports, - filteredExports, - false, // For now, just assume non-portable mode in the legacy deps file (this is going away soon anyway) - context.TargetFramework, - context.RuntimeIdentifier ?? string.Empty); - - var writer = new DependencyContextWriter(); - var depsJsonFile = Path.Combine(intermediateOutputPath, compilationOptions.OutputName + "dotnet-compile.deps.json"); - using (var fileStream = File.Create(depsJsonFile)) - { - writer.Write(dependencyContext, fileStream); - } - - compilerArgs.Add($"--resource:\"{depsJsonFile}\",{compilationOptions.OutputName}.deps.json"); - } - - if (!AddNonCultureResources(context.ProjectFile, compilerArgs, intermediateOutputPath, compilationOptions)) - { - return false; - } - // Add project source files - var sourceFiles = CompilerUtil.GetCompilationSources(context, compilationOptions); - compilerArgs.AddRange(sourceFiles); - - var compilerName = compilationOptions.CompilerName; - - // Write RSP file - var rsp = Path.Combine(intermediateOutputPath, $"dotnet-compile.rsp"); - File.WriteAllLines(rsp, compilerArgs); - - // Run pre-compile event - var contextVariables = new Dictionary() - { - { "compile:TargetFramework", context.TargetFramework.GetShortFolderName() }, - { "compile:FullTargetFramework", context.TargetFramework.DotNetFrameworkName }, - { "compile:Configuration", args.ConfigValue }, - { "compile:OutputFile", outputName }, - { "compile:OutputDir", outputPath.TrimEnd('\\', '/') }, - { "compile:ResponseFile", rsp } - }; - - if (context.ProjectFile.HasRuntimeOutput(args.ConfigValue)) - { - var runtimeContext = args.Workspace.GetRuntimeContext(context, args.GetRuntimes()); - var runtimeOutputPath = runtimeContext.GetOutputPaths(args.ConfigValue, args.BuildBasePathValue, args.OutputValue); - - contextVariables.Add( - "compile:RuntimeOutputDir", - runtimeOutputPath.RuntimeOutputPath.TrimEnd('\\', '/')); - - contextVariables.Add( - "compile:RuntimeIdentifier", - runtimeContext.RuntimeIdentifier); - } - - _scriptRunner.RunScripts(context, ScriptNames.PreCompile, contextVariables); - - // Cache the reporters before invoking the command in case it is a built-in command, which replaces - // the static Reporter instances. - Reporter errorReporter = Reporter.Error; - Reporter outputReporter = Reporter.Output; - - CommandResult result = _commandFactory.Create($"compile-{compilerName}", new[] { $"@{rsp}" }) - .WorkingDirectory(context.ProjectDirectory) - .OnErrorLine(line => HandleCompilerOutputLine(line, context, diagnostics, errorReporter)) - .OnOutputLine(line => HandleCompilerOutputLine(line, context, diagnostics, outputReporter)) - .Execute(); - - // Run post-compile event - contextVariables["compile:CompilerExitCode"] = result.ExitCode.ToString(); - _scriptRunner.RunScripts(context, ScriptNames.PostCompile, contextVariables); - - var success = result.ExitCode == 0; - - if (!success) - { - Reporter.Error.WriteLine($"{result.StartInfo.FileName} {result.StartInfo.Arguments} returned Exit Code {result.ExitCode}"); - } - - if (success) - { - success &= GenerateCultureResourceAssemblies(context.ProjectFile, dependencies, outputPath, compilationOptions); - } - - return PrintSummary(diagnostics, sw, success); - } - - private static void HandleCompilerOutputLine(string line, ProjectContext context, List diagnostics, Reporter reporter) - { - var diagnostic = ParseDiagnostic(context.ProjectDirectory, line); - if (diagnostic != null) - { - diagnostics.Add(diagnostic); - } - else - { - reporter.WriteLine(line); - } - } - } -} diff --git a/src/dotnet/commands/dotnet-compile/ResourceManifestName.cs b/src/dotnet/commands/dotnet-compile/ResourceManifestName.cs deleted file mode 100644 index c686d4871..000000000 --- a/src/dotnet/commands/dotnet-compile/ResourceManifestName.cs +++ /dev/null @@ -1,199 +0,0 @@ -// 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.Globalization; -using System.IO; -using System.Text; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.ProjectModel.Resources; - -namespace Microsoft.DotNet.Tools.Compiler -{ - internal static class ResourceManifestName - { - // Original source: https://raw.githubusercontent.com/Microsoft/msbuild/82177a50da735cc0443ac10fa490d69368403d71/src/XMakeTasks/CreateCSharpManifestResourceName.cs - - public static string CreateManifestName(string fileName, string rootNamespace) - { - var name = new StringBuilder(); - - // Differences from the msbuild task: - // - we do not include the name of the first class (if any) for binary resources or source code - // - culture info is ignored - - if (rootNamespace != null && rootNamespace.Length > 0) - { - name.Append(rootNamespace).Append("."); - } - - // Replace spaces in the directory name with underscores. - // Note that spaces in the file name itself are preserved. - var path = MakeValidIdentifier(Path.GetDirectoryName(fileName)); - - // This is different from the msbuild task: we always append extensions because otherwise, - // the emitted resource doesn't have an extension and it is not the same as in the classic - // C# assembly - if (ResourceUtility.IsResourceFile(fileName)) - { - name.Append(Path.Combine(path, Path.GetFileNameWithoutExtension(fileName))); - name.Append(".resources"); - name.Replace(Path.DirectorySeparatorChar, '.'); - name.Replace(Path.AltDirectorySeparatorChar, '.'); - } - else - { - name.Append(Path.Combine(path, Path.GetFileName(fileName))); - name.Replace(Path.DirectorySeparatorChar, '.'); - name.Replace(Path.AltDirectorySeparatorChar, '.'); - } - - return name.ToString(); - } - - // The code below the same is same as here: https://raw.githubusercontent.com/Microsoft/msbuild/41b137cd8805079af7792995e044521d62fcb005/src/XMakeTasks/CreateManifestResourceName.cs - - /// - /// This method is provided for compatibility with MsBuild which used to convert parts of resource names into - /// valid identifiers - /// - private static string MakeValidIdentifier(string name) - { - var id = new StringBuilder(name.Length); - - // split the name into folder names - var subNames = name.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); - - // convert every folder name - id.Append(MakeValidFolderIdentifier(subNames[0])); - - for (int i = 1; i < subNames.Length; i++) - { - id.Append('.'); - id.Append(MakeValidFolderIdentifier(subNames[i])); - } - - return id.ToString(); - } - - /// - /// Make a folder name into an identifier - /// - private static string MakeValidFolderIdentifier(string name) - { - // give string length to avoid reallocations; +1 since the resulting string may be one char longer than the - // original - if the name is a single underscore we add another underscore to it - var id = new StringBuilder(name.Length + 1); - - // split folder name into subnames separated by '.', if any - var subNames = name.Split(new char[] { '.' }); - - // convert each subname separately - id.Append(MakeValidSubFolderIdentifier(subNames[0])); - - for (int i = 1; i < subNames.Length; i++) - { - id.Append('.'); - id.Append(MakeValidSubFolderIdentifier(subNames[i])); - } - - // folder name cannot be a single underscore - add another underscore to it - if (id.ToString() == "_") - { - id.Append('_'); - } - - return id.ToString(); - } - - /// - /// Make a folder subname into identifier - /// - private static string MakeValidSubFolderIdentifier(string subName) - { - if (subName.Length == 0) - { - return subName; - } - - // give string length to avoid reallocations; +1 since the resulting string may be one char longer than the - // original - if the first character is an invalid first identifier character but a valid subsequent one, - // we prepend an underscore to it. - var id = new StringBuilder(subName.Length + 1); - - // the first character has stronger restrictions than the rest - if (!IsValidIdFirstChar(subName[0])) - { - // if the first character is not even a valid subsequent character, replace it with an underscore - if (!IsValidIdChar(subName[0])) - { - id.Append('_'); - } - // if it is a valid subsequent character, prepend an underscore to it - else - { - id.Append('_'); - id.Append(subName[0]); - } - } - else - { - id.Append(subName[0]); - } - - // process the rest of the subname - for (int i = 1; i < subName.Length; i++) - { - if (!IsValidIdChar(subName[i])) - { - id.Append('_'); - } - else - { - id.Append(subName[i]); - } - } - - return id.ToString(); - } - - /// - /// Is the character a valid first identifier character? - /// - private static bool IsValidIdFirstChar(char c) - { - return - char.IsLetter(c) || - CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.ConnectorPunctuation; - } - - /// - /// Is the character a valid identifier character? - /// - private static bool IsValidIdChar(char c) - { - var cat = CharUnicodeInfo.GetUnicodeCategory(c); - - return - char.IsLetterOrDigit(c) || - cat == UnicodeCategory.ConnectorPunctuation || - cat == UnicodeCategory.NonSpacingMark || - cat == UnicodeCategory.SpacingCombiningMark || - cat == UnicodeCategory.EnclosingMark; - } - - public static string EnsureResourceExtension(string logicalName, string resourceFilePath) - { - string resourceExtension = Path.GetExtension(resourceFilePath); - if (!string.IsNullOrEmpty(resourceExtension)) - { - if (!logicalName.EndsWith(resourceExtension, StringComparison.Ordinal)) - { - logicalName += resourceExtension; - } - } - - return logicalName; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-compile/ScriptRunner.cs b/src/dotnet/commands/dotnet-compile/ScriptRunner.cs deleted file mode 100644 index 72cb47cd6..000000000 --- a/src/dotnet/commands/dotnet-compile/ScriptRunner.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Utilities; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public class ScriptRunner : IScriptRunner - { - public void RunScripts(ProjectContext context, string name, Dictionary contextVariables) - { - foreach (var script in context.ProjectFile.Scripts.GetOrEmpty(name)) - { - ScriptExecutor.CreateCommandForScript(context.ProjectFile, script, contextVariables) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - } - } - } -} \ 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 cc5086ab2..4b2132663 100644 --- a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs +++ b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs @@ -9,7 +9,7 @@ using System.Text; using Microsoft.Build.Construction; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ProjectJsonMigration; -using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Internal.ProjectModel; namespace Microsoft.DotNet.Tools.Migrate { diff --git a/src/dotnet/commands/dotnet-new/CSharp_nunittest/Tests.cs b/src/dotnet/commands/dotnet-new/CSharp_nunittest/Tests.cs deleted file mode 100644 index ab4cf8ec5..000000000 --- a/src/dotnet/commands/dotnet-new/CSharp_nunittest/Tests.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NUnit.Framework; - -namespace Tests -{ - public class Tests - { - [SetUp] - public void Setup() - { - } - - [Test] - public void Test1() - { - Assert.Pass(); - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/CSharp_nunittest/project.json.template b/src/dotnet/commands/dotnet-new/CSharp_nunittest/project.json.template deleted file mode 100644 index bb414fa52..000000000 --- a/src/dotnet/commands/dotnet-new/CSharp_nunittest/project.json.template +++ /dev/null @@ -1,22 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "NUnit": "3.4.1", - "dotnet-test-nunit": "3.4.0-beta-1" - }, - - "testRunner": "nunit", - - "frameworks": { - "netcoreapp1.0": { - "imports": "portable-net45+win8", - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - } - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/CSharp_xunittest/Tests.cs b/src/dotnet/commands/dotnet-new/CSharp_xunittest/Tests.cs deleted file mode 100644 index 1bd5ced4f..000000000 --- a/src/dotnet/commands/dotnet-new/CSharp_xunittest/Tests.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Tests -{ - public class Tests - { - [Fact] - public void Test1() - { - Assert.True(true); - } - } -} diff --git a/src/dotnet/commands/dotnet-new/CSharp_xunittest/project.json.template b/src/dotnet/commands/dotnet-new/CSharp_xunittest/project.json.template deleted file mode 100644 index 82f115e7f..000000000 --- a/src/dotnet/commands/dotnet-new/CSharp_xunittest/project.json.template +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "debugType": "portable" - }, - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.1.1", - "xunit": "2.2.0-beta2-build3300", - "dotnet-test-xunit": "2.2.0-preview2-build1029" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - } - }, - "imports": [ - "dotnet5.4", - "portable-net451+win8" - ] - } - } -} diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs b/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs deleted file mode 100644 index d5fd26e80..000000000 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs +++ /dev/null @@ -1,8 +0,0 @@ -// Learn more about F# at http://fsharp.org - -open System - -[] -let main argv = - printfn "Hello World!" - 0 // return an integer exit code diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template b/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template deleted file mode 100644 index 581961fa3..000000000 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "debugType": "portable", - "emitEntryPoint": true, - "compilerName": "fsc", - "compile": { - "includeFiles": [ - "Program.fs" - ] - } - }, - "tools": { - "dotnet-compile-fsc":"1.0.0-preview2-*" - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" - }, - "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629" - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs b/src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs deleted file mode 100644 index ae53d091e..000000000 --- a/src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Library - -module Say = - let hello name = - printfn "Hello %s" name \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template b/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template deleted file mode 100644 index 7e88b72f9..000000000 --- a/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "debugType": "portable", - "compilerName": "fsc", - "compile": { - "includeFiles": [ - "Library.fs" - ] - } - }, - "tools": { - "dotnet-compile-fsc":"1.0.0-preview2-*" - }, - "frameworks": { - "netstandard1.6": { - "dependencies": { - "NETStandard.Library":"1.6.0", - "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629" - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/Program.cs b/src/dotnet/commands/dotnet-new/Program.cs index fdec4a841..8d682b303 100644 --- a/src/dotnet/commands/dotnet-new/Program.cs +++ b/src/dotnet/commands/dotnet-new/Program.cs @@ -137,21 +137,11 @@ namespace Microsoft.DotNet.Tools.New { new { Name = "Console", isMsBuild = true }, new { Name = "Web", isMsBuild = true }, - new { Name = "Lib", isMsBuild = true }, - new { Name = "xunittest", isMsBuild = false }, - new { Name = "nunittest", isMsBuild = false } + new { Name = "Lib", isMsBuild = true } } }; - var fsharp = new { Name = "F#", Alias = new[] { "f#", "fs", "fsharp" }, TemplatePrefix = "FSharp", - Templates = new[] - { - new { Name = "Console", isMsBuild = false }, - new { Name = "Lib", isMsBuild = false } - } - }; - - var languages = new[] { csharp, fsharp }; + var languages = new[] { csharp }; string langValuesString = string.Join(", ", languages.Select(l => l.Name)); var typeValues = @@ -168,7 +158,7 @@ namespace Microsoft.DotNet.Tools.New { string languageValue = lang.Value() ?? csharp.Name; - var language = new[] { csharp, fsharp } + var language = new[] { csharp } .FirstOrDefault(l => l.Alias.Contains(languageValue, StringComparer.OrdinalIgnoreCase)); if (language == null) diff --git a/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs b/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs deleted file mode 100644 index 1cd19120e..000000000 --- a/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs +++ /dev/null @@ -1,69 +0,0 @@ -// 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.IO; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.Pack -{ - public class ArtifactPathsCalculator - { - private readonly Project _project; - - private readonly string _configuration; - - public bool PackageOutputPathSet => !string.IsNullOrWhiteSpace(PackageOutputPathParameter); - - public string CompiledArtifactsPathParameter { get; } - - public string PackageOutputPathParameter { get; } - - public bool CompiledArtifactsPathSet => !string.IsNullOrWhiteSpace(CompiledArtifactsPathParameter); - - public string CompiledArtifactsPath => - CompiledArtifactsPathSet ? CompiledArtifactsPathParameter : PackageOutputPath; - - public string PackageOutputPath - { - get - { - if (PackageOutputPathSet) - { - return PackageOutputPathParameter; - } - - var outputPath = Path.Combine( - _project.ProjectDirectory, - Constants.BinDirectoryName, - _configuration); - - return outputPath; - } - } - - public ArtifactPathsCalculator( - Project project, - string compiledArtifactsPath, - string packageOutputPath, - string configuration) - { - _project = project; - CompiledArtifactsPathParameter = compiledArtifactsPath; - PackageOutputPathParameter = packageOutputPath; - _configuration = configuration; - } - - public string InputPathForContext(ProjectContext context) - { - return OutputPathsCalculator.GetOutputPaths(context.ProjectFile, - context.TargetFramework, - context.RuntimeIdentifier, - _configuration, - context.RootDirectory, - CompiledArtifactsPathParameter, - null).CompilationOutputPath; - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/BuildProjectCommand.cs b/src/dotnet/commands/dotnet-pack/BuildProjectCommand.cs deleted file mode 100644 index 27c786fa7..000000000 --- a/src/dotnet/commands/dotnet-pack/BuildProjectCommand.cs +++ /dev/null @@ -1,74 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; - -namespace Microsoft.DotNet.Tools.Pack -{ - internal class BuildProjectCommand - { - private readonly Project _project; - - private readonly string _buildBasePath; - private readonly string _configuration; - - private readonly BuildWorkspace _workspace; - - public BuildProjectCommand( - Project project, - string buildBasePath, - string configuration, - BuildWorkspace workspace) - { - _project = project; - _buildBasePath = buildBasePath; - _configuration = configuration; - _workspace = workspace; - } - - public int Execute() - { - if (HasSourceFiles()) - { - var argsBuilder = new List(); - argsBuilder.Add("--configuration"); - argsBuilder.Add($"{_configuration}"); - - // Passing the Workspace along will flow the version suffix, - // so we don't need to pass it as an argument. - - if (!string.IsNullOrEmpty(_buildBasePath)) - { - argsBuilder.Add("--build-base-path"); - argsBuilder.Add($"{_buildBasePath}"); - } - - argsBuilder.Add($"{_project.ProjectFilePath}"); - - var result = Build.BuildCommand.Run(argsBuilder.ToArray(), _workspace); - - return result; - } - - return 0; - } - - private bool HasSourceFiles() - { - var compilerOptions = _project.GetCompilerOptions( - _project.GetTargetFramework(targetFramework: null).FrameworkName, _configuration); - - if (compilerOptions.CompileInclude == null) - { - return _project.Files.SourceFiles.Any(); - } - - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); - - return includeFiles.Any(); - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/Constants.cs b/src/dotnet/commands/dotnet-pack/NuGet/Constants.cs deleted file mode 100644 index 323cb6122..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/Constants.cs +++ /dev/null @@ -1,64 +0,0 @@ -// 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; - -namespace NuGet.Legacy -{ - public static class Constants - { - /// - /// Represents the ".nupkg" extension. - /// - public static readonly string PackageExtension = ".nupkg"; - - /// - /// Represents the ".nuspec" extension. - /// - public static readonly string ManifestExtension = ".nuspec"; - - /// - /// Represents the ".nupkg.sha512" extension. - /// - public static readonly string HashFileExtension = ".nupkg.sha512"; - - /// - /// Represents the content directory in the package. - /// - public static readonly string ContentDirectory = "content"; - - /// - /// Represents the lib directory in the package. - /// - public static readonly string LibDirectory = "lib"; - - /// - /// Represents the tools directory in the package. - /// - public static readonly string ToolsDirectory = "tools"; - - /// - /// Represents the build directory in the package. - /// - public static readonly string BuildDirectory = "build"; - - public static readonly string BinDirectory = "bin"; - public static readonly string PackageReferenceFile = "packages.config"; - - public static readonly string BeginIgnoreMarker = "NUGET: BEGIN LICENSE TEXT"; - public static readonly string EndIgnoreMarker = "NUGET: END LICENSE TEXT"; - - internal const string PackageRelationshipNamespace = "http://schemas.microsoft.com/packaging/2010/07/"; - - // Starting from nuget 2.0, we use a file with the special name '_._' to represent an empty folder. - public const string PackageEmptyFileName = "_._"; - - // This is temporary until we fix the gallery to have proper first class support for this. - // The magic unpublished date is 1900-01-01T00:00:00 - public static readonly DateTimeOffset Unpublished = new DateTimeOffset(1900, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8)); - - public static readonly IReadOnlyList AssemblyReferencesExtensions - = new string[] { ".dll", ".exe", ".winmd" }; - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/EmptyFrameworkFolderFile.cs b/src/dotnet/commands/dotnet-pack/NuGet/EmptyFrameworkFolderFile.cs deleted file mode 100644 index 9036c4ea1..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/EmptyFrameworkFolderFile.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.IO; - -namespace NuGet.Legacy -{ - /// - /// Represents an empty framework folder in NuGet 2.0+ packages. - /// An empty framework folder is represented by a file named "_._". - /// - internal sealed class EmptyFrameworkFolderFile : PhysicalPackageFile - { - public EmptyFrameworkFolderFile(string directoryPathInPackage) : - base(() => Stream.Null) - { - if (directoryPathInPackage == null) - { - throw new ArgumentNullException(nameof(directoryPathInPackage)); - } - - TargetPath = System.IO.Path.Combine(directoryPathInPackage, Constants.PackageEmptyFileName); - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/FrameworkAssemblyReference.cs b/src/dotnet/commands/dotnet-pack/NuGet/FrameworkAssemblyReference.cs deleted file mode 100644 index 7d0c7e2fc..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/FrameworkAssemblyReference.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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 NuGet.Frameworks; - -namespace NuGet.Legacy -{ - public class FrameworkAssemblyReference - { - public FrameworkAssemblyReference(string assemblyName, IEnumerable supportedFrameworks) - { - if (string.IsNullOrEmpty(assemblyName)) - { - throw new ArgumentException(nameof(assemblyName)); - } - - if (supportedFrameworks == null) - { - throw new ArgumentNullException(nameof(supportedFrameworks)); - } - - AssemblyName = assemblyName; - SupportedFrameworks = supportedFrameworks; - } - - public string AssemblyName { get; private set; } - - public IEnumerable SupportedFrameworks { get; private set; } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/IPackageFile.cs b/src/dotnet/commands/dotnet-pack/NuGet/IPackageFile.cs deleted file mode 100644 index 1e32fe8b6..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/IPackageFile.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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.IO; - -namespace NuGet.Legacy -{ - public interface IPackageFile - { - /// - /// Gets the full path of the file inside the package. - /// - string Path - { - get; - } - - Stream GetStream(); - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/Manifest.cs b/src/dotnet/commands/dotnet-pack/NuGet/Manifest.cs deleted file mode 100644 index 25394c7c4..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/Manifest.cs +++ /dev/null @@ -1,130 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml.Linq; - -namespace NuGet.Legacy -{ - public class Manifest - { - private const string SchemaVersionAttributeName = "schemaVersion"; - - public Manifest(ManifestMetadata metadata) : this(metadata, null) - { - } - - public Manifest(ManifestMetadata metadata, ICollection files) - { - - if (metadata == null) - { - throw new ArgumentNullException(nameof(metadata)); - } - - Metadata = metadata; - - if (files != null) - { - Files = files; - } - } - - public ManifestMetadata Metadata { get; } - - public ICollection Files { get; } = new List(); - - /// - /// Saves the current manifest to the specified stream. - /// - /// The target stream. - public void Save(Stream stream) - { - Save(stream, validate: true, minimumManifestVersion: 1); - } - - /// - /// Saves the current manifest to the specified stream. - /// - /// The target stream. - /// The minimum manifest version that this class must use when saving. - public void Save(Stream stream, int minimumManifestVersion) - { - Save(stream, validate: true, minimumManifestVersion: minimumManifestVersion); - } - - public void Save(Stream stream, bool validate) - { - Save(stream, validate, minimumManifestVersion: 1); - } - - public void Save(Stream stream, bool validate, int minimumManifestVersion) - { - int version = Math.Max(minimumManifestVersion, ManifestVersionUtility.GetManifestVersion(Metadata)); - var schemaNamespace = (XNamespace)ManifestSchemaUtility.GetSchemaNamespace(version); - - var document = new XDocument( - new XElement(schemaNamespace + "package", - Metadata.ToXElement(schemaNamespace))); - - var fileElement = Files.ToXElement(schemaNamespace); - - if (fileElement != null) - { - document.Root.Add(fileElement); - } - - document.Save(stream); - } - - public static Manifest ReadFrom(Stream stream) - { - XDocument document = XDocument.Load(stream); - var schemaNamespace = GetSchemaNamespace(document); - - return ManifestReader.ReadManifest(document); - } - - private static string GetSchemaNamespace(XDocument document) - { - string schemaNamespace = ManifestSchemaUtility.SchemaVersionV1; - var rootNameSpace = document.Root.Name.Namespace; - if (rootNameSpace != null && !String.IsNullOrEmpty(rootNameSpace.NamespaceName)) - { - schemaNamespace = rootNameSpace.NamespaceName; - } - return schemaNamespace; - } - - public static Manifest Create(PackageBuilder copy) - { - var metadata = new ManifestMetadata(); - metadata.Id = copy.Id?.Trim(); - metadata.Version = copy.Version; - metadata.Title = copy.Title?.Trim(); - metadata.Authors = copy.Authors.Distinct(); - metadata.Owners = copy.Owners.Distinct(); - metadata.Tags = string.Join(",", copy.Tags).Trim(); - metadata.Serviceable = copy.Serviceable; - metadata.LicenseUrl = copy.LicenseUrl; - metadata.ProjectUrl = copy.ProjectUrl; - metadata.IconUrl = copy.IconUrl; - metadata.RequireLicenseAcceptance = copy.RequireLicenseAcceptance; - metadata.Description = copy.Description?.Trim(); - metadata.Copyright = copy.Copyright?.Trim(); - metadata.Summary = copy.Summary?.Trim(); - metadata.ReleaseNotes = copy.ReleaseNotes?.Trim(); - metadata.Language = copy.Language?.Trim(); - metadata.DependencySets = copy.DependencySets; - metadata.FrameworkAssemblies = copy.FrameworkAssemblies; - metadata.PackageAssemblyReferences = copy.PackageAssemblyReferences; - metadata.MinClientVersionString = copy.MinClientVersion?.ToString(); - - return new Manifest(metadata); - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestContentFiles.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestContentFiles.cs deleted file mode 100644 index dac2dfaae..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestContentFiles.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 NuGet.Legacy -{ - public class ManifestContentFiles - { - public string Include { get; set; } - - public string Exclude { get; set; } - - public string BuildAction { get; set; } - - public string CopyToOutput { get; set; } - - public string Flatten { get; set; } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestFile.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestFile.cs deleted file mode 100644 index 50bfe1180..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestFile.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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 NuGet.Legacy -{ - public class ManifestFile - { - public ManifestFile(string source, string target, string exclude) - { - Source = source; - Target = target; - Exclude = exclude; - } - - public string Source { get; } - - public string Target { get; } - - public string Exclude { get; } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestMetadata.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestMetadata.cs deleted file mode 100644 index 54199a1a6..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestMetadata.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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.IO; -using System.Linq; -using NuGet.Versioning; - -namespace NuGet.Legacy -{ - public class ManifestMetadata - { - private string _minClientVersionString; - private IEnumerable _authors = Enumerable.Empty(); - private IEnumerable _owners = Enumerable.Empty(); - - [ManifestVersion(5)] - public string MinClientVersionString - { - get { return _minClientVersionString; } - set - { - Version version = null; - if (!string.IsNullOrEmpty(value) && !System.Version.TryParse(value, out version)) - { - // TODO: Resources - throw new InvalidDataException("NuGetResources.Manifest_InvalidMinClientVersion"); - } - - _minClientVersionString = value; - MinClientVersion = version; - } - } - - public Version MinClientVersion { get; private set; } - - public string Id { get; set; } - - public NuGetVersion Version { get; set; } - - public string Title { get; set; } - - public IEnumerable Authors - { - get { return _authors; } - set { _authors = value ?? Enumerable.Empty(); } - } - - public IEnumerable Owners - { - get { return (_owners == null || !_owners.Any()) ? _authors : _owners; } - set { _owners = value ?? Enumerable.Empty(); } - } - - public Uri IconUrl { get; set; } - - public Uri LicenseUrl { get; set; } - - public Uri ProjectUrl { get; set; } - - public bool RequireLicenseAcceptance { get; set; } - - public bool DevelopmentDependency { get; set; } - - public string Description { get; set; } - - public string Summary { get; set; } - - [ManifestVersion(2)] - public string ReleaseNotes { get; set; } - - [ManifestVersion(2)] - public string Copyright { get; set; } - - public string Language { get; set; } - - public string Tags { get; set; } - - public bool Serviceable { get; set; } - - public IEnumerable DependencySets { get; set; } = new List(); - - public ICollection PackageAssemblyReferences { get; set; } = new List(); - - public IEnumerable FrameworkAssemblies { get; set; } = new List(); - - public ICollection ContentFiles { get; set; } = new List(); - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestReader.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestReader.cs deleted file mode 100644 index 68f06996e..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestReader.cs +++ /dev/null @@ -1,313 +0,0 @@ -// 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 NuGet.Frameworks; -using NuGet.Packaging.Core; -using NuGet.Versioning; -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Xml; -using System.Xml.Linq; -// TODO: Resources using NuGet.Resources; - -namespace NuGet.Legacy -{ - internal static class ManifestReader - { - private static readonly string[] RequiredElements = new string[] { "id", "version", "authors", "description" }; - - public static Manifest ReadManifest(XDocument document) - { - var metadataElement = document.Root.ElementsNoNamespace("metadata").FirstOrDefault(); - if (metadataElement == null) - { - // TODO: Resources - throw new InvalidDataException( - String.Format(CultureInfo.CurrentCulture, "NuGetResources.Manifest_RequiredElementMissing {0}", "metadata")); - } - - return new Manifest(ReadMetadata(metadataElement), - ReadFilesList(document.Root.ElementsNoNamespace("files").FirstOrDefault())); - } - - private static ManifestMetadata ReadMetadata(XElement xElement) - { - var manifestMetadata = new ManifestMetadata(); - manifestMetadata.DependencySets = new List(); - manifestMetadata.PackageAssemblyReferences = new List(); - manifestMetadata.MinClientVersionString = xElement.GetOptionalAttributeValue("minClientVersion"); - - // we store all child elements under so that we can easily check for required elements. - var allElements = new HashSet(); - - XNode node = xElement.FirstNode; - while (node != null) - { - var element = node as XElement; - if (element != null) - { - ReadMetadataValue(manifestMetadata, element, allElements); - } - node = node.NextNode; - } - - // now check for required elements, which include , , and - foreach (var requiredElement in RequiredElements) - { - if (!allElements.Contains(requiredElement)) - { - // TODO: Resources - throw new InvalidDataException( - String.Format(CultureInfo.CurrentCulture, "NuGetResources.Manifest_RequiredElementMissing {0}", requiredElement)); - } - } - - return manifestMetadata; - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - private static void ReadMetadataValue(ManifestMetadata manifestMetadata, XElement element, HashSet allElements) - { - if (element.Value == null) - { - return; - } - - allElements.Add(element.Name.LocalName); - - string value = element.Value?.Trim(); - switch (element.Name.LocalName) - { - case "id": - manifestMetadata.Id = value; - break; - case "version": - manifestMetadata.Version = NuGetVersion.Parse(value); - break; - case "authors": - manifestMetadata.Authors = value.Split(',').Select(a => a.Trim()); - break; - case "owners": - manifestMetadata.Owners = value.Split(',').Select(a => a.Trim()); - break; - case "licenseUrl": - manifestMetadata.LicenseUrl = new Uri(value); - break; - case "projectUrl": - manifestMetadata.ProjectUrl = new Uri(value); - break; - case "iconUrl": - manifestMetadata.IconUrl = new Uri(value); - break; - case "requireLicenseAcceptance": - manifestMetadata.RequireLicenseAcceptance = XmlConvert.ToBoolean(value); - break; - case "developmentDependency": - manifestMetadata.DevelopmentDependency = XmlConvert.ToBoolean(value); - break; - case "description": - manifestMetadata.Description = value; - break; - case "summary": - manifestMetadata.Summary = value; - break; - case "releaseNotes": - manifestMetadata.ReleaseNotes = value; - break; - case "copyright": - manifestMetadata.Copyright = value; - break; - case "language": - manifestMetadata.Language = value; - break; - case "title": - manifestMetadata.Title = value; - break; - case "tags": - manifestMetadata.Tags = value; - break; - case "serviceable": - manifestMetadata.Serviceable = XmlConvert.ToBoolean(value); - break; - case "dependencies": - manifestMetadata.DependencySets = ReadDependencySets(element); - break; - case "frameworkAssemblies": - manifestMetadata.FrameworkAssemblies = ReadFrameworkAssemblies(element); - break; - case "references": - manifestMetadata.PackageAssemblyReferences = ReadReferenceSets(element); - break; - case "contentFiles": - manifestMetadata.ContentFiles = ReadContentFiles(element); - break; - } - } - - private static List ReadContentFiles(XElement contentFilesElement) - { - if (!contentFilesElement.HasElements) - { - return new List(0); - } - - var contentFileSets = (from element in contentFilesElement.ElementsNoNamespace("files") - let includeAttribute = element.Attribute("include") - where includeAttribute != null && !string.IsNullOrEmpty(includeAttribute.Value) - let excludeAttribute = element.Attribute("exclude") - let buildActionAttribute = element.Attribute("buildAction") - let copyToOutputAttribute = element.Attribute("copyToOutput") - let flattenAttribute = element.Attribute("flatten") - select new ManifestContentFiles - { - Include = includeAttribute.Value?.Trim(), - Exclude = excludeAttribute == null ? null : excludeAttribute.Value, - BuildAction = buildActionAttribute == null ? null : buildActionAttribute.Value, - CopyToOutput = copyToOutputAttribute == null ? null : copyToOutputAttribute.Value, - Flatten = flattenAttribute == null ? null : flattenAttribute.Value - }).ToList(); - - return contentFileSets; - } - - private static List ReadReferenceSets(XElement referencesElement) - { - if (!referencesElement.HasElements) - { - return new List(0); - } - - if (referencesElement.ElementsNoNamespace("group").Any() && - referencesElement.ElementsNoNamespace("reference").Any()) - { - // TODO: Resources - throw new InvalidDataException("NuGetResources.Manifest_ReferencesHasMixedElements"); - } - - var references = ReadReference(referencesElement, throwIfEmpty: false); - if (references.Count > 0) - { - // old format, is direct child of - var referenceSet = new PackageReferenceSet(references); - return new List { referenceSet }; - } - else - { - var groups = referencesElement.ElementsNoNamespace("group"); - return (from element in groups - select new PackageReferenceSet(element.GetOptionalAttributeValue("targetFramework")?.Trim(), - ReadReference(element, throwIfEmpty: true))).ToList(); - } - } - - public static List ReadReference(XElement referenceElement, bool throwIfEmpty) - { - var references = (from element in referenceElement.ElementsNoNamespace("reference") - let fileAttribute = element.Attribute("file") - where fileAttribute != null && !String.IsNullOrEmpty(fileAttribute.Value) - select fileAttribute.Value?.Trim() - ).ToList(); - - if (throwIfEmpty && references.Count == 0) - { - // TODO: Resources - throw new InvalidDataException("NuGetResources.Manifest_ReferencesIsEmpty"); - } - - return references; - } - - private static List ReadFrameworkAssemblies(XElement frameworkElement) - { - if (!frameworkElement.HasElements) - { - return new List(0); - } - - return (from element in frameworkElement.ElementsNoNamespace("frameworkAssembly") - let assemblyNameAttribute = element.Attribute("assemblyName") - where assemblyNameAttribute != null && !String.IsNullOrEmpty(assemblyNameAttribute.Value) - select new FrameworkAssemblyReference(assemblyNameAttribute.Value?.Trim(), - new[] { NuGetFramework.Parse(element.GetOptionalAttributeValue("targetFramework")?.Trim()) }) - ).ToList(); - } - - private static List ReadDependencySets(XElement dependenciesElement) - { - if (!dependenciesElement.HasElements) - { - return new List(); - } - - // Disallow the element to contain both and - // child elements. Unfortunately, this cannot be enforced by XSD. - if (dependenciesElement.ElementsNoNamespace("dependency").Any() && - dependenciesElement.ElementsNoNamespace("group").Any()) - { - // TODO: Resources - throw new InvalidDataException("NuGetResources.Manifest_DependenciesHasMixedElements"); - } - - var dependencies = ReadDependencies(dependenciesElement); - if (dependencies.Count > 0) - { - // old format, is direct child of - var dependencySet = new PackageDependencySet(dependencies); - return new List { dependencySet }; - } - else - { - var groups = dependenciesElement.ElementsNoNamespace("group"); - return (from element in groups - select new PackageDependencySet(element.GetOptionalAttributeValue("targetFramework")?.Trim(), - ReadDependencies(element))).ToList(); - } - } - - private static List ReadDependencies(XElement containerElement) - { - - - // element is - return (from element in containerElement.ElementsNoNamespace("dependency") - let idElement = element.Attribute("id") - where idElement != null && !String.IsNullOrEmpty(idElement.Value) - select new PackageDependency( - idElement.Value?.Trim(), - VersionRange.Parse(element.GetOptionalAttributeValue("version")?.Trim()), - element.GetOptionalAttributeValue("include")?.Trim()?.Split(',').Select(a => a.Trim()).ToArray(), - element.GetOptionalAttributeValue("exclude")?.Trim()?.Split(',').Select(a => a.Trim()).ToArray() - )).ToList(); - } - - private static List ReadFilesList(XElement xElement) - { - if (xElement == null) - { - return null; - } - - List files = new List(); - foreach (var file in xElement.ElementsNoNamespace("file")) - { - var srcElement = file.Attribute("src"); - if (srcElement == null || String.IsNullOrEmpty(srcElement.Value)) - { - continue; - } - - string target = file.GetOptionalAttributeValue("target")?.Trim(); - string exclude = file.GetOptionalAttributeValue("exclude")?.Trim(); - - // Multiple sources can be specified by using semi-colon separated values. - files.AddRange(from source in srcElement.Value.Trim(';').Split(';') - select new ManifestFile(source?.Trim(), target?.Trim(), exclude?.Trim() )); - } - return files; - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestSchemaUtility.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestSchemaUtility.cs deleted file mode 100644 index c62eeb454..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestSchemaUtility.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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.Globalization; -using System.Linq; - -namespace NuGet.Legacy -{ - internal static class ManifestSchemaUtility - { - /// - /// Baseline schema - /// - internal const string SchemaVersionV1 = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"; - - /// - /// Added copyrights, references and release notes - /// - internal const string SchemaVersionV2 = "http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"; - - /// - /// Used if the version is a semantic version. - /// - internal const string SchemaVersionV3 = "http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"; - - /// - /// Added 'targetFramework' attribute for 'dependency' elements. - /// Allow framework folders under 'content' and 'tools' folders. - /// - internal const string SchemaVersionV4 = "http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"; - - /// - /// Added 'targetFramework' attribute for 'references' elements. - /// Added 'minClientVersion' attribute - /// - internal const string SchemaVersionV5 = "http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd"; - - /// - /// Allows XDT transformation - /// - internal const string SchemaVersionV6 = "http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"; - - private static readonly string[] VersionToSchemaMappings = new[] { - SchemaVersionV1, - SchemaVersionV2, - SchemaVersionV3, - SchemaVersionV4, - SchemaVersionV5, - SchemaVersionV6 - }; - - public static int GetVersionFromNamespace(string @namespace) - { - int index = Math.Max(0, Array.IndexOf(VersionToSchemaMappings, @namespace)); - - // we count version from 1 instead of 0 - return index + 1; - } - - public static string GetSchemaNamespace(int version) - { - // Versions are internally 0-indexed but stored with a 1 index so decrement it by 1 - if (version <= 0 || version > VersionToSchemaMappings.Length) - { - // TODO: Resources - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "NuGetResources.UnknownSchemaVersion", version)); - } - return VersionToSchemaMappings[version - 1]; - } - - public static bool IsKnownSchema(string schemaNamespace) - { - return VersionToSchemaMappings.Contains(schemaNamespace, StringComparer.OrdinalIgnoreCase); - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionAttribute.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionAttribute.cs deleted file mode 100644 index eaaaf0e6f..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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; - -namespace NuGet.Legacy -{ - [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] - internal sealed class ManifestVersionAttribute : Attribute - { - public ManifestVersionAttribute(int version) - { - Version = version; - } - - public int Version { get; private set; } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionUtility.cs b/src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionUtility.cs deleted file mode 100644 index 9a2510403..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/ManifestVersionUtility.cs +++ /dev/null @@ -1,112 +0,0 @@ -// 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; -using System.Linq; -using System.Reflection; - -namespace NuGet.Legacy -{ - internal static class ManifestVersionUtility - { - public const int DefaultVersion = 1; - public const int SemverVersion = 3; - public const int TargetFrameworkSupportForDependencyContentsAndToolsVersion = 4; - public const int TargetFrameworkSupportForReferencesVersion = 5; - public const int XdtTransformationVersion = 6; - - public static int GetManifestVersion(ManifestMetadata metadata) - { - return Math.Max(GetVersionFromObject(metadata), GetMaxVersionFromMetadata(metadata)); - } - - private static int GetMaxVersionFromMetadata(ManifestMetadata metadata) - { - // Important: always add newer version checks at the top - - bool referencesHasTargetFramework = - metadata.PackageAssemblyReferences != null && - metadata.PackageAssemblyReferences.Any(r => r.TargetFramework != null); - - if (referencesHasTargetFramework) - { - return TargetFrameworkSupportForReferencesVersion; - } - - bool dependencyHasTargetFramework = - metadata.DependencySets != null && - metadata.DependencySets.Any(d => d.TargetFramework != null); - - if (dependencyHasTargetFramework) - { - return TargetFrameworkSupportForDependencyContentsAndToolsVersion; - } - - if (metadata.Version.IsPrerelease) - { - return SemverVersion; - } - - return DefaultVersion; - } - - private static int GetVersionFromObject(object obj) - { - // all public, gettable, non-static properties - return obj?.GetType() - .GetRuntimeProperties() - .Where(prop => prop.GetMethod != null && prop.GetMethod.IsPublic && !prop.GetMethod.IsStatic) - .Select(prop => GetVersionFromPropertyInfo(obj, prop)) - .Max() - ?? DefaultVersion; - } - - private static int GetVersionFromPropertyInfo(object obj, PropertyInfo property) - { - var value = property.GetValue(obj, index: null); - if (value == null) - { - return DefaultVersion; - } - - int? version = GetPropertyVersion(property); - if (!version.HasValue) - { - return DefaultVersion; - } - - var stringValue = value as string; - if (stringValue != null) - { - if (!string.IsNullOrEmpty(stringValue)) - { - return version.Value; - } - - return DefaultVersion; - } - - // For all other object types a null check would suffice. - return version.Value; - } - - private static int VisitList(IEnumerable list) - { - int version = DefaultVersion; - - foreach (var item in list) - { - version = Math.Max(version, GetVersionFromObject(item)); - } - - return version; - } - - private static int? GetPropertyVersion(PropertyInfo property) - { - var attribute = property.GetCustomAttribute(); - return attribute?.Version; - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PackageBuilder.cs b/src/dotnet/commands/dotnet-pack/NuGet/PackageBuilder.cs deleted file mode 100644 index fc45583c8..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PackageBuilder.cs +++ /dev/null @@ -1,485 +0,0 @@ -// 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.Globalization; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using NuGet.Packaging; -using NuGet.Packaging.Core; -using NuGet.Versioning; - -namespace NuGet.Legacy -{ - public class PackageBuilder - { - private const string DefaultContentType = "application/octet"; - internal const string ManifestRelationType = "manifest"; - private bool _includeEmptyDirectories = false; - - public PackageBuilder() - { - Files = new List(); - DependencySets = new List(); - FrameworkAssemblies = new List(); - PackageAssemblyReferences = new List(); - ContentFiles = new List(); - Authors = new List(); - Owners = new List(); - Tags = new List(); - } - - public string Id - { - get; - set; - } - - public NuGetVersion Version - { - get; - set; - } - - public string Title - { - get; - set; - } - - public List Authors - { - get; - private set; - } - - public List Owners - { - get; - private set; - } - - public Uri IconUrl - { - get; - set; - } - - public Uri LicenseUrl - { - get; - set; - } - - public Uri ProjectUrl - { - get; - set; - } - - public bool RequireLicenseAcceptance - { - get; - set; - } - - public bool Serviceable - { - get; - set; - } - - public bool DevelopmentDependency - { - get; - set; - } - - public string Description - { - get; - set; - } - - public string Summary - { - get; - set; - } - - public string ReleaseNotes - { - get; - set; - } - - public string Language - { - get; - set; - } - - public List Tags - { - get; - private set; - } - - public string Copyright - { - get; - set; - } - - public List DependencySets - { - get; - private set; - } - - public List Files - { - get; - private set; - } - - public List FrameworkAssemblies - { - get; - private set; - } - - public List PackageAssemblyReferences - { - get; - private set; - } - - public List ContentFiles - { - get; - private set; - } - - public Version MinClientVersion - { - get; - set; - } - - public void Save(Stream stream) - { - // Make sure we're saving a valid package id - PackageIdValidator.ValidatePackageId(Id); - - // Throw if the package doesn't contain any dependencies nor content - if (!Files.Any() && !DependencySets.SelectMany(d => d.Dependencies).Any() && !FrameworkAssemblies.Any()) - { - // TODO: Resources - throw new InvalidOperationException("NuGetResources.CannotCreateEmptyPackage"); - } - - if (!ValidateSpecialVersionLength(Version)) - { - // TODO: Resources - throw new InvalidOperationException("NuGetResources.SemVerSpecialVersionTooLong"); - } - - ValidateDependencySets(Version, DependencySets); - ValidateReferenceAssemblies(Files, PackageAssemblyReferences); - - using (var package = new ZipArchive(stream, ZipArchiveMode.Create)) - { - // Validate and write the manifest - WriteManifest(package, ManifestVersionUtility.DefaultVersion); - - // Write the files to the package - var extensions = WriteFiles(package); - - extensions.Add("nuspec"); - - WriteOpcContentTypes(package, extensions); - } - } - - private static string CreatorInfo() - { - var creatorInfo = new List(); - var assembly = typeof(PackageBuilder).GetTypeInfo().Assembly; - creatorInfo.Add(assembly.FullName); - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - creatorInfo.Add("Linux"); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - creatorInfo.Add("OSX"); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - creatorInfo.Add("Windows"); - } - - var attribute = assembly.GetCustomAttributes().FirstOrDefault(); - if (attribute != null) - { - creatorInfo.Add(attribute.FrameworkDisplayName); - } - - return String.Join(";", creatorInfo); - } - - internal static void ValidateDependencySets(SemanticVersion version, IEnumerable dependencies) - { - if (version == null) - { - // We have independent validation for null-versions. - return; - } - - foreach (var dep in dependencies.SelectMany(s => s.Dependencies)) - { - PackageIdValidator.ValidatePackageId(dep.Id); - } - - // REVIEW: Do we want to keep enfocing this? - /*if (version.IsPrerelease) - { - // If we are creating a production package, do not allow any of the dependencies to be a prerelease version. - var prereleaseDependency = dependencies.SelectMany(set => set.Dependencies).FirstOrDefault(IsPrereleaseDependency); - if (prereleaseDependency != null) - { - throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, "NuGetResources.Manifest_InvalidPrereleaseDependency", prereleaseDependency.ToString())); - } - }*/ - } - - internal static void ValidateReferenceAssemblies(IEnumerable files, IEnumerable packageAssemblyReferences) - { - var libFiles = new HashSet(from file in files - where !string.IsNullOrEmpty(file.Path) && file.Path.StartsWith("lib", StringComparison.OrdinalIgnoreCase) - select Path.GetFileName(file.Path), StringComparer.OrdinalIgnoreCase); - - foreach (var reference in packageAssemblyReferences.SelectMany(p => p.References)) - { - if (!libFiles.Contains(reference) && - !libFiles.Contains(reference + ".dll") && - !libFiles.Contains(reference + ".exe") && - !libFiles.Contains(reference + ".winmd")) - { - // TODO: Resources - throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, "NuGetResources.Manifest_InvalidReference", reference)); - } - } - } - - public void Populate(ManifestMetadata manifestMetadata) - { - Id = manifestMetadata.Id; - Version = manifestMetadata.Version; - Title = manifestMetadata.Title; - AppendIfNotNull(Authors, manifestMetadata.Authors); - AppendIfNotNull(Owners, manifestMetadata.Owners); - IconUrl = manifestMetadata.IconUrl; - LicenseUrl = manifestMetadata.LicenseUrl; - ProjectUrl = manifestMetadata.ProjectUrl; - RequireLicenseAcceptance = manifestMetadata.RequireLicenseAcceptance; - DevelopmentDependency = manifestMetadata.DevelopmentDependency; - Serviceable = manifestMetadata.Serviceable; - Description = manifestMetadata.Description; - Summary = manifestMetadata.Summary; - ReleaseNotes = manifestMetadata.ReleaseNotes; - Language = manifestMetadata.Language; - Copyright = manifestMetadata.Copyright; - MinClientVersion = manifestMetadata.MinClientVersion; - - if (manifestMetadata.Tags != null) - { - Tags.AddRange(ParseTags(manifestMetadata.Tags)); - } - - AppendIfNotNull(DependencySets, manifestMetadata.DependencySets); - AppendIfNotNull(FrameworkAssemblies, manifestMetadata.FrameworkAssemblies); - AppendIfNotNull(PackageAssemblyReferences, manifestMetadata.PackageAssemblyReferences); - AppendIfNotNull(ContentFiles, manifestMetadata.ContentFiles); - } - - public void PopulateFiles(string basePath, IEnumerable files) - { - foreach (var file in files) - { - AddFiles(basePath, file.Source, file.Target, file.Exclude); - } - } - - private void WriteManifest(ZipArchive package, int minimumManifestVersion) - { - string path = Id + Constants.ManifestExtension; - - WriteOpcManifestRelationship(package, path); - - ZipArchiveEntry entry = package.CreateEntry(path, CompressionLevel.Optimal); - - using (Stream stream = entry.Open()) - { - Manifest manifest = Manifest.Create(this); - manifest.Save(stream, minimumManifestVersion); - } - } - - private HashSet WriteFiles(ZipArchive package) - { - var extensions = new HashSet(StringComparer.OrdinalIgnoreCase); - - // Add files that might not come from expanding files on disk - foreach (var file in Files.Distinct()) - { - using (Stream stream = file.GetStream()) - { - try - { - CreatePart(package, file.Path, stream); - - var fileExtension = Path.GetExtension(file.Path); - - // We have files without extension (e.g. the executables for Nix) - if (!string.IsNullOrEmpty(fileExtension)) - { - extensions.Add(fileExtension.Substring(1)); - } - } - catch - { - throw; - } - } - } - - return extensions; - } - - private void AddFiles(string basePath, string source, string destination, string exclude = null) - { - List searchFiles = PathResolver.ResolveSearchPattern(basePath, source, destination, _includeEmptyDirectories).ToList(); - - ExcludeFiles(searchFiles, basePath, exclude); - - if (!PathResolver.IsWildcardSearch(source) && !PathResolver.IsDirectoryPath(source) && !searchFiles.Any()) - { - // TODO: Resources - throw new FileNotFoundException( - String.Format(CultureInfo.CurrentCulture, "NuGetResources.PackageAuthoring_FileNotFound {0}", source)); - } - - - Files.AddRange(searchFiles); - } - - private static void ExcludeFiles(List searchFiles, string basePath, string exclude) - { - if (String.IsNullOrEmpty(exclude)) - { - return; - } - - // One or more exclusions may be specified in the file. Split it and prepend the base path to the wildcard provided. - var exclusions = exclude.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - foreach (var item in exclusions) - { - string wildCard = PathResolver.NormalizeWildcardForExcludedFiles(basePath, item); - PathResolver.FilterPackageFiles(searchFiles, p => p.SourcePath, new[] { wildCard }); - } - } - - private static void CreatePart(ZipArchive package, string path, Stream sourceStream) - { - if (PackageHelper.IsManifest(path)) - { - return; - } - - var entry = package.CreateEntry(PathUtility.GetPathWithForwardSlashes(path), CompressionLevel.Optimal); - using (var stream = entry.Open()) - { - sourceStream.CopyTo(stream); - } - } - - /// - /// Tags come in this format. tag1 tag2 tag3 etc.. - /// - private static IEnumerable ParseTags(string tags) - { - return from tag in tags.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) - select tag.Trim(); - } - - private static bool IsPrereleaseDependency(PackageDependency dependency) - { - return dependency.VersionRange.MinVersion?.IsPrerelease == true || - dependency.VersionRange.MaxVersion?.IsPrerelease == true; - } - - private static bool ValidateSpecialVersionLength(SemanticVersion version) - { - if (!version.IsPrerelease) - { - return true; - } - - return version == null || version.Release.Length <= 20; - } - - private static void WriteOpcManifestRelationship(ZipArchive package, string path) - { - ZipArchiveEntry relsEntry = package.CreateEntry("_rels/.rels", CompressionLevel.Optimal); - - using (var writer = new StreamWriter(relsEntry.Open())) - { - writer.Write(String.Format(@" - - -", path, GenerateRelationshipId())); - writer.Flush(); - } - } - - private static void WriteOpcContentTypes(ZipArchive package, HashSet extensions) - { - // OPC backwards compatibility - ZipArchiveEntry relsEntry = package.CreateEntry("[Content_Types].xml", CompressionLevel.Optimal); - - using (var writer = new StreamWriter(relsEntry.Open())) - { - writer.Write(@" - - "); - foreach (var extension in extensions) - { - writer.Write(@""); - } - writer.Write(""); - writer.Flush(); - } - } - - // Generate a relationship id for compatibility - private static string GenerateRelationshipId() - { - return "R" + Guid.NewGuid().ToString("N").Substring(0, 16); - } - - private static void AppendIfNotNull(List collection, IEnumerable toAdd) - { - if (toAdd != null) - { - collection.AddRange(toAdd); - } - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PackageDependencySet.cs b/src/dotnet/commands/dotnet-pack/NuGet/PackageDependencySet.cs deleted file mode 100644 index 1c6fb8244..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PackageDependencySet.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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; -using NuGet.Frameworks; -using NuGet.Packaging.Core; - -namespace NuGet.Legacy -{ - public class PackageDependencySet - { - public PackageDependencySet(IEnumerable dependencies) - : this((NuGetFramework)null, dependencies) - { - } - - public PackageDependencySet(string targetFramework, IEnumerable dependencies) - : this(targetFramework != null ? NuGetFramework.Parse(targetFramework) : null, dependencies) - { - } - - public PackageDependencySet(NuGetFramework targetFramework, IEnumerable dependencies) - { - if (dependencies == null) - { - throw new ArgumentNullException(nameof(dependencies)); - } - - TargetFramework = targetFramework; - Dependencies = dependencies.ToArray(); - } - - public NuGetFramework TargetFramework { get; } - - public IReadOnlyList Dependencies { get; } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PackageIdValidator.cs b/src/dotnet/commands/dotnet-pack/NuGet/PackageIdValidator.cs deleted file mode 100644 index 60a1819d1..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PackageIdValidator.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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.Globalization; -using System.Text.RegularExpressions; - -namespace NuGet.Legacy -{ - public static class PackageIdValidator - { - private static readonly Regex _idRegex = new Regex(@"^\w+([_.-]\w+)*$", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - - internal const int MaxPackageIdLength = 100; - - public static bool IsValidPackageId(string packageId) - { - if (packageId == null) - { - throw new ArgumentNullException(nameof(packageId)); - } - return _idRegex.IsMatch(packageId); - } - - public static void ValidatePackageId(string packageId) - { - if (packageId.Length > MaxPackageIdLength) - { - // TODO: Resources - throw new ArgumentException("NuGetResources.Manifest_IdMaxLengthExceeded"); - } - - if (!IsValidPackageId(packageId)) - { - // TODO: Resources - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "NuGetResources.InvalidPackageId", packageId)); - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PackageMetadataXmlExtensions.cs b/src/dotnet/commands/dotnet-pack/NuGet/PackageMetadataXmlExtensions.cs deleted file mode 100644 index 14e09d5c8..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PackageMetadataXmlExtensions.cs +++ /dev/null @@ -1,273 +0,0 @@ -// 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; -using System.Xml.Linq; -using NuGet.Frameworks; -using NuGet.Packaging.Core; -using NuGet.Versioning; - -namespace NuGet.Legacy -{ - internal static class PackageMetadataXmlExtensions - { - private const string References = "references"; - private const string Reference = "reference"; - private const string Group = "group"; - private const string File = "file"; - private const string TargetFramework = "targetFramework"; - private const string FrameworkAssemblies = "frameworkAssemblies"; - private const string FrameworkAssembly = "frameworkAssembly"; - private const string AssemblyName = "assemblyName"; - private const string Dependencies = "dependencies"; - private const string Files = "files"; - - public static XElement ToXElement(this ManifestMetadata metadata, XNamespace ns) - { - var elem = new XElement(ns + "metadata"); - if (metadata.MinClientVersionString != null) - { - elem.SetAttributeValue("minClientVersion", metadata.MinClientVersionString); - } - - elem.Add(new XElement(ns + "id", metadata.Id)); - elem.Add(new XElement(ns + "version", metadata.Version.ToString())); - AddElementIfNotNull(elem, ns, "title", metadata.Title); - AddElementIfNotNull(elem, ns, "authors", metadata.Authors, authors => string.Join(",", authors)); - AddElementIfNotNull(elem, ns, "owners", metadata.Owners, owners => string.Join(",", owners)); - AddElementIfNotNull(elem, ns, "licenseUrl", metadata.LicenseUrl); - AddElementIfNotNull(elem, ns, "projectUrl", metadata.ProjectUrl); - AddElementIfNotNull(elem, ns, "iconUrl", metadata.IconUrl); - elem.Add(new XElement(ns + "requireLicenseAcceptance", metadata.RequireLicenseAcceptance)); - if (metadata.DevelopmentDependency == true) - { - elem.Add(new XElement(ns + "developmentDependency", metadata.DevelopmentDependency)); - } - AddElementIfNotNull(elem, ns, "description", metadata.Description); - AddElementIfNotNull(elem, ns, "summary", metadata.Summary); - AddElementIfNotNull(elem, ns, "releaseNotes", metadata.ReleaseNotes); - AddElementIfNotNull(elem, ns, "copyright", metadata.Copyright); - AddElementIfNotNull(elem, ns, "language", metadata.Language); - AddElementIfNotNull(elem, ns, "tags", metadata.Tags); - if (metadata.Serviceable) - { - elem.Add(new XElement(ns + "serviceable", metadata.Serviceable)); - } - - elem.Add(GetXElementFromGroupableItemSets( - ns, - metadata.DependencySets, - set => set.TargetFramework != null, - set => set.TargetFramework.GetFrameworkString(), - set => set.Dependencies, - GetXElementFromPackageDependency, - Dependencies, - TargetFramework)); - - elem.Add(GetXElementFromGroupableItemSets( - ns, - metadata.PackageAssemblyReferences, - set => set.TargetFramework != null, - set => set.TargetFramework.GetFrameworkString(), - set => set.References, - GetXElementFromPackageReference, - References, - TargetFramework)); - - elem.Add(GetXElementFromFrameworkAssemblies(ns, metadata.FrameworkAssemblies)); - elem.Add(GetXElementFromManifestContentFiles(ns, metadata.ContentFiles)); - - return elem; - } - - - public static XElement ToXElement(this IEnumerable fileList, XNamespace ns) - { - return GetXElementFromManifestFiles(ns, fileList); - } - - public static string GetOptionalAttributeValue(this XElement element, string localName, string namespaceName = null) - { - XAttribute attr; - if (string.IsNullOrEmpty(namespaceName)) - { - attr = element.Attribute(localName); - } - else - { - attr = element.Attribute(XName.Get(localName, namespaceName)); - } - return attr != null ? attr.Value : null; - } - - public static string GetOptionalElementValue(this XContainer element, string localName, string namespaceName = null) - { - XElement child; - if (string.IsNullOrEmpty(namespaceName)) - { - child = element.ElementsNoNamespace(localName).FirstOrDefault(); - } - else - { - child = element.Element(XName.Get(localName, namespaceName)); - } - return child != null ? child.Value : null; - } - - public static IEnumerable ElementsNoNamespace(this XContainer container, string localName) - { - return container.Elements().Where(e => e.Name.LocalName == localName); - } - - public static IEnumerable ElementsNoNamespace(this IEnumerable source, string localName) - { - return source.Elements().Where(e => e.Name.LocalName == localName); - } - - private static XElement GetXElementFromGroupableItemSets( - XNamespace ns, - IEnumerable objectSets, - Func isGroupable, - Func getGroupIdentifer, - Func> getItems, - Func getXElementFromItem, - string parentName, - string identiferAttributeName) - { - if (objectSets == null || !objectSets.Any()) - { - return null; - } - - var groupableSets = new List(); - var ungroupableSets = new List(); - - foreach (var set in objectSets) - { - if (isGroupable(set)) - { - groupableSets.Add(set); - } - else - { - ungroupableSets.Add(set); - } - } - - var childElements = new List(); - if (!groupableSets.Any()) - { - // none of the item sets are groupable, then flatten the items - childElements.AddRange(objectSets.SelectMany(getItems).Select(item => getXElementFromItem(ns, item))); - } - else - { - // move the group with null target framework (if any) to the front just for nicer display in UI - foreach (var set in ungroupableSets.Concat(groupableSets)) - { - var groupElem = new XElement( - ns + Group, - getItems(set).Select(item => getXElementFromItem(ns, item)).ToArray()); - - if (isGroupable(set)) - { - groupElem.SetAttributeValue(identiferAttributeName, getGroupIdentifer(set)); - } - - childElements.Add(groupElem); - } - } - - return new XElement(ns + parentName, childElements.ToArray()); - } - - private static XElement GetXElementFromPackageReference(XNamespace ns, string reference) - { - return new XElement(ns + Reference, new XAttribute(File, reference)); - } - - private static XElement GetXElementFromPackageDependency(XNamespace ns, PackageDependency dependency) - { - return new XElement(ns + "dependency", - new XAttribute("id", dependency.Id), - dependency.VersionRange != null ? new XAttribute("version", dependency.VersionRange.ToString()) : null, - dependency.Include != null && dependency.Include.Any() ? new XAttribute("include", string.Join(",", dependency.Include)) : null, - dependency.Exclude != null && dependency.Exclude.Any() ? new XAttribute("exclude", string.Join(",", dependency.Exclude)) : null); - } - - private static XElement GetXElementFromFrameworkAssemblies(XNamespace ns, IEnumerable references) - { - if (references == null || !references.Any()) - { - return null; - } - - return new XElement( - ns + FrameworkAssemblies, - references.Select(reference => - new XElement(ns + FrameworkAssembly, - new XAttribute(AssemblyName, reference.AssemblyName), - reference.SupportedFrameworks != null && reference.SupportedFrameworks.Any() ? - new XAttribute("targetFramework", string.Join(", ", reference.SupportedFrameworks.Select(f => f.GetFrameworkString()))) : - null))); - } - - private static XElement GetXElementFromManifestFiles(XNamespace ns, IEnumerable files) - { - if (files == null || !files.Any()) - { - return null; - } - - return new XElement(ns + Files, - files.Select(file => - new XElement(ns + File, - new XAttribute("src", file.Source), - new XAttribute("target", file.Target), - new XAttribute("exclude", file.Exclude) - ))); - } - - private static XElement GetXElementFromManifestContentFiles(XNamespace ns, IEnumerable contentFiles) - { - if (contentFiles == null || !contentFiles.Any()) - { - return null; - } - - return new XElement(ns + "contentFiles", - contentFiles.Select(file => - new XElement(ns + File, - new XAttribute("include", file.Include), - new XAttribute("exclude", file.Exclude), - new XAttribute("buildAction", file.BuildAction), - new XAttribute("copyToOutput", file.CopyToOutput), - new XAttribute("flatten", file.Flatten) - ))); - } - - private static void AddElementIfNotNull(XElement parent, XNamespace ns, string name, T value) - where T : class - { - if (value != null) - { - parent.Add(new XElement(ns + name, value)); - } - } - - private static void AddElementIfNotNull(XElement parent, XNamespace ns, string name, T value, Func process) - where T : class - { - if (value != null) - { - var processed = process(value); - if (processed != null) - { - parent.Add(new XElement(ns + name, processed)); - } - } - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PackageReferenceSet.cs b/src/dotnet/commands/dotnet-pack/NuGet/PackageReferenceSet.cs deleted file mode 100644 index 31de42634..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PackageReferenceSet.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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; -using NuGet.Frameworks; - -namespace NuGet.Legacy -{ - public class PackageReferenceSet - { - public PackageReferenceSet(IEnumerable references) - : this((NuGetFramework)null, references) - { - } - - public PackageReferenceSet(string targetFramework, IEnumerable references) - : this(targetFramework != null ? NuGetFramework.Parse(targetFramework) : null, references) - { - } - - public PackageReferenceSet(NuGetFramework targetFramework, IEnumerable references) - { - if (references == null) - { - throw new ArgumentNullException(nameof(references)); - } - - TargetFramework = targetFramework; - References = references.ToArray(); - } - - public IReadOnlyCollection References { get; } - - public NuGetFramework TargetFramework { get; } - - } -} diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PathResolver.cs b/src/dotnet/commands/dotnet-pack/NuGet/PathResolver.cs deleted file mode 100644 index 79e845ae2..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PathResolver.cs +++ /dev/null @@ -1,304 +0,0 @@ -// 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.IO; -using System.Linq; -using System.Text.RegularExpressions; - -namespace NuGet.Legacy -{ - public static class PathResolver - { - /// - /// Returns a collection of files from the source that matches the wildcard. - /// - /// The collection of files to match. - /// Function that returns the path to filter a package file - /// The wildcards to apply to match the path with. - /// - public static IEnumerable GetMatches(IEnumerable source, Func getPath, IEnumerable wildcards) - { - var filters = wildcards.Select(WildcardToRegex); - return source.Where(item => - { - string path = getPath(item); - return filters.Any(f => f.IsMatch(path)); - }); - } - - /// - /// Removes files from the source that match any wildcard. - /// - public static void FilterPackageFiles(ICollection source, Func getPath, IEnumerable wildcards) - { - var matchedFiles = new HashSet(GetMatches(source, getPath, wildcards)); - var itemsToRemove = source.Where(matchedFiles.Contains).ToArray(); - foreach (var item in itemsToRemove) - { - source.Remove(item); - } - } - - public static string NormalizeWildcardForExcludedFiles(string basePath, string wildcard) - { - if (wildcard.StartsWith("**", StringComparison.OrdinalIgnoreCase)) - { - // Allow any path to match the first '**' segment, see issue 2891 for more details. - return wildcard; - } - basePath = NormalizeBasePath(basePath, ref wildcard); - return Path.Combine(basePath, wildcard); - } - - private static Regex WildcardToRegex(string wildcard) - { - var pattern = Regex.Escape(wildcard); - if (Path.DirectorySeparatorChar == '/') - { - // regex wildcard adjustments for *nix-style file systems - pattern = pattern - .Replace(@"\*\*/", ".*") //For recursive wildcards /**/, include the current directory. - .Replace(@"\*\*", ".*") // For recursive wildcards that don't end in a slash e.g. **.txt would be treated as a .txt file at any depth - .Replace(@"\*", @"[^/]*(/)?") // For non recursive searches, limit it any character that is not a directory separator - .Replace(@"\?", "."); // ? translates to a single any character - } - else - { - // regex wildcard adjustments for Windows-style file systems - pattern = pattern - .Replace("/", @"\\") // On Windows, / is treated the same as \. - .Replace(@"\*\*\\", ".*") //For recursive wildcards \**\, include the current directory. - .Replace(@"\*\*", ".*") // For recursive wildcards that don't end in a slash e.g. **.txt would be treated as a .txt file at any depth - .Replace(@"\*", @"[^\\]*(\\)?") // For non recursive searches, limit it any character that is not a directory separator - .Replace(@"\?", "."); // ? translates to a single any character - } - - return new Regex('^' + pattern + '$', RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - } - - internal static IEnumerable ResolveSearchPattern(string basePath, string searchPath, string targetPath, bool includeEmptyDirectories) - { - string normalizedBasePath; - IEnumerable searchResults = PerformWildcardSearchInternal(basePath, searchPath, includeEmptyDirectories, out normalizedBasePath); - - return searchResults.Select(result => - result.IsFile - ? new PhysicalPackageFile - { - SourcePath = result.Path, - TargetPath = ResolvePackagePath(normalizedBasePath, searchPath, result.Path, targetPath) - } - : new EmptyFrameworkFolderFile(ResolvePackagePath(normalizedBasePath, searchPath, result.Path, targetPath)) - { - SourcePath = result.Path - } - ); - } - - public static IEnumerable PerformWildcardSearch(string basePath, string searchPath) - { - string normalizedBasePath; - var searchResults = PerformWildcardSearchInternal(basePath, searchPath, includeEmptyDirectories: false, normalizedBasePath: out normalizedBasePath); - return searchResults.Select(s => s.Path); - } - - private static IEnumerable PerformWildcardSearchInternal(string basePath, string searchPath, bool includeEmptyDirectories, out string normalizedBasePath) - { - if (!searchPath.StartsWith(@"\\", StringComparison.OrdinalIgnoreCase) - && Path.DirectorySeparatorChar != '/') - { - //If the system's DirectorySeparatorChar is '/' we're probably dealing with Mac or *nix - // In any case, if '/' is the separator, we don't want to trim off the first char ever - // since it would completely change the meaning of the path - // eg: /var/somedir/ is not at all the same as var/somedir (relative vs absolute) - - // If we aren't dealing with network paths, trim the leading slash. - searchPath = searchPath.TrimStart(Path.DirectorySeparatorChar); - } - - bool searchDirectory = false; - - // If the searchPath ends with \ or /, we treat searchPath as a directory, - // and will include everything under it, recursively - if (IsDirectoryPath(searchPath)) - { - searchPath = searchPath + "**" + Path.DirectorySeparatorChar + "*"; - searchDirectory = true; - } - - basePath = NormalizeBasePath(basePath, ref searchPath); - normalizedBasePath = GetPathToEnumerateFrom(basePath, searchPath); - - // Append the basePath to searchPattern and get the search regex. We need to do this because the search regex is matched from line start. - Regex searchRegex = WildcardToRegex(Path.Combine(basePath, searchPath)); - - // This is a hack to prevent enumerating over the entire directory tree if the only wildcard characters are the ones in the file name. - // If the path portion of the search path does not contain any wildcard characters only iterate over the TopDirectory. - SearchOption searchOption = SearchOption.AllDirectories; - // (a) Path is not recursive search - bool isRecursiveSearch = searchPath.IndexOf("**", StringComparison.OrdinalIgnoreCase) != -1; - // (b) Path does not have any wildcards. - bool isWildcardPath = Path.GetDirectoryName(searchPath).Contains('*'); - if (!isRecursiveSearch && !isWildcardPath) - { - searchOption = SearchOption.TopDirectoryOnly; - } - - // Starting from the base path, enumerate over all files and match it using the wildcard expression provided by the user. - // Note: We use Directory.GetFiles() instead of Directory.EnumerateFiles() here to support Mono - var matchedFiles = from file in Directory.GetFiles(normalizedBasePath, "*.*", searchOption) - where searchRegex.IsMatch(file) - select new SearchPathResult(file, isFile: true); - - if (!includeEmptyDirectories) - { - return matchedFiles; - } - - // retrieve empty directories - // Note: We use Directory.GetDirectories() instead of Directory.EnumerateDirectories() here to support Mono - var matchedDirectories = from directory in Directory.GetDirectories(normalizedBasePath, "*.*", searchOption) - where searchRegex.IsMatch(directory) && IsEmptyDirectory(directory) - select new SearchPathResult(directory, isFile: false); - - if (searchDirectory && IsEmptyDirectory(normalizedBasePath)) - { - matchedDirectories = matchedDirectories.Concat(new [] { new SearchPathResult(normalizedBasePath, isFile: false) }); - } - - return matchedFiles.Concat(matchedDirectories); - } - - internal static string GetPathToEnumerateFrom(string basePath, string searchPath) - { - string basePathToEnumerate; - int wildcardIndex = searchPath.IndexOf('*'); - if (wildcardIndex == -1) - { - // For paths without wildcard, we could either have base relative paths (such as lib\foo.dll) or paths outside the base path - // (such as basePath: C:\packages and searchPath: D:\packages\foo.dll) - // In this case, Path.Combine would pick up the right root to enumerate from. - var searchRoot = Path.GetDirectoryName(searchPath); - basePathToEnumerate = Path.Combine(basePath, searchRoot); - } - else - { - // If not, find the first directory separator and use the path to the left of it as the base path to enumerate from. - int directorySeparatoryIndex = searchPath.LastIndexOf(Path.DirectorySeparatorChar, wildcardIndex); - if (directorySeparatoryIndex == -1) - { - // We're looking at a path like "NuGet*.dll", NuGet*\bin\release\*.dll - // In this case, the basePath would continue to be the path to begin enumeration from. - basePathToEnumerate = basePath; - } - else - { - string nonWildcardPortion = searchPath.Substring(0, directorySeparatoryIndex); - basePathToEnumerate = Path.Combine(basePath, nonWildcardPortion); - } - } - return basePathToEnumerate; - } - - /// - /// Determins the path of the file inside a package. - /// For recursive wildcard paths, we preserve the path portion beginning with the wildcard. - /// For non-recursive wildcard paths, we use the file name from the actual file path on disk. - /// - internal static string ResolvePackagePath(string searchDirectory, string searchPattern, string fullPath, string targetPath) - { - string packagePath; - bool isDirectorySearch = IsDirectoryPath(searchPattern); - bool isWildcardSearch = IsWildcardSearch(searchPattern); - bool isRecursiveWildcardSearch = isWildcardSearch && searchPattern.IndexOf("**", StringComparison.OrdinalIgnoreCase) != -1; - - if ((isRecursiveWildcardSearch || isDirectorySearch) && fullPath.StartsWith(searchDirectory, StringComparison.OrdinalIgnoreCase)) - { - // The search pattern is recursive. Preserve the non-wildcard portion of the path. - // e.g. Search: X:\foo\**\*.cs results in SearchDirectory: X:\foo and a file path of X:\foo\bar\biz\boz.cs - // Truncating X:\foo\ would result in the package path. - packagePath = fullPath.Substring(searchDirectory.Length).TrimStart(Path.DirectorySeparatorChar); - } - else if (!isWildcardSearch && Path.GetExtension(searchPattern).Equals(Path.GetExtension(targetPath), StringComparison.OrdinalIgnoreCase)) - { - // If the search does not contain wild cards, and the target path shares the same extension, copy it - // e.g. --> Content\css\ie.css - return targetPath; - } - else - { - packagePath = Path.GetFileName(fullPath); - } - return Path.Combine(targetPath ?? String.Empty, packagePath); - } - - private static readonly string OneDotSlash = "." + Path.DirectorySeparatorChar; - private static readonly string TwoDotSlash = ".." + Path.DirectorySeparatorChar; - - internal static string NormalizeBasePath(string basePath, ref string searchPath) - { - // If no base path is provided, use the current directory. - basePath = String.IsNullOrEmpty(basePath) ? OneDotSlash : basePath; - - // If the search path is relative, transfer the ..\ portion to the base path. - // This needs to be done because the base path determines the root for our enumeration. - while (searchPath.StartsWith(TwoDotSlash, StringComparison.OrdinalIgnoreCase)) - { - basePath = Path.Combine(basePath, TwoDotSlash); - searchPath = searchPath.Substring(TwoDotSlash.Length); - } - - return Path.GetFullPath(basePath); - } - - /// - /// Returns true if the path contains any wildcard characters. - /// - internal static bool IsWildcardSearch(string filter) - { - return filter.IndexOf('*') != -1; - } - - internal static bool IsDirectoryPath(string path) - { - return path != null && path.Length > 1 && - (path[path.Length - 1] == Path.DirectorySeparatorChar || - path[path.Length - 1] == Path.AltDirectorySeparatorChar); - } - - private static bool IsEmptyDirectory(string directory) - { - return !Directory.EnumerateFileSystemEntries(directory).Any(); - } - - private struct SearchPathResult - { - private readonly string _path; - private readonly bool _isFile; - - public string Path - { - get - { - return _path; - } - } - - public bool IsFile - { - get - { - return _isFile; - } - } - - public SearchPathResult(string path, bool isFile) - { - _path = path; - _isFile = isFile; - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PathUtility.cs b/src/dotnet/commands/dotnet-pack/NuGet/PathUtility.cs deleted file mode 100644 index adfb51f98..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PathUtility.cs +++ /dev/null @@ -1,33 +0,0 @@ -// 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.IO; - -namespace NuGet.Legacy -{ - internal static class PathUtility - { - public static string GetPathWithForwardSlashes(string path) - { - return path.Replace('\\', '/'); - } - - public static string GetPathWithBackSlashes(string path) - { - return path.Replace('/', '\\'); - } - - public static string GetPathWithDirectorySeparator(string path) - { - if (Path.DirectorySeparatorChar == '/') - { - return GetPathWithForwardSlashes(path); - } - else - { - return GetPathWithBackSlashes(path); - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/NuGet/PhysicalPackageFile.cs b/src/dotnet/commands/dotnet-pack/NuGet/PhysicalPackageFile.cs deleted file mode 100644 index a6e100c6d..000000000 --- a/src/dotnet/commands/dotnet-pack/NuGet/PhysicalPackageFile.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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.IO; - -namespace NuGet.Legacy -{ - public class PhysicalPackageFile : IPackageFile - { - private readonly Func _streamFactory; - - public PhysicalPackageFile() - { - } - - public PhysicalPackageFile(PhysicalPackageFile file) - { - SourcePath = file.SourcePath; - TargetPath = file.TargetPath; - } - - internal PhysicalPackageFile(Func streamFactory) - { - _streamFactory = streamFactory; - } - - /// - /// Path on disk - /// - public string SourcePath { get; set; } - - /// - /// Path in package - /// - public string TargetPath { get; set; } - - public string Path - { - get - { - return TargetPath; - } - } - - public Stream GetStream() - { - return _streamFactory != null ? _streamFactory() : File.OpenRead(SourcePath); - } - - public override string ToString() - { - return TargetPath; - } - - public override bool Equals(object obj) - { - var file = obj as PhysicalPackageFile; - - return file != null && string.Equals(SourcePath, file.SourcePath, StringComparison.OrdinalIgnoreCase) && - string.Equals(TargetPath, file.TargetPath, StringComparison.OrdinalIgnoreCase); - } - - public override int GetHashCode() - { - int hash = 0; - if (SourcePath != null) - { - hash = SourcePath.GetHashCode(); - } - - if (TargetPath != null) - { - hash = hash * 4567 + TargetPath.GetHashCode(); - } - - return hash; - } - } -} diff --git a/src/dotnet/commands/dotnet-pack3/Pack3Command.cs b/src/dotnet/commands/dotnet-pack/PackCommand.cs similarity index 96% rename from src/dotnet/commands/dotnet-pack3/Pack3Command.cs rename to src/dotnet/commands/dotnet-pack/PackCommand.cs index d5faa29d8..cb0ad685e 100644 --- a/src/dotnet/commands/dotnet-pack3/Pack3Command.cs +++ b/src/dotnet/commands/dotnet-pack/PackCommand.cs @@ -6,9 +6,9 @@ using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools.MSBuild; -namespace Microsoft.DotNet.Tools.Pack3 +namespace Microsoft.DotNet.Tools.Pack { - public class Pack3Command + public class PackCommand { public static int Run(string[] args) { @@ -16,8 +16,8 @@ namespace Microsoft.DotNet.Tools.Pack3 CommandLineApplication cmd = new CommandLineApplication(throwOnUnexpectedArg: false) { - Name = "pack3", - FullName = "pack3", + Name = "pack", + FullName = "pack", Description = "pack for msbuild", AllowArgumentSeparator = true, ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText diff --git a/src/dotnet/commands/dotnet-pack/PackageGenerator.cs b/src/dotnet/commands/dotnet-pack/PackageGenerator.cs deleted file mode 100644 index 9d88b1df6..000000000 --- a/src/dotnet/commands/dotnet-pack/PackageGenerator.cs +++ /dev/null @@ -1,420 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing; -using Microsoft.DotNet.ProjectModel.FileSystemGlobbing.Abstractions; -using Microsoft.DotNet.ProjectModel.Resources; -using Microsoft.DotNet.ProjectModel.Utilities; -using Microsoft.DotNet.Tools.Pack; -using NuGet.Legacy; -using NuGet.Frameworks; -using NuGet.Packaging.Core; -using NuGet.Versioning; -using PackageBuilder = NuGet.Legacy.PackageBuilder; -using NuGetConstants = NuGet.Legacy.Constants; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public class PackageGenerator - { - protected ArtifactPathsCalculator ArtifactPathsCalculator { get; } - - protected Project Project { get; } - - protected string Configuration { get; } - - protected PackageBuilder PackageBuilder { get; private set; } - - public PackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator) - { - ArtifactPathsCalculator = artifactPathsCalculator; - Project = project; - Configuration = configuration; - } - - public bool BuildPackage(IEnumerable contexts, List packDiagnostics) - { - Reporter.Output.WriteLine($"Producing nuget package \"{GetPackageName()}\" for {Project.Name}"); - - PackageBuilder = CreatePackageBuilder(Project); - - // TODO: Report errors for required fields - // id - // author - // description - foreach (var context in contexts) - { - Reporter.Verbose.WriteLine($"Processing {context.TargetFramework.ToString().Yellow()}"); - ProcessContext(context); - Reporter.Verbose.WriteLine(""); - } - - var packageOutputPath = Path.Combine( - ArtifactPathsCalculator.PackageOutputPath, - GetPackageName() + NuGetConstants.PackageExtension); - - if (GeneratePackage(packageOutputPath, packDiagnostics)) - { - return true; - } - - return false; - } - - protected virtual void ProcessContext(ProjectContext context) - { - PopulateDependencies(context); - - var inputFolder = ArtifactPathsCalculator.InputPathForContext(context); - - var compilerOptions = Project.GetCompilerOptions(context.TargetFramework, Configuration); - var outputName = compilerOptions.OutputName; - var outputExtension = - context.TargetFramework.IsDesktop() && compilerOptions.EmitEntryPoint.GetValueOrDefault() - ? ".exe" : ".dll"; - - IEnumerable resourceCultures = null; - if (compilerOptions.EmbedInclude == null) - { - resourceCultures = context.ProjectFile.Files.ResourceFiles - .Select(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key)) - .Distinct(); - } - else - { - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.EmbedInclude, "/", diagnostics: null); - resourceCultures = includeFiles - .Select(file => ResourceUtility.GetResourceCultureName(file.SourcePath)) - .Distinct(); - } - - foreach (var culture in resourceCultures) - { - if (string.IsNullOrEmpty(culture)) - { - continue; - } - - var resourceFilePath = Path.Combine(culture, $"{outputName}.resources.dll"); - TryAddOutputFile(context, inputFolder, resourceFilePath); - } - - TryAddOutputFile(context, inputFolder, outputName + outputExtension); - TryAddOutputFile(context, inputFolder, $"{outputName}.xml"); - TryAddOutputFile(context, inputFolder, $"{outputName}.runtimeconfig.json"); - } - - protected virtual bool GeneratePackage(string nupkg, List packDiagnostics) - { - foreach (var sharedFile in Project.Files.SharedFiles) - { - var file = new PhysicalPackageFile(); - file.SourcePath = sharedFile; - file.TargetPath = Path.Combine("shared", Path.GetFileName(sharedFile)); - PackageBuilder.Files.Add(file); - } - - if (Project.PackOptions.PackInclude != null) - { - var files = IncludeFilesResolver.GetIncludeFiles( - Project.PackOptions.PackInclude, - "/", - diagnostics: packDiagnostics); - PackageBuilder.Files.AddRange(GetPackageFiles(files, packDiagnostics)); - } - else if (Project.Files.PackInclude != null && Project.Files.PackInclude.Any()) - { - AddPackageFiles(Project.Files.PackInclude, packDiagnostics); - } - - // Write the packages as long as we're still in a success state. - if (!packDiagnostics.Any(d => d.Severity == DiagnosticMessageSeverity.Error)) - { - Reporter.Verbose.WriteLine($"Adding package files"); - foreach (var file in PackageBuilder.Files.OfType()) - { - if (file.SourcePath != null && File.Exists(file.SourcePath)) - { - Reporter.Verbose.WriteLine($"Adding {file.Path.Yellow()}"); - } - } - - Directory.CreateDirectory(Path.GetDirectoryName(nupkg)); - - using (var fs = File.Create(nupkg)) - { - PackageBuilder.Save(fs); - Reporter.Output.WriteLine($"{Project.Name} -> {Path.GetFullPath(nupkg)}"); - } - - return true; - } - - return false; - } - - private void AddPackageFiles(IEnumerable packageFiles, IList diagnostics) - { - var rootDirectory = new DirectoryInfoWrapper(new DirectoryInfo(Project.ProjectDirectory)); - - foreach (var match in CollectAdditionalFiles(rootDirectory, packageFiles, Project.ProjectFilePath, diagnostics)) - { - PackageBuilder.Files.Add(match); - } - } - - internal static IEnumerable CollectAdditionalFiles( - DirectoryInfoBase rootDirectory, - IEnumerable projectFileGlobs, - string projectFilePath, - IList diagnostics) - { - foreach (var entry in projectFileGlobs) - { - // Evaluate the globs on the right - var matcher = new Matcher(); - matcher.AddIncludePatterns(entry.SourceGlobs); - var results = matcher.Execute(rootDirectory); - var files = results.Files.ToList(); - - // Check for illegal characters - if (string.IsNullOrEmpty(entry.Target)) - { - diagnostics.Add(new DiagnosticMessage( - ErrorCodes.NU1003, - $"Invalid '{ProjectFilesCollection.PackIncludePropertyName}' section. The target '{entry.Target}' is invalid, " + - "targets must either be a file name or a directory suffixed with '/'. " + - "The root directory of the package can be specified by using a single '/' character.", - projectFilePath, - DiagnosticMessageSeverity.Error, - entry.Line, - entry.Column)); - continue; - } - - if (entry.Target.Split('/').Any(s => s.Equals(".") || s.Equals(".."))) - { - diagnostics.Add(new DiagnosticMessage( - ErrorCodes.NU1004, - $"Invalid '{ProjectFilesCollection.PackIncludePropertyName}' section. " + - $"The target '{entry.Target}' contains path-traversal characters ('.' or '..'). " + - "These characters are not permitted in target paths.", - projectFilePath, - DiagnosticMessageSeverity.Error, - entry.Line, - entry.Column)); - continue; - } - - // Check the arity of the left - if (entry.Target.EndsWith("/")) - { - var dir = entry.Target.Substring(0, entry.Target.Length - 1).Replace('/', Path.DirectorySeparatorChar); - - foreach (var file in files) - { - yield return new PhysicalPackageFile() - { - SourcePath = Path.Combine(rootDirectory.FullName, PathUtility.GetPathWithDirectorySeparator(file.Path)), - TargetPath = Path.Combine(dir, PathUtility.GetPathWithDirectorySeparator(file.Stem)) - }; - } - } - else - { - // It's a file. If the glob matched multiple things, we're sad :( - if (files.Count > 1) - { - // Arity mismatch! - string sourceValue = entry.SourceGlobs.Length == 1 ? - $"\"{entry.SourceGlobs[0]}\"" : - ("[" + string.Join(",", entry.SourceGlobs.Select(v => $"\"{v}\"")) + "]"); - diagnostics.Add(new DiagnosticMessage( - ErrorCodes.NU1005, - $"Invalid '{ProjectFilesCollection.PackIncludePropertyName}' section. " + - $"The target '{entry.Target}' refers to a single file, but the pattern {sourceValue} " + - "produces multiple files. To mark the target as a directory, suffix it with '/'.", - projectFilePath, - DiagnosticMessageSeverity.Error, - entry.Line, - entry.Column)); - } - else - { - yield return new PhysicalPackageFile() - { - SourcePath = Path.Combine(rootDirectory.FullName, files[0].Path), - TargetPath = PathUtility.GetPathWithDirectorySeparator(entry.Target) - }; - } - } - } - } - - private static IEnumerable GetPackageFiles( - IEnumerable includeFiles, - IList diagnostics) - { - foreach (var entry in includeFiles) - { - yield return new PhysicalPackageFile() - { - SourcePath = PathUtility.GetPathWithDirectorySeparator(entry.SourcePath), - TargetPath = PathUtility.GetPathWithDirectorySeparator(entry.TargetPath) - }; - } - } - - protected void TryAddOutputFile(ProjectContext context, - string outputPath, - string filePath) - { - var targetPath = Path.Combine("lib", context.TargetFramework.GetTwoDigitShortFolderName(), filePath); - var sourcePath = Path.Combine(outputPath, filePath); - - if (!File.Exists(sourcePath)) - { - return; - } - - PackageBuilder.Files.Add(new PhysicalPackageFile - { - SourcePath = sourcePath, - TargetPath = targetPath - }); - } - - private void PopulateDependencies(ProjectContext context) - { - var dependencies = new List(); - var project = context.RootProject; - - foreach (var dependency in project.Dependencies) - { - if (dependency.Type.Equals(LibraryDependencyType.Build)) - { - continue; - } - - // TODO: Efficiency - var dependencyDescription = - context.LibraryManager.GetLibraries().First(l => l.RequestedRanges.Contains(dependency)); - - // REVIEW: Can we get this far with unresolved dependencies - if (dependencyDescription == null || !dependencyDescription.Resolved) - { - continue; - } - - if (dependencyDescription.Identity.Type == LibraryType.Project && - ((ProjectDescription)dependencyDescription).Project.EmbedInteropTypes) - { - continue; - } - - if (dependency.LibraryRange.TypeConstraint == LibraryDependencyTarget.Reference) - { - PackageBuilder.FrameworkAssemblies.Add( - new FrameworkAssemblyReference(dependency.Name, new[] { context.TargetFramework })); - - Reporter.Verbose.WriteLine($"Adding framework assembly {dependency.Name.Yellow()}"); - } - else - { - VersionRange dependencyVersion = null; - - if (dependency.LibraryRange.VersionRange == null || - dependency.LibraryRange.VersionRange.IsFloating) - { - dependencyVersion = new VersionRange(dependencyDescription.Identity.Version); - } - else - { - dependencyVersion = dependency.LibraryRange.VersionRange; - } - - Reporter.Verbose.WriteLine($"Adding dependency {dependency.Name.Yellow()} {VersionUtility.RenderVersion(dependencyVersion).Yellow()}"); - - dependencies.Add(new PackageDependency(dependency.Name, dependencyVersion)); - } - } - - PackageBuilder.DependencySets.Add(new PackageDependencySet(context.TargetFramework, dependencies)); - } - - protected virtual string GetPackageName() - { - return $"{Project.Name}.{Project.Version}"; - } - - private static string GetDefaultRootOutputPath(Project project, string outputOptionValue) - { - string rootOutputPath = string.Empty; - - if (string.IsNullOrEmpty(outputOptionValue)) - { - rootOutputPath = project.ProjectDirectory; - } - - return rootOutputPath; - } - - private static PackageBuilder CreatePackageBuilder(Project project) - { - var builder = new PackageBuilder(); - builder.Authors.AddRange(project.Authors); - builder.Owners.AddRange(project.PackOptions.Owners); - - if (builder.Authors.Count == 0) - { - var defaultAuthor = Environment.GetEnvironmentVariable("NUGET_AUTHOR"); - if (string.IsNullOrEmpty(defaultAuthor)) - { - builder.Authors.Add(project.Name); - } - else - { - builder.Authors.Add(defaultAuthor); - } - } - - builder.Description = project.Description ?? project.Name; - builder.Id = project.Name; - builder.Version = project.Version; - builder.Title = project.Title; - builder.Summary = project.PackOptions.Summary; - builder.Copyright = project.Copyright; - builder.RequireLicenseAcceptance = project.PackOptions.RequireLicenseAcceptance; - builder.ReleaseNotes = project.PackOptions.ReleaseNotes; - builder.Language = project.Language; - builder.Tags.AddRange(project.PackOptions.Tags); - builder.Serviceable = project.Serviceable; - - if (!string.IsNullOrEmpty(project.PackOptions.IconUrl)) - { - builder.IconUrl = new Uri(project.PackOptions.IconUrl); - } - - if (!string.IsNullOrEmpty(project.PackOptions.ProjectUrl)) - { - builder.ProjectUrl = new Uri(project.PackOptions.ProjectUrl); - } - - if (!string.IsNullOrEmpty(project.PackOptions.LicenseUrl)) - { - builder.LicenseUrl = new Uri(project.PackOptions.LicenseUrl); - } - - return builder; - } - - } -} diff --git a/src/dotnet/commands/dotnet-pack/PackagesGenerator.cs b/src/dotnet/commands/dotnet-pack/PackagesGenerator.cs deleted file mode 100644 index 9a9c01fae..000000000 --- a/src/dotnet/commands/dotnet-pack/PackagesGenerator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Compiler; - -namespace Microsoft.DotNet.Tools.Pack -{ - public class PackagesGenerator - { - private readonly IEnumerable _contexts; - private readonly ArtifactPathsCalculator _artifactPathsCalculator; - private readonly string _configuration; - - public PackagesGenerator( - IEnumerable contexts, - ArtifactPathsCalculator artifactPathsCalculator, - string configuration) - { - _contexts = contexts; - _artifactPathsCalculator = artifactPathsCalculator; - _configuration = configuration; - } - - public int Build() - { - var project = _contexts.First().ProjectFile; - - var packDiagnostics = new List(); - - var mainPackageGenerator = new PackageGenerator(project, _configuration, _artifactPathsCalculator); - var symbolsPackageGenerator = - new SymbolPackageGenerator(project, _configuration, _artifactPathsCalculator); - - return mainPackageGenerator.BuildPackage(_contexts, packDiagnostics) && - symbolsPackageGenerator.BuildPackage(_contexts, packDiagnostics) ? 0 : 1; - } - } -} diff --git a/src/dotnet/commands/dotnet-pack/Program.cs b/src/dotnet/commands/dotnet-pack/Program.cs deleted file mode 100644 index 0d167ec2b..000000000 --- a/src/dotnet/commands/dotnet-pack/Program.cs +++ /dev/null @@ -1,95 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Common; -using Microsoft.DotNet.Tools.Pack; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public class PackCommand - { - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - var app = new CommandLineApplication(); - app.Name = "dotnet pack"; - app.FullName = ".NET Packager"; - app.Description = "Packager for the .NET Platform"; - app.HelpOption("-h|--help"); - - var output = app.Option("-o|--output ", "Directory in which to place outputs", CommandOptionType.SingleValue); - var noBuild = app.Option("--no-build", "Do not build project before packing", CommandOptionType.NoValue); - var buildBasePath = app.Option("-b|--build-base-path ", "Directory in which to place temporary build outputs", CommandOptionType.SingleValue); - var configuration = app.Option("-c|--configuration ", "Configuration under which to build", CommandOptionType.SingleValue); - var versionSuffix = app.Option("--version-suffix ", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue); - var serviceable = app.Option("-s|--serviceable", "Set the serviceable flag in the package", CommandOptionType.NoValue); - var path = app.Argument("", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory"); - - app.OnExecute(() => - { - // Locate the project and get the name and full path - var pathValue = path.Value; - if (string.IsNullOrEmpty(pathValue)) - { - pathValue = Directory.GetCurrentDirectory(); - } - - if (!pathValue.EndsWith(Project.FileName)) - { - pathValue = Path.Combine(pathValue, Project.FileName); - } - - if (!File.Exists(pathValue)) - { - Reporter.Error.WriteLine($"Unable to find a project.json in {pathValue}"); - return 1; - } - - // Set defaults based on the environment - var workspace = BuildWorkspace.Create(versionSuffix.Value()); - - var configValue = configuration.Value() ?? Cli.Utils.Constants.DefaultConfiguration; - var outputValue = output.Value(); - var buildBasePathValue = PathUtility.GetFullPath(buildBasePath.Value()); - - var contexts = workspace.GetProjectContextCollection(pathValue).FrameworkOnlyContexts; - var project = contexts.First().ProjectFile; - - var artifactPathsCalculator = new ArtifactPathsCalculator(project, buildBasePathValue, outputValue, configValue); - var packageBuilder = new PackagesGenerator(contexts, artifactPathsCalculator, configValue); - - project.Serviceable = serviceable.HasValue(); - - int buildResult = 0; - if (!noBuild.HasValue()) - { - var buildProjectCommand = new BuildProjectCommand(project, buildBasePathValue, configValue, workspace); - buildResult = buildProjectCommand.Execute(); - } - - return buildResult != 0 ? buildResult : packageBuilder.Build(); - }); - - try - { - return app.Execute(args); - } - catch (Exception ex) - { -#if DEBUG - Console.Error.WriteLine(ex); -#else - Console.Error.WriteLine(ex.Message); -#endif - return 1; - } - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/Properties/launchSettings.json b/src/dotnet/commands/dotnet-pack/Properties/launchSettings.json deleted file mode 100644 index 7a29b189e..000000000 --- a/src/dotnet/commands/dotnet-pack/Properties/launchSettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "profiles": { - "dotnet pack": { - "executablePath": "..\\..\\artifacts\\win7-x64\\stage2\\bin\\dotnet-pack.exe" - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/README.md b/src/dotnet/commands/dotnet-pack/README.md deleted file mode 100644 index 9f41b0699..000000000 --- a/src/dotnet/commands/dotnet-pack/README.md +++ /dev/null @@ -1,76 +0,0 @@ -% DOTNET-PACK(1) -% Microsoft Corporation dotnetclifeedback@microsoft.com -% June 2016 - -## NAME - -`dotnet-pack` - Packs the code into a NuGet package - -## SYNOPSIS - -`dotnet pack [--output] - [--no-build] [--build-base-path] - [--configuration] [--version-suffix] - []` - -## DESCRIPTION - -The `dotnet pack` command builds the project and creates NuGet packages. The result of this operation is two packages with the `nupkg` extension. One package contains the code and the other contains the debug symbols. - -NuGet dependencies of the project being packed are added to the nuspec file, so they are able to be resolved when the package is installed. -Project-to-project references are not packaged inside the project by default. If you wish to do this, you need to reference the required project in your dependencies node with a `type` set to "build" like in the following example: - -```json -{ - "version": "1.0.0-*", - "dependencies": { - "ProjectA": { - "target": "project", - "type": "build" - } - } -} -``` - -`dotnet pack` by default first builds the project. If you wish to avoid this, pass the `--no-build` option. This can be useful in Continuous Integration (CI) build scenarios in which you know the code was just previously built, for example. - -## OPTIONS - -`[project]` - -The project to pack. It can be either a path to a `project.json` file or to a directory. If omitted, it will -default to the current directory. - -`-o`, `--output` [DIR] - -Places the built packages in the directory specified. - -`--no-build` - -Skips the building phase of the packing process. - -`--build-base-path` - -Places the temporary build artifacts in the specified directory. By default, they go to the obj directory in the current directory. - -`-c`, `--configuration [Debug|Release]` - -Configuration to use when building the project. If not specified, will default to "Debug". - -## EXAMPLES - -`dotnet pack` - -Packs the current project. - -`dotnet pack ~/projects/app1/project.json` - -Packs the app1 project. - -`dotnet pack --output nupkgs` - -Packs the current application and place the resulting packages into the specified folder. - -`dotnet pack --no-build --output nupkgs` - -Packs the current project into the specified folder and skips the build step. \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-pack/SymbolPackageGenerator.cs b/src/dotnet/commands/dotnet-pack/SymbolPackageGenerator.cs deleted file mode 100644 index 306f21ef1..000000000 --- a/src/dotnet/commands/dotnet-pack/SymbolPackageGenerator.cs +++ /dev/null @@ -1,72 +0,0 @@ -// 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.Collections.Generic; -using System.IO; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.Tools.Pack; -using NuGet.Legacy; - -namespace Microsoft.DotNet.Tools.Compiler -{ - public class SymbolPackageGenerator: PackageGenerator - { - public SymbolPackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator) - : base(project, configuration, artifactPathsCalculator) - { - } - - protected override string GetPackageName() - { - return $"{Project.Name}.{Project.Version}.symbols"; - } - - protected override void ProcessContext(ProjectContext context) - { - base.ProcessContext(context); - - var inputFolder = ArtifactPathsCalculator.InputPathForContext(context); - var ouptutName = Project.GetCompilerOptions(context.TargetFramework, Configuration).OutputName; - - TryAddOutputFile(context, inputFolder, $"{ouptutName}.pdb"); - TryAddOutputFile(context, inputFolder, $"{ouptutName}.mdb"); - } - - protected override bool GeneratePackage(string nupkg, List packDiagnostics) - { - var compilerOptions = Project.GetCompilerOptions( - Project.GetTargetFramework(targetFramework: null).FrameworkName, Configuration); - - if (compilerOptions.CompileInclude == null) - { - foreach (var path in Project.Files.SourceFiles) - { - var srcFile = new PhysicalPackageFile - { - SourcePath = path, - TargetPath = Path.Combine("src", Common.PathUtility.GetRelativePath(Project.ProjectDirectory, path)) - }; - - PackageBuilder.Files.Add(srcFile); - } - } - else - { - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); - foreach (var entry in includeFiles) - { - var srcFile = new PhysicalPackageFile - { - SourcePath = entry.SourcePath, - TargetPath = Path.Combine("src", entry.TargetPath) - }; - - PackageBuilder.Files.Add(srcFile); - } - } - - return base.GeneratePackage(nupkg, packDiagnostics); - } - } -} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-projectmodel-server/ConnectionContext.cs b/src/dotnet/commands/dotnet-projectmodel-server/ConnectionContext.cs deleted file mode 100644 index 235db0530..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/ConnectionContext.cs +++ /dev/null @@ -1,62 +0,0 @@ -// 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.Collections.Generic; -using System.Net.Sockets; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - internal class ConnectionContext - { - private readonly string _hostName; - private readonly ProcessingQueue _queue; - private readonly IDictionary _projects; - - public ConnectionContext(Socket acceptedSocket, - string hostName, - ProtocolManager protocolManager, - DesignTimeWorkspace workspaceContext, - IDictionary projects) - { - _hostName = hostName; - _projects = projects; - - _queue = new ProcessingQueue(new NetworkStream(acceptedSocket)); - _queue.OnReceive += message => - { - if (protocolManager.IsProtocolNegotiation(message)) - { - message.Sender = this; - protocolManager.Negotiate(message); - } - else - { - message.Sender = this; - ProjectManager projectManager; - if (!_projects.TryGetValue(message.ContextId, out projectManager)) - { - projectManager = new ProjectManager(message.ContextId, - workspaceContext, - protocolManager); - - _projects[message.ContextId] = projectManager; - } - - projectManager.OnReceive(message); - } - }; - } - - public void QueueStart() - { - _queue.Start(); - } - - public bool Transmit(Message message) - { - message.HostId = _hostName; - return _queue.Send(message); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/DependencyTypeChangeFinder.cs b/src/dotnet/commands/dotnet-projectmodel-server/Helpers/DependencyTypeChangeFinder.cs deleted file mode 100644 index da48518fc..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/DependencyTypeChangeFinder.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.ProjectModel.Server.Helpers -{ - internal class DependencyTypeChangeFinder - { - public static IEnumerable Diagnose( - ProjectContext context, - IEnumerable previousSearchPaths) - { - var result = new List(); - var project = context.ProjectFile; - var libraries = context.LibraryManager.GetLibraries(); - - var updatedSearchPath = GetUpdatedSearchPaths(previousSearchPaths, project.ResolveSearchPaths()); - var projectCandiates = GetProjectCandidates(updatedSearchPath); - var rootDependencies = libraries.FirstOrDefault(library => string.Equals(library.Identity.Name, project.Name)) - ?.Dependencies - ?.ToDictionary(libraryRange => libraryRange.Name); - - foreach (var library in libraries) - { - var diagnostic = Validate(library, projectCandiates, rootDependencies); - if (diagnostic != null) - { - result.Add(diagnostic); - } - } - - return result; - } - - private static DiagnosticMessage Validate(LibraryDescription library, - HashSet projectCandidates, - Dictionary rootDependencies) - { - if (!library.Resolved || projectCandidates == null) - { - return null; - } - - var foundCandidate = projectCandidates.Contains(library.Identity.Name); - - if ((library.Identity.Type == LibraryType.Project && !foundCandidate) || - (library.Identity.Type == LibraryType.Package && foundCandidate)) - { - library.Resolved = false; - - var libraryRange = rootDependencies[library.Identity.Name]; - - return new DiagnosticMessage( - ErrorCodes.NU1010, - $"The type of dependency {library.Identity.Name} was changed.", - libraryRange.SourceFilePath, - DiagnosticMessageSeverity.Error, - libraryRange.SourceLine, - libraryRange.SourceColumn, - library); - } - - return null; - } - - private static HashSet GetProjectCandidates(IEnumerable searchPaths) - { - if (searchPaths == null) - { - return null; - } - - return new HashSet(searchPaths.Where(path => Directory.Exists(path)) - .SelectMany(path => Directory.GetDirectories(path)) - .Where(path => File.Exists(Path.Combine(path, Project.FileName))) - .Select(path => Path.GetFileName(path))); - } - - /// - /// Returns the search paths if they're updated. Otherwise returns null. - /// - private static IEnumerable GetUpdatedSearchPaths(IEnumerable oldSearchPaths, - IEnumerable newSearchPaths) - { - // The oldSearchPaths is null when the current project is not initialized. It is not necessary to - // validate the dependency in this case. - if (oldSearchPaths == null) - { - return null; - } - - if (Enumerable.SequenceEqual(oldSearchPaths, newSearchPaths)) - { - return null; - } - - return newSearchPaths; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/JTokenExtensions.cs b/src/dotnet/commands/dotnet-projectmodel-server/Helpers/JTokenExtensions.cs deleted file mode 100644 index 9edd1d8bf..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/JTokenExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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 Newtonsoft.Json.Linq; - -namespace Microsoft.DotNet.ProjectModel.Server.Helpers -{ - public static class JTokenExtensions - { - public static string GetValue(this JToken token, string name) - { - return GetValue(token, name); - } - - public static TVal GetValue(this JToken token, string name) - { - var value = token?[name]; - if (value != null) - { - return value.Value(); - } - - return default(TVal); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/NuGetFrameworkExtensions.cs b/src/dotnet/commands/dotnet-projectmodel-server/Helpers/NuGetFrameworkExtensions.cs deleted file mode 100644 index 5bc8c1d53..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/NuGetFrameworkExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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.ProjectModel.Resolution; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - public static class NuGetFrameworkExtensions - { - public static FrameworkData ToPayload(this NuGetFramework framework) - { - return new FrameworkData - { - ShortName = framework.GetShortFolderName(), - FrameworkName = framework.DotNetFrameworkName, - FriendlyName = FrameworkReferenceResolver.Default.GetFriendlyFrameworkName(framework), - RedistListPath = FrameworkReferenceResolver.Default.GetFrameworkRedistListPath(framework) - }; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/ProjectExtensions.cs b/src/dotnet/commands/dotnet-projectmodel-server/Helpers/ProjectExtensions.cs deleted file mode 100644 index ef28bbc23..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Helpers/ProjectExtensions.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.IO; - -namespace Microsoft.DotNet.ProjectModel.Server.Helpers -{ - public static class ProjectExtensions - { - public static IEnumerable ResolveSearchPaths(this Project project) - { - GlobalSettings settings; - return project.ResolveSearchPaths(out settings); - } - - public static IEnumerable ResolveSearchPaths(this Project project, out GlobalSettings globalSettings) - { - if (project == null) - { - throw new ArgumentNullException(nameof(project)); - } - - var searchPaths = new HashSet { Directory.GetParent(project.ProjectDirectory).FullName }; - - globalSettings = project.ResolveGlobalSettings(); - if (globalSettings != null) - { - foreach (var searchPath in globalSettings.ProjectSearchPaths) - { - var path = Path.Combine(globalSettings.DirectoryPath, searchPath); - searchPaths.Add(Path.GetFullPath(path)); - } - } - - return searchPaths; - } - - public static GlobalSettings ResolveGlobalSettings(this Project project) - { - if (project == null) - { - throw new ArgumentNullException(nameof(project)); - } - - GlobalSettings settings; - var root = ProjectRootResolver.ResolveRootDirectory(project.ProjectDirectory); - if (GlobalSettings.TryGetGlobalSettings(root, out settings)) - { - return settings; - } - else - { - return null; - } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectContextSnapshot.cs b/src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectContextSnapshot.cs deleted file mode 100644 index 997e56cd2..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectContextSnapshot.cs +++ /dev/null @@ -1,93 +0,0 @@ -// 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; -using Microsoft.DotNet.Cli.Compiler.Common; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.Server.Helpers; -using Microsoft.DotNet.ProjectModel.Server.Models; -using NuGet.Frameworks; -using NuGet.LibraryModel; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - internal class ProjectContextSnapshot - { - public string RootDependency { get; set; } - public NuGetFramework TargetFramework { get; set; } - public IReadOnlyList SourceFiles { get; set; } - public CommonCompilerOptions CompilerOptions { get; set; } - public IReadOnlyList ProjectReferences { get; set; } - public IReadOnlyList FileReferences { get; set; } - public IReadOnlyList DependencyDiagnostics { get; set; } - public IDictionary Dependencies { get; set; } - - public static ProjectContextSnapshot Create(ProjectContext context, string configuration, IEnumerable previousSearchPaths) - { - var snapshot = new ProjectContextSnapshot(); - - var allDependencyDiagnostics = new List(); - allDependencyDiagnostics.AddRange(context.LibraryManager.GetAllDiagnostics()); - allDependencyDiagnostics.AddRange(DependencyTypeChangeFinder.Diagnose(context, previousSearchPaths)); - - var diagnosticsLookup = allDependencyDiagnostics.ToLookup(d => d.Source); - - var allExports = context.CreateExporter(configuration) - .GetAllExports() - .ToDictionary(export => export.Library.Identity.Name); - - var allSourceFiles = new List(GetSourceFiles(context, configuration)); - var allFileReferences = new List(); - var allProjectReferences = new List(); - var allDependencies = new Dictionary(); - - // All exports are returned. When the same library name have a ReferenceAssembly type export and a Package type export - // both will be listed as dependencies. Prefix "fx/" will be added to ReferenceAssembly type dependency. - foreach (var export in allExports.Values) - { - allSourceFiles.AddRange(export.SourceReferences.Select(f => f.ResolvedPath)); - var diagnostics = diagnosticsLookup[export.Library].ToList(); - var description = DependencyDescription.Create(export.Library, diagnostics, allExports); - allDependencies[description.Name] = description; - - var projectReferene = ProjectReferenceDescription.Create(export.Library); - if (projectReferene != null && export.Library.Identity.Name != context.ProjectFile.Name) - { - allProjectReferences.Add(projectReferene); - } - - if (export.Library.Identity.Type != LibraryType.Project) - { - allFileReferences.AddRange(export.CompilationAssemblies.Select(asset => asset.ResolvedPath)); - } - } - - snapshot.RootDependency = context.ProjectFile.Name; - snapshot.TargetFramework = context.TargetFramework; - snapshot.SourceFiles = allSourceFiles.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList(); - snapshot.CompilerOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration); - snapshot.ProjectReferences = allProjectReferences.OrderBy(reference => reference.Name).ToList(); - snapshot.FileReferences = allFileReferences.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList(); - snapshot.DependencyDiagnostics = allDependencyDiagnostics; - snapshot.Dependencies = allDependencies; - - return snapshot; - } - - private static IEnumerable GetSourceFiles(ProjectContext context, string configuration) - { - var compilerOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration); - - if (compilerOptions.CompileInclude == null) - { - return context.ProjectFile.Files.SourceFiles; - } - - var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); - - return includeFiles.Select(f => f.SourcePath); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectSnapshot.cs b/src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectSnapshot.cs deleted file mode 100644 index 0b28210bf..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/InternalModels/ProjectSnapshot.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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; -using Microsoft.DotNet.ProjectModel.Server.Helpers; -using Microsoft.DotNet.ProjectModel.Server.Models; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - internal class ProjectSnapshot - { - public Project Project { get; set; } - public string GlobalJsonPath { get; set; } - public IReadOnlyList ProjectSearchPaths { get; set; } - public IReadOnlyList ProjectDiagnostics { get; set; } - public ErrorMessage GlobalErrorMessage { get; set; } - public Dictionary ProjectContexts { get; } = new Dictionary(); - - public static ProjectSnapshot Create(string projectDirectory, - string configuration, - DesignTimeWorkspace workspaceContext, - IReadOnlyList previousSearchPaths, - bool clearWorkspaceContextCache) - { - var projectContextsCollection = workspaceContext.GetProjectContextCollection(projectDirectory, clearWorkspaceContextCache); - if (!projectContextsCollection.ProjectContexts.Any()) - { - throw new InvalidOperationException($"Unable to find project.json in '{projectDirectory}'"); - } - GlobalSettings globalSettings; - var currentSearchPaths = projectContextsCollection.Project.ResolveSearchPaths(out globalSettings); - - var snapshot = new ProjectSnapshot(); - snapshot.Project = projectContextsCollection.Project; - snapshot.ProjectDiagnostics = new List(projectContextsCollection.ProjectDiagnostics); - snapshot.ProjectSearchPaths = currentSearchPaths.ToList(); - snapshot.GlobalJsonPath = globalSettings?.FilePath; - - foreach (var projectContext in projectContextsCollection.FrameworkOnlyContexts) - { - snapshot.ProjectContexts[projectContext.TargetFramework] = - ProjectContextSnapshot.Create(projectContext, configuration, previousSearchPaths); - } - - return snapshot; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/MessageTypes.cs b/src/dotnet/commands/dotnet-projectmodel-server/MessageTypes.cs deleted file mode 100644 index df9419502..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/MessageTypes.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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.ProjectModel.Server -{ - public class MessageTypes - { - // Incoming - public const string Initialize = nameof(Initialize); - public const string ChangeConfiguration = nameof(ChangeConfiguration); - public const string RefreshDependencies = nameof(RefreshDependencies); - public const string RestoreComplete = nameof(RestoreComplete); - public const string FilesChanged = nameof(FilesChanged); - public const string GetDiagnostics = nameof(GetDiagnostics); - public const string ProtocolVersion = nameof(ProtocolVersion); - - // Outgoing - public const string Error = nameof(Error); - public const string ProjectInformation = nameof(ProjectInformation); - public const string Diagnostics = nameof(Diagnostics); - public const string DependencyDiagnostics = nameof(DependencyDiagnostics); - public const string Dependencies = nameof(Dependencies); - public const string CompilerOptions = nameof(CompilerOptions); - public const string References = nameof(References); - public const string Sources = nameof(Sources); - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/CompilerOptionsMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/CompilerOptionsMessenger.cs deleted file mode 100644 index 57c46426b..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/CompilerOptionsMessenger.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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 Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class CompilerOptionsMessenger : Messenger - { - public CompilerOptionsMessenger(Action transmit) - : base(MessageTypes.CompilerOptions, transmit) - { } - - protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - return remote.CompilerOptions != null && - Equals(local.CompilerOptions, remote.CompilerOptions); - } - - protected override void SendPayload(ProjectContextSnapshot local, Action send) - { - send(new CompilationOptionsMessage - { - Framework = local.TargetFramework.ToPayload(), - Options = local.CompilerOptions - }); - } - - protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - remote.CompilerOptions = local.CompilerOptions; - } - - private class CompilationOptionsMessage - { - public FrameworkData Framework { get; set; } - - public CommonCompilerOptions Options { get; set; } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependenciesMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependenciesMessenger.cs deleted file mode 100644 index e89fcabc4..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependenciesMessenger.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class DependenciesMessenger : Messenger - { - public DependenciesMessenger(Action transmit) - : base(MessageTypes.Dependencies, transmit) - { } - - protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - return remote.Dependencies != null && - string.Equals(local.RootDependency, remote.RootDependency) && - Equals(local.TargetFramework, remote.TargetFramework) && - Enumerable.SequenceEqual(local.Dependencies, remote.Dependencies); - } - - protected override void SendPayload(ProjectContextSnapshot local, Action send) - { - send(new DependenciesMessage - { - Framework = local.TargetFramework.ToPayload(), - RootDependency = local.RootDependency, - Dependencies = local.Dependencies - }); - } - - protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - remote.Dependencies = local.Dependencies; - } - - private class DependenciesMessage - { - public FrameworkData Framework { get; set; } - public string RootDependency { get; set; } - public IDictionary Dependencies { get; set; } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependencyDiagnosticsMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependencyDiagnosticsMessenger.cs deleted file mode 100644 index fa95b756b..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/DependencyDiagnosticsMessenger.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.Linq; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class DependencyDiagnosticsMessenger : Messenger - { - public DependencyDiagnosticsMessenger(Action transmit) - : base(MessageTypes.DependencyDiagnostics, transmit) - { } - - protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - return remote.DependencyDiagnostics != null && - Enumerable.SequenceEqual(local.DependencyDiagnostics, remote.DependencyDiagnostics); - } - - protected override void SendPayload(ProjectContextSnapshot local, Action send) - { - send(new DiagnosticsListMessage( - local.DependencyDiagnostics, - local.TargetFramework?.ToPayload())); - } - - protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - remote.DependencyDiagnostics = local.DependencyDiagnostics; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/GlobalErrorMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/GlobalErrorMessenger.cs deleted file mode 100644 index 854465ef8..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/GlobalErrorMessenger.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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 Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class GlobalErrorMessenger : Messenger - { - public GlobalErrorMessenger(Action transmit) - : base(MessageTypes.Error, transmit) - { } - - protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote) - { - return remote != null && Equals(local.GlobalErrorMessage, remote.GlobalErrorMessage); - } - - protected override void SendPayload(ProjectSnapshot local, Action send) - { - if (local.GlobalErrorMessage != null) - { - send(local.GlobalErrorMessage); - } - else - { - send(new ErrorMessage - { - Message = null, - Path = null, - Line = -1, - Column = -1 - }); - } - } - - protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote) - { - remote.GlobalErrorMessage = local.GlobalErrorMessage; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/Messenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/Messenger.cs deleted file mode 100644 index 5805e9425..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/Messenger.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal abstract class Messenger where T : class - { - protected readonly Action _transmit; - - public Messenger(string messageType, Action transmit) - { - _transmit = transmit; - - MessageType = messageType; - } - - public string MessageType { get; } - - public void UpdateRemote(T local, T remote) - { - if (!CheckDifference(local, remote)) - { - SendPayload(local, payload => _transmit(MessageType, payload)); - SetValue(local, remote); - } - } - - protected abstract void SetValue(T local, T remote); - protected abstract void SendPayload(T local, Action send); - protected abstract bool CheckDifference(T local, T remote); - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectDiagnosticsMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectDiagnosticsMessenger.cs deleted file mode 100644 index 4ef95660d..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectDiagnosticsMessenger.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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.Linq; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class ProjectDiagnosticsMessenger : Messenger - { - public ProjectDiagnosticsMessenger(Action transmit) - : base(MessageTypes.Diagnostics, transmit) - { } - - protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote) - { - return remote.ProjectDiagnostics != null && - Enumerable.SequenceEqual(local.ProjectDiagnostics, remote.ProjectDiagnostics); - } - - protected override void SendPayload(ProjectSnapshot local, Action send) - { - send(new DiagnosticsListMessage(local.ProjectDiagnostics)); - } - - protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote) - { - remote.ProjectDiagnostics = local.ProjectDiagnostics; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectInformationMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectInformationMessenger.cs deleted file mode 100644 index 096f42747..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ProjectInformationMessenger.cs +++ /dev/null @@ -1,68 +0,0 @@ -// 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; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class ProjectInformationMessenger : Messenger - { - public ProjectInformationMessenger(Action transmit) - : base(MessageTypes.ProjectInformation, transmit) - { } - - protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote) - { - return remote.Project != null && - string.Equals(local.Project.Name, remote.Project.Name) && - string.Equals(local.GlobalJsonPath, remote.GlobalJsonPath) && - Enumerable.SequenceEqual(local.Project.GetTargetFrameworks().Select(f => f.FrameworkName), - remote.Project.GetTargetFrameworks().Select(f => f.FrameworkName)) && - Enumerable.SequenceEqual(local.Project.GetConfigurations(), remote.Project.GetConfigurations()) && - Enumerable.SequenceEqual(local.Project.Commands, remote.Project.Commands) && - Enumerable.SequenceEqual(local.ProjectSearchPaths, remote.ProjectSearchPaths); - } - - protected override void SendPayload(ProjectSnapshot local, Action send) - { - send(new ProjectInformationMessage(local.Project, local.GlobalJsonPath, local.ProjectSearchPaths)); - } - - protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote) - { - remote.Project = local.Project; - remote.GlobalJsonPath = local.GlobalJsonPath; - remote.ProjectSearchPaths = local.ProjectSearchPaths; - } - - private class ProjectInformationMessage - { - public ProjectInformationMessage(Project project, - string gloablJsonPath, - IReadOnlyList projectSearchPaths) - { - Name = project.Name; - Frameworks = project.GetTargetFrameworks().Select(f => f.FrameworkName.ToPayload()).ToList(); - Configurations = project.GetConfigurations().ToList(); - Commands = project.Commands; - ProjectSearchPaths = projectSearchPaths; - GlobalJsonPath = gloablJsonPath; - } - - public string Name { get; } - - public IReadOnlyList Frameworks { get; } - - public IReadOnlyList Configurations { get; } - - public IDictionary Commands { get; } - - public IReadOnlyList ProjectSearchPaths { get; } - - public string GlobalJsonPath { get; } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ReferencesMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ReferencesMessenger.cs deleted file mode 100644 index 04a06af0b..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/ReferencesMessenger.cs +++ /dev/null @@ -1,48 +0,0 @@ -// 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; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class ReferencesMessenger : Messenger - { - public ReferencesMessenger(Action transmit) - : base(MessageTypes.References, transmit) - { } - - protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - return remote.FileReferences != null && - remote.ProjectReferences != null && - Enumerable.SequenceEqual(local.FileReferences, remote.FileReferences) && - Enumerable.SequenceEqual(local.ProjectReferences, remote.ProjectReferences); - } - - protected override void SendPayload(ProjectContextSnapshot local, Action send) - { - send(new ReferencesMessage - { - Framework = local.TargetFramework.ToPayload(), - ProjectReferences = local.ProjectReferences, - FileReferences = local.FileReferences - }); - } - - protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - remote.FileReferences = local.FileReferences; - remote.ProjectReferences = local.ProjectReferences; - } - - private class ReferencesMessage - { - public FrameworkData Framework { get; set; } - public IReadOnlyList FileReferences { get; set; } - public IReadOnlyList ProjectReferences { get; set; } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/SourcesMessenger.cs b/src/dotnet/commands/dotnet-projectmodel-server/Messengers/SourcesMessenger.cs deleted file mode 100644 index 66f7767df..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Messengers/SourcesMessenger.cs +++ /dev/null @@ -1,45 +0,0 @@ -// 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; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server.Messengers -{ - internal class SourcesMessenger : Messenger - { - public SourcesMessenger(Action transmit) - : base(MessageTypes.Sources, transmit) - { } - - protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - return remote.SourceFiles != null && - Enumerable.SequenceEqual(local.SourceFiles, remote.SourceFiles); - } - - protected override void SendPayload(ProjectContextSnapshot local, Action send) - { - send(new SourcesMessage - { - Framework = local.TargetFramework.ToPayload(), - Files = local.SourceFiles, - GeneratedFiles = new Dictionary() - }); - } - - protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote) - { - remote.SourceFiles = local.SourceFiles; - } - - private class SourcesMessage - { - public FrameworkData Framework { get; set; } - public IReadOnlyList Files { get; set; } - public IDictionary GeneratedFiles { get; set; } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs deleted file mode 100644 index 7c1e3ee1e..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs +++ /dev/null @@ -1,94 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.ProjectModel.Compilation; -using NuGet.LibraryModel; -using NuGet.Versioning; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - public class DependencyDescription - { - private DependencyDescription() { } - - public string Name { get; private set; } - - public string DisplayName { get; private set; } - - public string Version { get; private set; } - - public string Path { get; private set; } - - public string Type { get; private set; } - - public bool Resolved { get; private set; } - - public IEnumerable Dependencies { get; private set; } - - public IEnumerable Errors { get; private set; } - - public IEnumerable Warnings { get; private set; } - - public override bool Equals(object obj) - { - var other = obj as DependencyDescription; - - return other != null && - Resolved == other.Resolved && - string.Equals(Name, other.Name) && - object.Equals(Version, other.Version) && - string.Equals(Path, other.Path) && - string.Equals(Type, other.Type) && - Enumerable.SequenceEqual(Dependencies, other.Dependencies) && - Enumerable.SequenceEqual(Errors, other.Errors) && - Enumerable.SequenceEqual(Warnings, other.Warnings); - } - - public override int GetHashCode() - { - // These objects are currently POCOs and we're overriding equals - // so that things like Enumerable.SequenceEqual just work. - return base.GetHashCode(); - } - - public static DependencyDescription Create(LibraryDescription library, - List diagnostics, - IDictionary exportsLookup) - { - var result = new DependencyDescription - { - Name = library.Identity.Name, - DisplayName = library.Identity.Name, - Version = (library.Identity.Version ?? new NuGetVersion("1.0.0")).ToNormalizedString(), - Type = library.Identity.Type.Value, - Resolved = library.Resolved, - Path = library.Path, - Dependencies = library.Dependencies.Select(dependency => GetDependencyItem(dependency, exportsLookup)), - Errors = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Error) - .Select(d => new DiagnosticMessageView(d)), - Warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning) - .Select(d => new DiagnosticMessageView(d)) - }; - - var msbuildLibrary = library as MSBuildProjectDescription; - if (msbuildLibrary != null) - { - result.Path = msbuildLibrary.MSBuildProjectPath; - } - - return result; - } - - private static DependencyItem GetDependencyItem(LibraryDependency dependency, - IDictionary exportsLookup) - { - return new DependencyItem - { - Name = dependency.Name, - Version = exportsLookup[dependency.Name].Library.Identity.Version?.ToNormalizedString() - }; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyItem.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyItem.cs deleted file mode 100644 index 1f014daff..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyItem.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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.ProjectModel.Server.Models -{ - public class DependencyItem - { - public string Name { get; set; } - - public string Version { get; set; } - - public override bool Equals(object obj) - { - var other = obj as DependencyItem; - return other != null && - string.Equals(Name, other.Name) && - object.Equals(Version, other.Version); - } - - public override int GetHashCode() - { - // These objects are currently POCOs and we're overriding equals - // so that things like Enumerable.SequenceEqual just work. - return base.GetHashCode(); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageGroup.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageGroup.cs deleted file mode 100644 index c76adf86c..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageGroup.cs +++ /dev/null @@ -1,25 +0,0 @@ -// 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.Collections.Generic; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - public class DiagnosticMessageGroup - { - public DiagnosticMessageGroup(IEnumerable diagnostics) - : this(framework: null, diagnostics: diagnostics) - { } - - public DiagnosticMessageGroup(NuGetFramework framework, IEnumerable diagnostics) - { - Framework = framework; - Diagnostics = diagnostics; - } - - public IEnumerable Diagnostics { get; } - - public NuGetFramework Framework { get; } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageView.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageView.cs deleted file mode 100644 index 8285d48ba..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticMessageView.cs +++ /dev/null @@ -1,74 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - public class DiagnosticMessageView - { - public DiagnosticMessageView(DiagnosticMessage data) - { - ErrorCode = data.ErrorCode; - SourceFilePath = data.SourceFilePath; - Message = data.Message; - Severity = data.Severity; - StartLine = data.StartLine; - StartColumn = data.StartColumn; - EndLine = data.EndLine; - EndColumn = data.EndColumn; - FormattedMessage = data.FormattedMessage; - - var description = data.Source as LibraryDescription; - if (description != null) - { - Source = new - { - Name = description.Identity.Name, - Version = description.Identity.Version?.ToString() - }; - } - } - - public string ErrorCode { get; } - - public string SourceFilePath { get; } - - public string Message { get; } - - public DiagnosticMessageSeverity Severity { get; } - - public int StartLine { get; } - - public int StartColumn { get; } - - public int EndLine { get; } - - public int EndColumn { get; } - - public string FormattedMessage { get; } - - public object Source { get; } - - public override bool Equals(object obj) - { - var other = obj as DiagnosticMessageView; - - return other != null && - Severity == other.Severity && - StartLine == other.StartLine && - StartColumn == other.StartColumn && - EndLine == other.EndLine && - EndColumn == other.EndColumn && - string.Equals(ErrorCode, other.ErrorCode, StringComparison.Ordinal) && - string.Equals(SourceFilePath, other.SourceFilePath, StringComparison.Ordinal) && - string.Equals(Message, other.Message, StringComparison.Ordinal) && - object.Equals(Source, other.Source); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticsListMessage.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticsListMessage.cs deleted file mode 100644 index dc66cd12d..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/DiagnosticsListMessage.cs +++ /dev/null @@ -1,69 +0,0 @@ -// 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; -using Newtonsoft.Json; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - public class DiagnosticsListMessage - { - public DiagnosticsListMessage(IEnumerable diagnostics) : - this(diagnostics, frameworkData: null) - { - } - - public DiagnosticsListMessage(IEnumerable diagnostics, FrameworkData frameworkData) : - this(diagnostics.Select(msg => new DiagnosticMessageView(msg)).ToList(), frameworkData) - { - if (diagnostics == null) - { - throw new ArgumentNullException(nameof(diagnostics)); - } - } - - public DiagnosticsListMessage(IEnumerable diagnostics) : - this(diagnostics, frameworkData: null) - { - } - - public DiagnosticsListMessage(IEnumerable diagnostics, FrameworkData frameworkData) - { - if (diagnostics == null) - { - throw new ArgumentNullException(nameof(diagnostics)); - } - - Diagnostics = diagnostics; - Errors = diagnostics.Where(msg => msg.Severity == DiagnosticMessageSeverity.Error).ToList(); - Warnings = diagnostics.Where(msg => msg.Severity == DiagnosticMessageSeverity.Warning).ToList(); - Framework = frameworkData; - } - - public FrameworkData Framework { get; } - - [JsonIgnore] - public IEnumerable Diagnostics { get; } - - public IList Errors { get; } - - public IList Warnings { get; } - - public override bool Equals(object obj) - { - var other = obj as DiagnosticsListMessage; - - return other != null && - Enumerable.SequenceEqual(Errors, other.Errors) && - Enumerable.SequenceEqual(Warnings, other.Warnings) && - object.Equals(Framework, other.Framework); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/ErrorMessage.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/ErrorMessage.cs deleted file mode 100644 index 8623afae3..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/ErrorMessage.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - public class ErrorMessage - { - public string Message { get; set; } - public string Path { get; set; } - public int Line { get; set; } - public int Column { get; set; } - - public override bool Equals(object obj) - { - var payload = obj as ErrorMessage; - return payload != null && - string.Equals(Message, payload.Message, StringComparison.Ordinal) && - string.Equals(Path, payload.Path, StringComparison.OrdinalIgnoreCase) && - Line == payload.Line && - Column == payload.Column; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/FrameworkData.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/FrameworkData.cs deleted file mode 100644 index 258c1cb08..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/FrameworkData.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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.ProjectModel.Server.Models -{ - public class FrameworkData - { - public string FrameworkName { get; set; } - public string FriendlyName { get; set; } - public string ShortName { get; set; } - public string RedistListPath { get; set; } - - public override bool Equals(object obj) - { - var other = obj as FrameworkData; - - return other != null && - string.Equals(FrameworkName, other.FrameworkName); - } - - public override int GetHashCode() - { - // These objects are currently POCOs and we're overriding equals - // so that things like Enumerable.SequenceEqual just work. - return base.GetHashCode(); - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/Message.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/Message.cs deleted file mode 100644 index 0c0bfe8f3..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/Message.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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 Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.DotNet.ProjectModel.Server.Models -{ - internal class Message - { - public static Message FromPayload(string messageType, int contextId, object payload) - { - return new Message - { - MessageType = messageType, - ContextId = contextId, - Payload = payload is JToken ? (JToken)payload : JToken.FromObject(payload) - }; - } - - private Message() { } - - public string MessageType { get; set; } - - public string HostId { get; set; } - - public int ContextId { get; set; } = -1; - - public JToken Payload { get; set; } - - [JsonIgnore] - public ConnectionContext Sender { get; set; } - - public override string ToString() - { - return $"({HostId}, {MessageType}, {ContextId}) -> {Payload?.ToString(Formatting.Indented)}"; - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs deleted file mode 100644 index 224837488..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs +++ /dev/null @@ -1,57 +0,0 @@ -// 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.ProjectModel.Server.Models -{ - internal class ProjectReferenceDescription - { - private ProjectReferenceDescription() { } - - public FrameworkData Framework { get; set; } - public string Name { get; set; } - public string Path { get; set; } - - public override bool Equals(object obj) - { - var other = obj as ProjectReferenceDescription; - return other != null && - string.Equals(Name, other.Name) && - string.Equals(Path, other.Path); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - /// - /// Create a ProjectReferenceDescription from given LibraryDescription. If the library doesn't - /// represent a project reference returns null. - /// - public static ProjectReferenceDescription Create(LibraryDescription library) - { - if (library is ProjectDescription) - { - return new ProjectReferenceDescription - { - Framework = library.Framework.ToPayload(), - Name = library.Identity.Name, - Path = library.Path - }; - } - else if (library is MSBuildProjectDescription) - { - return new ProjectReferenceDescription - { - Framework = library.Framework.ToPayload(), - Name = library.Identity.Name, - Path = ((MSBuildProjectDescription)library).MSBuildProjectPath, - }; - } - else - { - return null; - } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/ProcessingQueue.cs b/src/dotnet/commands/dotnet-projectmodel-server/ProcessingQueue.cs deleted file mode 100644 index d3ceb13e9..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/ProcessingQueue.cs +++ /dev/null @@ -1,88 +0,0 @@ -// 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.IO; -using System.Threading; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel.Server.Models; -using Newtonsoft.Json; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - internal class ProcessingQueue - { - private readonly BinaryReader _reader; - private readonly BinaryWriter _writer; - - public ProcessingQueue(Stream stream) - { - _reader = new BinaryReader(stream); - _writer = new BinaryWriter(stream); - } - - public event Action OnReceive; - - public void Start() - { - Reporter.Output.WriteLine("Start"); - new Thread(ReceiveMessages).Start(); - } - - public bool Send(Action writeAction) - { - lock (_writer) - { - try - { - writeAction(_writer); - return true; - } - catch (IOException ex) - { - // swallow - Reporter.Output.WriteLine($"Ignore {nameof(IOException)} during sending message: \"{ex.Message}\"."); - } - catch (Exception ex) - { - Reporter.Output.WriteLine($"Unexpected exception {ex.GetType().Name} during sending message: \"{ex.Message}\"."); - throw; - } - } - - return false; - } - - public bool Send(Message message) - { - return Send(_writer => - { - Reporter.Output.WriteLine($"OnSend ({message})"); - _writer.Write(JsonConvert.SerializeObject(message)); - }); - } - - private void ReceiveMessages() - { - try - { - while (true) - { - var content = _reader.ReadString(); - var message = JsonConvert.DeserializeObject(content); - - Reporter.Output.WriteLine($"OnReceive ({message})"); - OnReceive(message); - } - } - catch (IOException ex) - { - Reporter.Output.WriteLine($"Ignore {nameof(IOException)} during receiving messages: \"{ex}\"."); - } - catch (Exception ex) - { - Reporter.Error.WriteLine($"Unexpected exception {ex.GetType().Name} during receiving messages: \"{ex}\"."); - } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Program.cs b/src/dotnet/commands/dotnet-projectmodel-server/Program.cs deleted file mode 100644 index 3211ed15d..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/Program.cs +++ /dev/null @@ -1,161 +0,0 @@ -// 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.Diagnostics; -using System.Net; -using System.Net.Sockets; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - public class ProjectModelServerCommand - { - private readonly Dictionary _projects; - private readonly DesignTimeWorkspace _workspaceContext; - private readonly ProtocolManager _protocolManager; - private readonly string _hostName; - private readonly int _port; - private Socket _listenSocket; - - public ProjectModelServerCommand(int port, string hostName) - { - _port = port; - _hostName = hostName; - _protocolManager = new ProtocolManager(maxVersion: 4); - _workspaceContext = new DesignTimeWorkspace(ProjectReaderSettings.ReadFromEnvironment()); - _projects = new Dictionary(); - } - - public static int Run(string[] args) - { - var app = new CommandLineApplication(); - app.Name = "dotnet-projectmodel-server"; - app.Description = ".NET Project Model Server"; - app.FullName = ".NET Design Time Server"; - app.Description = ".NET Design Time Server"; - app.HelpOption("-?|-h|--help"); - - var verbose = app.Option("--verbose", "Verbose ouput", CommandOptionType.NoValue); - var hostpid = app.Option("--host-pid", "The process id of the host", CommandOptionType.SingleValue); - var hostname = app.Option("--host-name", "The name of the host", CommandOptionType.SingleValue); - var port = app.Option("--port", "The TCP port used for communication", CommandOptionType.SingleValue); - - app.OnExecute(() => - { - try - { - if (!MonitorHostProcess(hostpid)) - { - return 1; - } - - var intPort = CheckPort(port); - if (intPort == -1) - { - return 1; - } - - if (!hostname.HasValue()) - { - Reporter.Error.WriteLine($"Option \"{hostname.LongName}\" is missing."); - return 1; - } - - var program = new ProjectModelServerCommand(intPort, hostname.Value()); - program.OpenChannel(); - } - catch (Exception ex) - { - Reporter.Error.WriteLine($"Unhandled exception in server main: {ex}"); - throw; - } - - return 0; - }); - - return app.Execute(args); - } - - public void OpenChannel() - { - _listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - _listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, _port)); - _listenSocket.Listen(10); - - Reporter.Output.WriteLine($"Process ID {Process.GetCurrentProcess().Id}"); - Reporter.Output.WriteLine($"Listening on port {_port}"); - - while (true) - { - var acceptSocket = _listenSocket.Accept(); - Reporter.Output.WriteLine($"Client accepted {acceptSocket.LocalEndPoint}"); - - var connection = new ConnectionContext(acceptSocket, - _hostName, - _protocolManager, - _workspaceContext, - _projects); - - connection.QueueStart(); - } - } - - public void Shutdown() - { - if (_listenSocket.Connected) - { - _listenSocket.Shutdown(SocketShutdown.Both); - } - } - - private static int CheckPort(CommandOption port) - { - if (!port.HasValue()) - { - Reporter.Error.WriteLine($"Option \"{port.LongName}\" is missing."); - } - - int result; - if (int.TryParse(port.Value(), out result)) - { - return result; - } - else - { - Reporter.Error.WriteLine($"Option \"{port.LongName}\" is not a valid Int32 value."); - return -1; - } - } - - private static bool MonitorHostProcess(CommandOption host) - { - if (!host.HasValue()) - { - Console.Error.WriteLine($"Option \"{host.LongName}\" is missing."); - return false; - } - - int hostPID; - if (int.TryParse(host.Value(), out hostPID)) - { - var hostProcess = Process.GetProcessById(hostPID); - hostProcess.EnableRaisingEvents = true; - hostProcess.Exited += (s, e) => - { - Process.GetCurrentProcess().Kill(); - }; - - Reporter.Output.WriteLine($"Server will exit when process {hostPID} exits."); - return true; - } - else - { - Reporter.Error.WriteLine($"Option \"{host.LongName}\" is not a valid Int32 value."); - return false; - } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/ProjectManager.cs b/src/dotnet/commands/dotnet-projectmodel-server/ProjectManager.cs deleted file mode 100644 index 47f4a0390..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/ProjectManager.cs +++ /dev/null @@ -1,327 +0,0 @@ -// 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.Diagnostics; -using System.Linq; -using System.Threading; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel.Server.Helpers; -using Microsoft.DotNet.ProjectModel.Server.Messengers; -using Microsoft.DotNet.ProjectModel.Server.Models; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - internal class ProjectManager - { - private readonly object _processingLock = new object(); - private readonly Queue _inbox = new Queue(); - private readonly ProtocolManager _protocolManager; - - private ConnectionContext _initializedContext; - - // triggers - private readonly Trigger _appPath = new Trigger(); - private readonly Trigger _configure = new Trigger(); - private readonly Trigger _refreshDependencies = new Trigger(); - private readonly Trigger _filesChanged = new Trigger(); - - private ProjectSnapshot _local = new ProjectSnapshot(); - private ProjectSnapshot _remote = new ProjectSnapshot(); - - private readonly DesignTimeWorkspace _workspaceContext; - private int? _contextProtocolVersion; - - private readonly List> _messengers; - - private ProjectDiagnosticsMessenger _projectDiagnosticsMessenger; - private GlobalErrorMessenger _globalErrorMessenger; - private ProjectInformationMessenger _projectInforamtionMessenger; - - public ProjectManager( - int contextId, - DesignTimeWorkspace workspaceContext, - ProtocolManager protocolManager) - { - Id = contextId; - _workspaceContext = workspaceContext; - _protocolManager = protocolManager; - - _messengers = new List> - { - new ReferencesMessenger(Transmit), - new DependenciesMessenger(Transmit), - new DependencyDiagnosticsMessenger(Transmit), - new CompilerOptionsMessenger(Transmit), - new SourcesMessenger(Transmit) - }; - - _projectDiagnosticsMessenger = new ProjectDiagnosticsMessenger(Transmit); - _globalErrorMessenger = new GlobalErrorMessenger(Transmit); - _projectInforamtionMessenger = new ProjectInformationMessenger(Transmit); - } - - public int Id { get; } - - public string ProjectPath { get { return _appPath.Value; } } - - public int ProtocolVersion - { - get - { - if (_contextProtocolVersion.HasValue) - { - return _contextProtocolVersion.Value; - } - else - { - return _protocolManager.CurrentVersion; - } - } - } - - public void OnReceive(Message message) - { - lock (_inbox) - { - _inbox.Enqueue(message); - } - - ThreadPool.QueueUserWorkItem(state => ((ProjectManager)state).ProcessLoop(), this); - } - - private void Transmit(string messageType, object payload) - { - var message = Message.FromPayload(messageType, Id, payload); - _initializedContext.Transmit(message); - } - - private void ProcessLoop() - { - if (!Monitor.TryEnter(_processingLock)) - { - return; - } - - try - { - lock (_inbox) - { - if (!_inbox.Any()) - { - return; - } - } - - DoProcessLoop(); - } - catch (Exception ex) - { - Reporter.Error.WriteLine($"A unexpected exception occurred: {ex}"); - - var error = new ErrorMessage - { - Message = ex.Message - }; - - var fileFormatException = ex as FileFormatException; - if (fileFormatException != null) - { - error.Path = fileFormatException.Path; - error.Line = fileFormatException.Line; - error.Column = fileFormatException.Column; - } - - var message = Message.FromPayload(MessageTypes.Error, Id, error); - - _initializedContext.Transmit(message); - _remote.GlobalErrorMessage = error; - } - finally - { - Monitor.Exit(_processingLock); - } - } - - private void DoProcessLoop() - { - while (true) - { - DrainInbox(); - - UpdateProject(); - SendOutgingMessages(); - - lock (_inbox) - { - if (_inbox.Count == 0) - { - return; - } - } - } - } - - private void DrainInbox() - { - Reporter.Output.WriteLine("Begin draining inbox."); - - while (ProcessMessage()) { } - - Reporter.Output.WriteLine("Finish draining inbox."); - } - - private bool ProcessMessage() - { - Message message; - - lock (_inbox) - { - if (!_inbox.Any()) - { - return false; - } - - message = _inbox.Dequeue(); - Debug.Assert(message != null); - } - - Reporter.Output.WriteLine($"Received {message.MessageType}"); - - switch (message.MessageType) - { - case MessageTypes.Initialize: - Initialize(message); - break; - case MessageTypes.ChangeConfiguration: - // TODO: what if the payload is null or represent empty string? - _configure.Value = message.Payload.GetValue("Configuration"); - break; - case MessageTypes.RefreshDependencies: - // In the case of RefreshDependencies request, the cache will not be reset in any case. The value - // is set so as to trigger refresh action in later loop. - _refreshDependencies.Value = false; - break; - case MessageTypes.RestoreComplete: - // In the case of RestoreComplete request, the value of the 'Reset' property in payload will determine - // if the cache should be reset. If the property doesn't exist, cache will be reset. - _refreshDependencies.Value = message.Payload.HasValues ? message.Payload.Value("Reset") : true; - break; - case MessageTypes.FilesChanged: - _filesChanged.Value = 0; - break; - } - - return true; - } - - private void Initialize(Message message) - { - if (_initializedContext != null) - { - Reporter.Output.WriteLine($"Received {message.MessageType} message more than once for {_appPath.Value}"); - return; - } - - _initializedContext = message.Sender; - _appPath.Value = message.Payload.GetValue("ProjectFolder"); - _configure.Value = message.Payload.GetValue("Configuration") ?? "Debug"; - - var version = message.Payload.GetValue("Version"); - if (version != 0 && !_protocolManager.EnvironmentOverridden) - { - _contextProtocolVersion = Math.Min(version, _protocolManager.MaxVersion); - Reporter.Output.WriteLine($"Set context protocol version to {_contextProtocolVersion.Value}"); - } - } - - private bool UpdateProject() - { - ProjectSnapshot newSnapshot = null; - - if (_appPath.WasAssigned || _configure.WasAssigned || _filesChanged.WasAssigned || _refreshDependencies.WasAssigned) - { - _appPath.ClearAssigned(); - _configure.ClearAssigned(); - _filesChanged.ClearAssigned(); - - bool resetCache = _refreshDependencies.WasAssigned ? _refreshDependencies.Value : false; - _refreshDependencies.ClearAssigned(); - - newSnapshot = ProjectSnapshot.Create(_appPath.Value, - _configure.Value, - _workspaceContext, - _remote.ProjectSearchPaths, - clearWorkspaceContextCache: resetCache); - } - - if (newSnapshot == null) - { - return false; - } - - _local = newSnapshot; - - return true; - } - - private void SendOutgingMessages() - { - _projectInforamtionMessenger.UpdateRemote(_local, _remote); - _projectDiagnosticsMessenger.UpdateRemote(_local, _remote); - - var unprocessedFrameworks = new HashSet(_remote.ProjectContexts.Keys); - foreach (var pair in _local.ProjectContexts) - { - ProjectContextSnapshot localProjectSnapshot = pair.Value; - ProjectContextSnapshot remoteProjectSnapshot; - - if (!_remote.ProjectContexts.TryGetValue(pair.Key, out remoteProjectSnapshot)) - { - remoteProjectSnapshot = new ProjectContextSnapshot(); - _remote.ProjectContexts[pair.Key] = remoteProjectSnapshot; - } - - unprocessedFrameworks.Remove(pair.Key); - - foreach (var messenger in _messengers) - { - messenger.UpdateRemote(localProjectSnapshot, - remoteProjectSnapshot); - } - } - - // Remove all processed frameworks from the remote view - foreach (var framework in unprocessedFrameworks) - { - _remote.ProjectContexts.Remove(framework); - } - - _globalErrorMessenger.UpdateRemote(_local, _remote); - } - - private class Trigger - { - private TValue _value; - - public bool WasAssigned { get; private set; } - - public void ClearAssigned() - { - WasAssigned = false; - } - - public TValue Value - { - get { return _value; } - set - { - WasAssigned = true; - _value = value; - } - } - } - } -} diff --git a/src/dotnet/commands/dotnet-projectmodel-server/ProtocolManager.cs b/src/dotnet/commands/dotnet-projectmodel-server/ProtocolManager.cs deleted file mode 100644 index dd7de15c9..000000000 --- a/src/dotnet/commands/dotnet-projectmodel-server/ProtocolManager.cs +++ /dev/null @@ -1,107 +0,0 @@ -// 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 Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel.Server.Models; - -namespace Microsoft.DotNet.ProjectModel.Server -{ - internal class ProtocolManager - { - /// - /// Environment variable for overriding protocol. - /// - public const string EnvDthProtocol = "DTH_PROTOCOL"; - - public ProtocolManager(int maxVersion) - { - MaxVersion = maxVersion; - - // initialized to the highest supported version or environment overridden value - int? protocol = GetProtocolVersionFromEnvironment(); - - if (protocol.HasValue) - { - CurrentVersion = protocol.Value; - EnvironmentOverridden = true; - } - else - { - CurrentVersion = 4; - } - } - - public int MaxVersion { get; } - - public int CurrentVersion { get; private set; } - - public bool EnvironmentOverridden { get; } - - public bool IsProtocolNegotiation(Message message) - { - return message?.MessageType == MessageTypes.ProtocolVersion; - } - - public void Negotiate(Message message) - { - if (!IsProtocolNegotiation(message)) - { - return; - } - - Reporter.Output.WriteLine("Initializing the protocol negotiation."); - - if (EnvironmentOverridden) - { - Reporter.Output.WriteLine($"DTH protocol negotiation is override by environment variable {EnvDthProtocol} and set to {CurrentVersion}."); - return; - } - - var tokenValue = message.Payload?["Version"]; - if (tokenValue == null) - { - Reporter.Output.WriteLine("Protocol negotiation failed. Version property is missing in payload."); - return; - } - - var preferredVersion = tokenValue.ToObject(); - if (preferredVersion == 0) - { - // the preferred version can't be zero. either property is missing or the the payload is corrupted. - Reporter.Output.WriteLine("Protocol negotiation failed. Protocol version 0 is invalid."); - return; - } - - CurrentVersion = Math.Min(preferredVersion, MaxVersion); - Reporter.Output.WriteLine($"Protocol negotiation successed. Use protocol {CurrentVersion}"); - - if (message.Sender != null) - { - Reporter.Output.WriteLine("Respond to protocol negotiation."); - message.Sender.Transmit(Message.FromPayload( - MessageTypes.ProtocolVersion, - 0, - new { Version = CurrentVersion })); - } - else - { - Reporter.Output.WriteLine($"{nameof(Message.Sender)} is null."); - } - } - - private static int? GetProtocolVersionFromEnvironment() - { - // look for the environment variable DTH_PROTOCOL, if it is set override the protocol version. - // this is for debugging. - var strProtocol = Environment.GetEnvironmentVariable(EnvDthProtocol); - int intProtocol = -1; - if (!string.IsNullOrEmpty(strProtocol) && Int32.TryParse(strProtocol, out intProtocol)) - { - return intProtocol; - } - - return null; - } - } -} diff --git a/src/dotnet/commands/dotnet-publish/Program.cs b/src/dotnet/commands/dotnet-publish/Program.cs index 90f502309..45174aff6 100644 --- a/src/dotnet/commands/dotnet-publish/Program.cs +++ b/src/dotnet/commands/dotnet-publish/Program.cs @@ -1,12 +1,8 @@ // 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.IO; using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.Tools.Common; namespace Microsoft.DotNet.Tools.Publish { @@ -16,63 +12,54 @@ namespace Microsoft.DotNet.Tools.Publish { DebugHelper.HandleDebugSwitch(ref args); - var app = new CommandLineApplication(); + CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false); app.Name = "dotnet publish"; app.FullName = ".NET Publisher"; app.Description = "Publisher for the .NET Platform"; + app.AllowArgumentSeparator = true; + app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText; app.HelpOption("-h|--help"); - var framework = app.Option("-f|--framework ", "Target framework to compile for", CommandOptionType.SingleValue); - var runtime = app.Option("-r|--runtime ", "Target runtime to publish for", CommandOptionType.SingleValue); - var buildBasePath = app.Option("-b|--build-base-path ", "Directory in which to place temporary outputs", CommandOptionType.SingleValue); - var output = app.Option("-o|--output ", "Path in which to publish the app", CommandOptionType.SingleValue); - var versionSuffix = app.Option("--version-suffix ", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue); - var configuration = app.Option("-c|--configuration ", "Configuration under which to build", CommandOptionType.SingleValue); - var projectPath = app.Argument("", "The project to publish, defaults to the current directory. Can be a path to a project.json or a project directory"); - var nativeSubdirectories = app.Option("--native-subdirectory", "Temporary mechanism to include subdirectories from native assets of dependency packages in output", CommandOptionType.NoValue); - var noBuild = app.Option("--no-build", "Do not build projects before publishing", CommandOptionType.NoValue); + CommandArgument projectArgument = app.Argument("", + "The MSBuild project file to publish. If a project file is not specified, MSBuild searches the current" + + " working directory for a file that has a file extension that ends in `proj` and uses that file."); + + CommandOption frameworkOption = app.Option( + "-f|--framework ", "Target framework to publish for", + CommandOptionType.SingleValue); + + CommandOption runtimeOption = app.Option( + "-r|--runtime ", "Target runtime to publish for. The default is to publish a portable application.", + CommandOptionType.SingleValue); + + CommandOption outputOption = app.Option( + "-o|--output ", "Path in which to publish the app", + CommandOptionType.SingleValue); + + CommandOption configurationOption = app.Option( + "-c|--configuration ", "Configuration under which to build", + CommandOptionType.SingleValue); + + CommandOption versionSuffixOption = app.Option( + "--version-suffix ", "Defines the value for the $(VersionSuffix) property in the project", + CommandOptionType.SingleValue); app.OnExecute(() => { var publish = new PublishCommand(); - publish.Framework = framework.Value(); - publish.Runtime = runtime.Value(); - publish.BuildBasePath = PathUtility.GetFullPath(buildBasePath.Value()); - publish.OutputPath = output.Value(); - publish.Configuration = configuration.Value() ?? Constants.DefaultConfiguration; - publish.NativeSubdirectories = nativeSubdirectories.HasValue(); - publish.ProjectPath = projectPath.Value; - publish.VersionSuffix = versionSuffix.Value(); - publish.ShouldBuild = !noBuild.HasValue(); + publish.ProjectPath = projectArgument.Value; + publish.Framework = frameworkOption.Value(); + publish.Runtime = runtimeOption.Value(); + publish.OutputPath = outputOption.Value(); + publish.Configuration = configurationOption.Value(); + publish.VersionSuffix = versionSuffixOption.Value(); + publish.ExtraMSBuildArguments = app.RemainingArguments; - publish.Workspace = BuildWorkspace.Create(versionSuffix.Value()); - - if (string.IsNullOrEmpty(publish.ProjectPath)) - { - publish.ProjectPath = Directory.GetCurrentDirectory(); - } - - if (!publish.TryPrepareForPublish()) - { - return 1; - } - - publish.PublishAllProjects(); - Reporter.Output.WriteLine($"Published {publish.NumberOfPublishedProjects}/{publish.NumberOfProjects} projects successfully"); - return (publish.NumberOfPublishedProjects == publish.NumberOfProjects) ? 0 : 1; + return publish.Execute(); }); - try - { - return app.Execute(args); - } - catch (Exception ex) - { - Reporter.Error.WriteLine(ex.Message.Red()); - Reporter.Verbose.WriteLine(ex.ToString().Yellow()); - return 1; - } + return app.Execute(args); } - } + } } diff --git a/src/dotnet/commands/dotnet-publish/PublishCommand.cs b/src/dotnet/commands/dotnet-publish/PublishCommand.cs index cb202bb36..79476f727 100644 --- a/src/dotnet/commands/dotnet-publish/PublishCommand.cs +++ b/src/dotnet/commands/dotnet-publish/PublishCommand.cs @@ -1,435 +1,67 @@ // 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.Compiler.Common; using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Files; -using Microsoft.DotNet.InternalAbstractions; -using Microsoft.DotNet.ProjectModel; -using Microsoft.DotNet.ProjectModel.Compilation; -using Microsoft.DotNet.ProjectModel.Files; -using Microsoft.DotNet.ProjectModel.Utilities; -using Microsoft.DotNet.Tools.Common; -using NuGet.Frameworks; +using Microsoft.DotNet.Tools.MSBuild; +using Microsoft.DotNet.Tools.Restore; namespace Microsoft.DotNet.Tools.Publish { public partial class PublishCommand { - private const string PublishSubfolderName = "publish"; - public string ProjectPath { get; set; } - public string Configuration { get; set; } - public string BuildBasePath { get; set; } - public string OutputPath { get; set; } public string Framework { get; set; } public string Runtime { get; set; } - public bool NativeSubdirectories { get; set; } - public NuGetFramework NugetFramework { get; set; } - public BuildWorkspace Workspace { get; set; } - public IList ProjectContexts { get; set; } + public string OutputPath { get; set; } + public string Configuration { get; set; } public string VersionSuffix { get; set; } - public int NumberOfProjects { get; private set; } - public int NumberOfPublishedProjects { get; private set; } - public bool ShouldBuild { get; set; } - public bool TryPrepareForPublish() + public List ExtraMSBuildArguments { get; set; } + + private PublishCommand() { - if (Framework != null) - { - NugetFramework = NuGetFramework.Parse(Framework); - - if (NugetFramework.IsUnsupported) - { - Reporter.Output.WriteLine($"Unsupported framework {Framework}.".Red()); - return false; - } - } - - ProjectContexts = SelectContexts(ProjectPath, NugetFramework, Runtime).ToList(); - if (!ProjectContexts.Any()) - { - string errMsg = $"'{ProjectPath}' cannot be published for '{Framework ?? ""}' '{Runtime ?? ""}'"; - Reporter.Output.WriteLine(errMsg.Red()); - return false; - } - - return true; } - public void PublishAllProjects() + public int Execute() { - NumberOfPublishedProjects = 0; - NumberOfProjects = 0; + List msbuildArgs = new List(); - foreach (var project in ProjectContexts) + if (!string.IsNullOrEmpty(ProjectPath)) { - if (PublishProjectContext(project, BuildBasePath, OutputPath, Configuration, NativeSubdirectories)) - { - NumberOfPublishedProjects++; - } - - NumberOfProjects++; - } - } - - /// - /// Publish the project for given 'framework (ex - netcoreapp1.0)' and 'runtimeID (ex - win7-x64)' - /// - /// project that is to be published - /// Location of published files - /// Debug or Release - /// - /// Return 0 if successful else return non-zero - private bool PublishProjectContext(ProjectContext context, string buildBasePath, string outputPath, string configuration, bool nativeSubdirectories) - { - var target = context.TargetFramework.DotNetFrameworkName; - if (!string.IsNullOrEmpty(context.RuntimeIdentifier)) - { - target = $"{target}/{context.RuntimeIdentifier}"; - } - Reporter.Output.WriteLine($"Publishing {context.RootProject.Identity.Name.Yellow()} for {target.Yellow()}"); - - var options = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration); - var outputPaths = context.GetOutputPaths(configuration, buildBasePath, outputPath); - - if (string.IsNullOrEmpty(outputPath)) - { - outputPath = Path.Combine(outputPaths.RuntimeOutputPath, PublishSubfolderName); + msbuildArgs.Add(ProjectPath); } - var contextVariables = new Dictionary - { - { "publish:ProjectPath", context.ProjectDirectory }, - { "publish:Configuration", configuration }, - { "publish:OutputPath", outputPath }, - { "publish:TargetFramework", context.TargetFramework.GetShortFolderName() }, - { "publish:FullTargetFramework", context.TargetFramework.DotNetFrameworkName }, - { "publish:Runtime", context.RuntimeIdentifier }, - }; + msbuildArgs.Add("/t:Publish"); - RunScripts(context, ScriptNames.PrePublish, contextVariables); - - if (!Directory.Exists(outputPath)) + if (!string.IsNullOrEmpty(Framework)) { - Directory.CreateDirectory(outputPath); + msbuildArgs.Add($"/p:TargetFramework={Framework}"); } - // Compile the project (and transitively, all it's dependencies) - if (ShouldBuild && !InvokeBuildOnProject(context, buildBasePath, configuration)) + if (!string.IsNullOrEmpty(Runtime)) { - return false; + msbuildArgs.Add($"/p:RuntimeIdentifier={Runtime}"); } - // Use a library exporter to collect publish assets - var exporter = context.CreateExporter(configuration, buildBasePath); - - // Get the output paths used by the call to `dotnet build` above (since we didn't pass `--output`, they will be different from - // our current output paths) - var buildOutputPaths = context.GetOutputPaths(configuration, buildBasePath); - - var exports = exporter.GetAllExports(); - - var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name, StringComparer.OrdinalIgnoreCase); - var platformExclusionList = context.GetPlatformExclusionList(exportsLookup); - var buildExclusionList = context.GetTypeBuildExclusionList(exportsLookup); - var allExclusionList = new HashSet(platformExclusionList); - allExclusionList.UnionWith(buildExclusionList); - var filteredExports = exports.FilterExports(allExclusionList); - - foreach (var export in filteredExports) + if (!string.IsNullOrEmpty(OutputPath)) { - Reporter.Verbose.WriteLine($"publish: Publishing {export.Library.Identity.ToString().Green().Bold()} ..."); - - PublishAssetGroups(export.RuntimeAssemblyGroups, outputPath, nativeSubdirectories: false, includeRuntimeGroups: context.IsPortable); - PublishAssetGroups(export.NativeLibraryGroups, outputPath, nativeSubdirectories, includeRuntimeGroups: context.IsPortable); - - var runtimeAssetsToCopy = export.RuntimeAssets.Where(a => ShouldCopyExportRuntimeAsset(context, buildOutputPaths, export, a)); - runtimeAssetsToCopy.StructuredCopyTo(outputPath, outputPaths.IntermediateOutputDirectoryPath); - - foreach (var resourceAsset in export.ResourceAssemblies) - { - var dir = Path.Combine(outputPath, resourceAsset.Locale); - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - File.Copy(resourceAsset.Asset.ResolvedPath, Path.Combine(dir, resourceAsset.Asset.FileName), overwrite: true); - } - } - foreach (var export in exports) - { - if (options.PreserveCompilationContext.GetValueOrDefault()) - { - PublishRefs(export, outputPath); - } + msbuildArgs.Add($"/p:PublishDir={OutputPath}"); } - if (context.ProjectFile.HasRuntimeOutput(configuration) && !context.TargetFramework.IsDesktop()) + if (!string.IsNullOrEmpty(Configuration)) { - // Make executable in the new location - var executable = new Executable(context, buildOutputPaths, outputPath, buildOutputPaths.IntermediateOutputDirectoryPath, exporter, configuration); - var runtimeExports = filteredExports; - var compilationExports = exports.FilterExports(buildExclusionList); - - executable.WriteConfigurationFiles(exports, runtimeExports, compilationExports, includeDevConfig: false); - } - - var contentFiles = new ContentFiles(context); - - if (context.ProjectFile.PublishOptions != null) - { - var includeEntries = IncludeFilesResolver.GetIncludeFiles( - context.ProjectFile.PublishOptions, - PathUtility.EnsureTrailingSlash(outputPath), - diagnostics: null); - - contentFiles.StructuredCopyTo(outputPath, includeEntries); - } - else - { - contentFiles.StructuredCopyTo(outputPath); - } - - // Publish a host if this is an application - if (options.EmitEntryPoint.GetValueOrDefault() && !string.IsNullOrEmpty(context.RuntimeIdentifier)) - { - Reporter.Verbose.WriteLine($"publish: Renaming native host in output to create fully standalone output."); - RenamePublishedHost(context, outputPath, options); - } - - RunScripts(context, ScriptNames.PostPublish, contextVariables); - - Reporter.Output.WriteLine($"publish: Published to {outputPath}".Green().Bold()); - - return true; - } - - - /// - /// Filters which export's RuntimeAssets should get copied to the output path. - /// - /// - /// True if the asset should be copied to the output path; otherwise, false. - /// - private static bool ShouldCopyExportRuntimeAsset(ProjectContext context, OutputPaths buildOutputPaths, LibraryExport export, LibraryAsset asset) - { - // The current project has the host .exe in its runtime assets, but it shouldn't be copied - // to the output path during publish. The host will come from the export that has the real host in it. - - if (context.RootProject.Identity == export.Library.Identity) - { - if (asset.ResolvedPath == buildOutputPaths.RuntimeFiles.Executable) - { - return false; - } - } - - return true; - } - - private bool InvokeBuildOnProject(ProjectContext context, string buildBasePath, string configuration) - { - var args = new List() - { - "--framework", - $"{context.TargetFramework.DotNetFrameworkName}", - "--configuration", - configuration, - context.ProjectFile.ProjectDirectory - }; - - if (!string.IsNullOrEmpty(context.RuntimeIdentifier)) - { - args.Insert(0, context.RuntimeIdentifier); - args.Insert(0, "--runtime"); + msbuildArgs.Add($"/p:Configuration={Configuration}"); } if (!string.IsNullOrEmpty(VersionSuffix)) { - args.Add("--version-suffix"); - args.Add(VersionSuffix); + msbuildArgs.Add($"/p:VersionSuffix={VersionSuffix}"); } - if (!string.IsNullOrEmpty(buildBasePath)) - { - args.Add("--build-base-path"); - args.Add(buildBasePath); - } + msbuildArgs.AddRange(ExtraMSBuildArguments); - var result = Build.BuildCommand.Run(args.ToArray(), Workspace); - - return result == 0; - } - - private static void PublishRefs(LibraryExport export, string outputPath) - { - var refsPath = Path.Combine(outputPath, "refs"); - if (!Directory.Exists(refsPath)) - { - Directory.CreateDirectory(refsPath); - } - - // Do not copy compilation assembly if it's in runtime assemblies - var runtimeAssemblies = new HashSet(export.RuntimeAssemblyGroups.GetDefaultAssets()); - foreach (var compilationAssembly in export.CompilationAssemblies) - { - if (runtimeAssemblies.Contains(compilationAssembly)) - { - continue; - } - var destFileName = Path.Combine(refsPath, Path.GetFileName(compilationAssembly.ResolvedPath)); - File.Copy(compilationAssembly.ResolvedPath, destFileName, overwrite: true); - } - } - - private static int RenamePublishedHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions) - { - if (context.TargetFramework.IsDesktop()) - { - return 0; - } - - var publishedHostFile = ResolvePublishedHostFile(outputPath); - if (publishedHostFile == null) - { - Reporter.Output.WriteLine($"publish: warning: host executable not available in dependencies, using host for current platform"); - // TODO should this be an error? - - CoreHost.CopyTo(outputPath, compilationOptions.OutputName + Constants.ExeSuffix); - return 0; - } - - var publishedHostExtension = Path.GetExtension(publishedHostFile); - var renamedHostName = compilationOptions.OutputName + publishedHostExtension; - var renamedHostFile = Path.Combine(outputPath, renamedHostName); - - try - { - Reporter.Verbose.WriteLine($"publish: renaming published host {publishedHostFile} to {renamedHostFile}"); - File.Copy(publishedHostFile, renamedHostFile, true); - File.Delete(publishedHostFile); - } - catch (Exception e) - { - Reporter.Error.WriteLine($"publish: Failed to rename {publishedHostFile} to {renamedHostFile}: {e.Message}"); - return 1; - } - - return 0; - } - - private static string ResolvePublishedHostFile(string outputPath) - { - var tryExtensions = new string[] { "", ".exe" }; - - foreach (var extension in tryExtensions) - { - var hostFile = Path.Combine(outputPath, Constants.PublishedHostExecutableName + extension); - if (File.Exists(hostFile)) - { - Reporter.Verbose.WriteLine($"resolved published host: {hostFile}"); - return hostFile; - } - } - - Reporter.Verbose.WriteLine($"failed to resolve published host in: {outputPath}"); - return null; - } - private void PublishAssetGroups(IEnumerable groups, string outputPath, bool nativeSubdirectories, bool includeRuntimeGroups) - { - foreach (var group in groups.Where(g => includeRuntimeGroups || string.IsNullOrEmpty(g.Runtime))) - { - foreach (var file in group.Assets) - { - var destinationDirectory = DetermineFileDestinationDirectory(file, outputPath, nativeSubdirectories); - - if (!string.IsNullOrEmpty(group.Runtime)) - { - destinationDirectory = Path.Combine(destinationDirectory, Path.GetDirectoryName(file.RelativePath)); - } - - if (!Directory.Exists(destinationDirectory)) - { - Directory.CreateDirectory(destinationDirectory); - } - - Reporter.Verbose.WriteLine($"Publishing file {Path.GetFileName(file.RelativePath)} to {destinationDirectory}"); - File.Copy(file.ResolvedPath, Path.Combine(destinationDirectory, file.FileName), overwrite: true); - } - } - } - - private static string DetermineFileDestinationDirectory(LibraryAsset file, string outputPath, bool nativeSubdirectories) - { - var destinationDirectory = outputPath; - - if (nativeSubdirectories) - { - destinationDirectory = Path.Combine(outputPath, GetNativeRelativeSubdirectory(file.RelativePath)); - } - - return destinationDirectory; - } - - private static string GetNativeRelativeSubdirectory(string filepath) - { - string directoryPath = Path.GetDirectoryName(filepath); - - string[] parts = directoryPath.Split(new string[] { "native" }, 2, StringSplitOptions.None); - - if (parts.Length != 2) - { - throw new Exception("Unrecognized Native Directory Format: " + filepath); - } - - string candidate = parts[1]; - candidate = candidate.TrimStart(new char[] { '/', '\\' }); - - return candidate; - } - - private IEnumerable SelectContexts(string projectPath, NuGetFramework framework, string runtime) - { - if (projectPath.EndsWith("project.json")) - { - if (File.Exists(projectPath) == false) - throw new InvalidProjectException($"'{projectPath}' does not exist"); - } - else if (File.Exists(Path.Combine(projectPath, "project.json")) == false) - { - throw new InvalidProjectException($"'{projectPath}' does not contain a project.json file"); - } - - var contexts = Workspace.GetProjectContextCollection(projectPath) - .EnsureValid(projectPath) - .FrameworkOnlyContexts; - - contexts = framework == null ? - contexts : - contexts.Where(c => Equals(c.TargetFramework, framework)); - - var rids = string.IsNullOrEmpty(runtime) ? - DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers(DotnetFiles.VersionFileObject) : - new[] { runtime }; - - return contexts.Select(c => Workspace.GetRuntimeContext(c, rids)); - } - - private static void RunScripts(ProjectContext context, string name, Dictionary contextVariables) - { - foreach (var script in context.ProjectFile.Scripts.GetOrEmpty(name)) - { - ScriptExecutor.CreateCommandForScript(context.ProjectFile, script, contextVariables) - .ForwardStdErr() - .ForwardStdOut() - .Execute(); - } + return new MSBuildForwardingApp(msbuildArgs).Execute(); } } } diff --git a/src/dotnet/commands/dotnet-publish/README.md b/src/dotnet/commands/dotnet-publish/README.md deleted file mode 100644 index c61a8cb4b..000000000 --- a/src/dotnet/commands/dotnet-publish/README.md +++ /dev/null @@ -1,79 +0,0 @@ -% DOTNET-PUBLISH(1) -% Microsoft Corporation dotnetclifeedback@microsoft.com -% June 2016 - -## NAME - -`dotnet-publish` - Packs the application and all of its dependencies into a folder getting it ready for publishing - -## SYNOPSIS - -`dotnet publish [--framework] - [--runtime] [--build-base-path] [--output] - [--version-suffix] [--configuration] - []` - -## DESCRIPTION - -`dotnet publish` compiles the application, reads through its dependencies specified in the `project.json` file and publishes the resulting set of files to a directory. - -Depending on the type of portable app, the resulting directory will contain the following: - -1. **Portable application** - application's intermediate language (IL) code and all of application's managed dependencies. - * **Portable application with native dependencies** - same as above with a sub-directory for the supported platform of each native - dependency. -2. **Self-contained application** - same as above plus the entire runtime for the targeted platform. - -The above types are covered in more details in the [types of portable applications](https://docs.microsoft.com/en-us/dotnet/articles/core/app-types) topic. - -## OPTIONS - -`[project]` - -`dotnet publish` needs access to the `project.json` file to work. If it is not specified on invocation via [project], `project.json` in the current directory will be the default. -If no `project.json` can be found, `dotnet publish` will throw an error. - -`-f`, `--framework` [FID] - -Publishes the application for a given framework identifier (FID). If not specified, FID is read from `project.json`. In no valid framework is found, the command will throw an error. If multiple valid frameworks are found, the command will publish for all valid frameworks. - - -`-r`, `--runtime` [RID] - -Publishes the application for a given runtime. - -`-b`, `--build-base-path` [DIR] - -Directory in which to place temporary outputs. - -`-o`, `--output` - -Specify the path where to place the directory. If not specified, it will default to _./bin/[configuration]/[framework]/_ -for portable applications or _./bin/[configuration]/[framework]/[runtime]_ for self-contained applications. - ---version-suffix [VERSION_SUFFIX] - -Defines what `*` should be replaced with in the version field in the project.json file. - -`-c`, `--configuration [Debug|Release]` - -Configuration to use when publishing. The default value is Debug. - -## EXAMPLES - -`dotnet publish` - -Publishes an application using the framework found in `project.json`. If `project.json` contains `runtimes` node, publish for the RID of the current platform. - -`dotnet publish ~/projects/app1/project.json` - -Publishes the application using the specified `project.json`. - -`dotnet publish --framework netcoreapp1.0` - -Publishes the current application using the `netcoreapp1.0` framework. - -`dotnet publish --framework netcoreapp1.0 --runtime osx.10.11-x64` - -Publishes the current application using the `netcoreapp1.0` framework and runtime for `OS X 10.10`. This RID has to -exist in the `project.json` `runtimes` node. diff --git a/src/dotnet/commands/dotnet-publish3/Program.cs b/src/dotnet/commands/dotnet-publish3/Program.cs deleted file mode 100644 index 1e84dcd42..000000000 --- a/src/dotnet/commands/dotnet-publish3/Program.cs +++ /dev/null @@ -1,65 +0,0 @@ -// 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.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; - -namespace Microsoft.DotNet.Tools.Publish3 -{ - public partial class Publish3Command - { - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false); - app.Name = "dotnet publish3"; - app.FullName = ".NET Publisher"; - app.Description = "Publisher for the .NET Platform"; - app.AllowArgumentSeparator = true; - app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText; - app.HelpOption("-h|--help"); - - CommandArgument projectArgument = app.Argument("", - "The MSBuild project file to publish. If a project file is not specified, MSBuild searches the current" + - " working directory for a file that has a file extension that ends in `proj` and uses that file."); - - CommandOption frameworkOption = app.Option( - "-f|--framework ", "Target framework to publish for", - CommandOptionType.SingleValue); - - CommandOption runtimeOption = app.Option( - "-r|--runtime ", "Target runtime to publish for. The default is to publish a portable application.", - CommandOptionType.SingleValue); - - CommandOption outputOption = app.Option( - "-o|--output ", "Path in which to publish the app", - CommandOptionType.SingleValue); - - CommandOption configurationOption = app.Option( - "-c|--configuration ", "Configuration under which to build", - CommandOptionType.SingleValue); - - CommandOption versionSuffixOption = app.Option( - "--version-suffix ", "Defines the value for the $(VersionSuffix) property in the project", - CommandOptionType.SingleValue); - - app.OnExecute(() => - { - Publish3Command publish = new Publish3Command(); - - publish.ProjectPath = projectArgument.Value; - publish.Framework = frameworkOption.Value(); - publish.Runtime = runtimeOption.Value(); - publish.OutputPath = outputOption.Value(); - publish.Configuration = configurationOption.Value(); - publish.VersionSuffix = versionSuffixOption.Value(); - publish.ExtraMSBuildArguments = app.RemainingArguments; - - return publish.Execute(); - }); - - return app.Execute(args); - } - } -} diff --git a/src/dotnet/commands/dotnet-publish3/Publish3Command.cs b/src/dotnet/commands/dotnet-publish3/Publish3Command.cs deleted file mode 100644 index 79366dab7..000000000 --- a/src/dotnet/commands/dotnet-publish3/Publish3Command.cs +++ /dev/null @@ -1,68 +0,0 @@ -// 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.Collections.Generic; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Tools.MSBuild; -using Microsoft.DotNet.Tools.Restore3; - -namespace Microsoft.DotNet.Tools.Publish3 -{ - public partial class Publish3Command - { - public string ProjectPath { get; set; } - public string Framework { get; set; } - public string Runtime { get; set; } - public string OutputPath { get; set; } - public string Configuration { get; set; } - public string VersionSuffix { get; set; } - - public List ExtraMSBuildArguments { get; set; } - - private Publish3Command() - { - } - - public int Execute() - { - List msbuildArgs = new List(); - - if (!string.IsNullOrEmpty(ProjectPath)) - { - msbuildArgs.Add(ProjectPath); - } - - msbuildArgs.Add("/t:Publish"); - - if (!string.IsNullOrEmpty(Framework)) - { - msbuildArgs.Add($"/p:TargetFramework={Framework}"); - } - - if (!string.IsNullOrEmpty(Runtime)) - { - msbuildArgs.Add($"/p:RuntimeIdentifier={Runtime}"); - } - - if (!string.IsNullOrEmpty(OutputPath)) - { - msbuildArgs.Add($"/p:PublishDir={OutputPath}"); - } - - if (!string.IsNullOrEmpty(Configuration)) - { - msbuildArgs.Add($"/p:Configuration={Configuration}"); - } - - if (!string.IsNullOrEmpty(VersionSuffix)) - { - msbuildArgs.Add($"/p:VersionSuffix={VersionSuffix}"); - } - - msbuildArgs.AddRange(ExtraMSBuildArguments); - - return new MSBuildForwardingApp(msbuildArgs).Execute(); - } - - } -} diff --git a/src/dotnet/commands/dotnet-repl-csi/Program.cs b/src/dotnet/commands/dotnet-repl-csi/Program.cs deleted file mode 100644 index 6f085fecf..000000000 --- a/src/dotnet/commands/dotnet-repl-csi/Program.cs +++ /dev/null @@ -1,184 +0,0 @@ -// 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.IO; -using System.Linq; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.ProjectModel; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.Repl.Csi -{ - public sealed class ReplCsiCommand - { - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - var app = new CommandLineApplication(throwOnUnexpectedArg: false); - app.Name = "dotnet repl csi"; - app.FullName = "C# REPL"; - app.Description = "C# REPL for the .NET platform"; - app.HelpOption("-h|--help"); - - var script = app.Argument("