diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj index ac661a175..cc26d6ade 100644 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj +++ b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj @@ -10,6 +10,10 @@ $(PackageTargetFallback);portable-net45+win8;dnxcore50 + + 1.0.0-preview5-* + + @@ -34,7 +38,7 @@ 4.0.0-rc2 - 1.0.0-preview5-* + $(SdkNugetVersion) diff --git a/build/Microsoft.DotNet.Cli.BundledSdks.proj b/build/Microsoft.DotNet.Cli.BundledSdks.proj index 4408ca0a4..a17c04fe1 100644 --- a/build/Microsoft.DotNet.Cli.BundledSdks.proj +++ b/build/Microsoft.DotNet.Cli.BundledSdks.proj @@ -17,6 +17,9 @@ + + + diff --git a/build/Microsoft.DotNet.Cli.BundledSdks.props b/build/Microsoft.DotNet.Cli.BundledSdks.props index 0babb29ae..ece91153f 100644 --- a/build/Microsoft.DotNet.Cli.BundledSdks.props +++ b/build/Microsoft.DotNet.Cli.BundledSdks.props @@ -8,5 +8,6 @@ + diff --git a/build/Microsoft.DotNet.Cli.DependencyVersions.props b/build/Microsoft.DotNet.Cli.DependencyVersions.props index 7a13ffe63..f2a5bbff8 100644 --- a/build/Microsoft.DotNet.Cli.DependencyVersions.props +++ b/build/Microsoft.DotNet.Cli.DependencyVersions.props @@ -1,8 +1,8 @@ - 15.1.0-preview-000454-01 + 15.1.0-preview-000458-02 1.0.0-alpha-20161104-2 - 1.0.0-alpha-20161203-1-150 + 1.0.0-alpha-20161205-1-154 diff --git a/build/Microsoft.DotNet.Cli.Test.targets b/build/Microsoft.DotNet.Cli.Test.targets index b5ea53144..2ef55efef 100644 --- a/build/Microsoft.DotNet.Cli.Test.targets +++ b/build/Microsoft.DotNet.Cli.Test.targets @@ -209,12 +209,13 @@ /p:RuntimeIdentifier=%(TestPackageProject.PackRuntime) + + MsbuildArgs="$(DotNetPackMsbuildArgs) /p:SdkNuGetVersion=$(SdkNugetVersion)" /> RemoveDefaultCompileAndEmbeddedResourceForWebProjects( + IEnumerable transform, + ProjectType projectType, + ProjectRootElement csproj) + { + if(projectType == ProjectType.Web) + { + var itemsToRemove = transform.Where(p => + p != null && + p.Include.Contains("**\\*") && + (p.ItemType == "Compile" || p.ItemType == "EmbeddedResource")); + + CleanExistingItems(csproj, new [] {"Compile", "EmbeddedResource"}); + + transform = transform.Where(p => !itemsToRemove.Contains(p)); + } + + return transform; + } + private void CleanExistingProperties(ProjectRootElement csproj) { var existingPropertiesToRemove = new [] {"OutputType", "TargetExt"}; @@ -324,6 +368,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules } } + private void CleanExistingItems(ProjectRootElement csproj, IEnumerable itemsToRemove) + { + foreach (var itemName in itemsToRemove) + { + var items = csproj.Items.Where(i => i.ItemType == itemName); + + foreach (var item in items) + { + item.Parent.RemoveChild(item); + } + } + } + private IncludeContext GetCompileIncludeContext(CommonCompilerOptions compilerOptions, string projectDirectory) { // Defaults from src/Microsoft.DotNet.ProjectModel/ProjectReader.cs #L596 diff --git a/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj b/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj index db0fb1146..8aca574b2 100644 --- a/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj +++ b/src/dotnet/commands/dotnet-new/CSharp_Web/$projectName$.csproj @@ -9,20 +9,6 @@ $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; - - $(GlobalExclude);bin\**;obj\**;node_modules\**;jspm_packages\**;bower_components\**;**\*.user;**\*.*proj - - - - - - - - - - - - diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Console/$projectName$.fsproj index 6da500e0c..eb5b0c1da 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Console/$projectName$.fsproj @@ -1,5 +1,4 @@ - - + Exe @@ -15,10 +14,7 @@ - - All - - + All @@ -29,6 +25,4 @@ - - diff --git a/src/dotnet/commands/dotnet-new/FSharp_Lib/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Lib/$projectName$.fsproj index 1d46adc91..f12243115 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Lib/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Lib/$projectName$.fsproj @@ -1,5 +1,4 @@ - - + netstandard1.6 @@ -14,10 +13,7 @@ - - All - - + All @@ -28,6 +24,4 @@ - - diff --git a/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj index d2d15b7ad..4a8357186 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Mstest/$projectName$.fsproj @@ -1,5 +1,4 @@ - - + Exe @@ -14,13 +13,10 @@ - - All - - + - + All @@ -31,5 +27,4 @@ - - \ No newline at end of file + diff --git a/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj index 3f391937e..797f4f0d9 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Web/$projectName$.fsproj @@ -1,5 +1,4 @@ - - + Exe @@ -11,20 +10,26 @@ $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + + $(GlobalExclude);bin\**;obj\**;node_modules\**;jspm_packages\**;bower_components\**;**\*.user;**\*.*proj + + + + + + + - - All - - + All @@ -49,5 +54,4 @@ - diff --git a/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj b/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj index f4368f2d4..ab38c4799 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj +++ b/src/dotnet/commands/dotnet-new/FSharp_Xunittest/$projectName$.fsproj @@ -1,5 +1,4 @@ - - + Exe @@ -13,14 +12,11 @@ - - All - - + All @@ -31,6 +27,4 @@ - - diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs index 16249caa4..da0888d85 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs @@ -63,6 +63,27 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests mockProj.Items.First(i => i.ItemType == "EmbeddedResource").Exclude.Should().BeEmpty(); } + [Fact] + public void MigratingWebProjectWithoutCustomSourcesOrResourcesDoesNotEmitCompileAndEmbeddedResource() + { + var mockProj = RunBuildOptionsRuleOnPj(@" + { + ""buildOptions"": { + ""emitEntryPoint"": true + }, + ""dependencies"": { + ""Microsoft.AspNetCore.Mvc"" : { + ""version"": ""1.0.0"" + } + }, + ""frameworks"": { + ""netcoreapp1.0"": {} + } + }"); + + mockProj.Items.Count().Should().Be(0); + } + [Fact] public void MigratingEmitEntryPointTruePopulatesOutputTypeField() { diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index b5a5c12a5..f14515568 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Migration.Tests [InlineData("TestAppWithRuntimeOptions")] [InlineData("TestAppWithContents")] [InlineData("AppWithAssemblyInfo")] - public void It_migrates_apps(string projectName) + public void ItMigratesApps(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, identifier: projectName) .WithLockFiles() @@ -50,7 +50,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_migrates_signed_apps() + public void ItMigratesSignedApps() { var projectDirectory = TestAssetsManager.CreateTestInstance("TestAppWithSigning").WithLockFiles().Path; @@ -74,7 +74,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_migrates_dotnet_new_console_with_identical_outputs() + public void ItMigratesDotnetNewConsoleWithIdenticalOutputs() { var testInstance = TestAssetsManager .CreateTestInstance("ProjectJsonConsoleTemplate"); @@ -96,8 +96,8 @@ namespace Microsoft.DotNet.Migration.Tests VerifyAllMSBuildOutputsRunnable(projectDirectory); } - [Fact(Skip="Final tools version missing.")] - public void It_migrates_old_dotnet_new_web_without_tools_with_outputs_containing_project_json_outputs() + [Fact] + public void ItMigratesOldDotnetNewWebWithoutToolsWithOutputsContainingProjectJsonOutputs() { var testInstance = TestAssetsManager .CreateTestInstance("ProjectJsonWebTemplate") @@ -108,10 +108,7 @@ namespace Microsoft.DotNet.Migration.Tests var globalDirectory = Path.Combine(projectDirectory, ".."); var projectJsonFile = Path.Combine(projectDirectory, "project.json"); - WriteGlobalJson(globalDirectory); - var projectJson = JObject.Parse(File.ReadAllText(projectJsonFile)); - projectJson.Remove("tools"); - File.WriteAllText(projectJsonFile, projectJson.ToString()); + WriteGlobalJson(globalDirectory); var outputComparisonData = GetComparisonData(projectDirectory); @@ -126,9 +123,27 @@ namespace Microsoft.DotNet.Migration.Tests outputsIdentical.Should().BeTrue(); } + public void ItAddsMicrosoftNetWebSdkToTheSdkAttributeOfAWebApp() + { + var testInstance = TestAssetsManager + .CreateTestInstance("ProjectJsonWebTemplate") + .WithLockFiles(); + + var projectDirectory = testInstance.Path; + + var globalDirectory = Path.Combine(projectDirectory, ".."); + var projectJsonFile = Path.Combine(projectDirectory, "project.json"); + + MigrateProject(new [] { projectDirectory }); + + var csProj = Path.Combine(projectDirectory, $"{new DirectoryInfo(projectDirectory).Name}.csproj"); + + File.ReadAllText(csProj).Should().Contain(@"Sdk=""Microsoft.NET.Sdk.Web"""); + } + [Theory] [InlineData("TestLibraryWithTwoFrameworks")] - public void It_migrates_projects_with_multiple_TFMs(string projectName) + public void ItMigratesProjectsWithMultipleTFMs(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, identifier: projectName).WithLockFiles().Path; @@ -150,7 +165,7 @@ namespace Microsoft.DotNet.Migration.Tests [InlineData("TestAppWithLibrary/TestLibrary")] [InlineData("TestLibraryWithAnalyzer")] [InlineData("PJTestLibraryWithConfiguration")] - public void It_migrates_a_library(string projectName) + public void ItMigratesALibrary(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, identifier: projectName).WithLockFiles().Path; @@ -174,7 +189,7 @@ namespace Microsoft.DotNet.Migration.Tests [InlineData("ProjectC", "ProjectC,ProjectD,ProjectE")] [InlineData("ProjectD", "ProjectD")] [InlineData("ProjectE", "ProjectE")] - public void It_migrates_root_project_and_references(string projectName, string expectedProjects) + public void ItMigratesRootProjectAndReferences(string projectName, string expectedProjects) { var projectDirectory = TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"{projectName}.RefsTest").Path; @@ -192,7 +207,7 @@ namespace Microsoft.DotNet.Migration.Tests [InlineData("ProjectC")] [InlineData("ProjectD")] [InlineData("ProjectE")] - public void It_migrates_root_project_and_skips_references(string projectName) + public void ItMigratesRootProjectAndSkipsReferences(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"{projectName}.SkipRefsTest").Path; @@ -205,7 +220,7 @@ namespace Microsoft.DotNet.Migration.Tests [Theory] [InlineData(true)] [InlineData(false)] - public void It_migrates_all_projects_in_given_directory(bool skipRefs) + public void ItMigratesAllProjectsInGivenDirectory(bool skipRefs) { var projectDirectory = TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"MigrateDirectory.SkipRefs.{skipRefs}").Path; @@ -224,7 +239,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_migrates_given_project_json() + public void ItMigratesGivenProjectJson() { var projectDirectory = TestAssetsManager.CreateTestInstance("TestAppDependencyGraph").Path; @@ -239,7 +254,7 @@ namespace Microsoft.DotNet.Migration.Tests [Fact] // regression test for https://github.com/dotnet/cli/issues/4269 - public void It_migrates_and_builds_P2P_references() + public void ItMigratesAndBuildsP2PReferences() { var assetsDir = TestAssetsManager.CreateTestInstance("TestAppDependencyGraph").WithLockFiles().Path; @@ -269,7 +284,7 @@ namespace Microsoft.DotNet.Migration.Tests [Theory] [InlineData("src", "ProjectH")] [InlineData("src with spaces", "ProjectJ")] - public void It_migrates_and_builds_projects_in_global_json(string path, string projectName) + public void ItMigratesAndBuildsProjectsInGlobalJson(string path, string projectName) { var assetsDir = TestAssetsManager.CreateTestInstance(Path.Combine("TestAppDependencyGraph", "ProjectsWithGlobalJson"), callingMethod: $"ProjectsWithGlobalJson.{projectName}") @@ -306,7 +321,7 @@ namespace Microsoft.DotNet.Migration.Tests [Theory] [InlineData(true)] [InlineData(false)] - public void Migration_outputs_error_when_no_projects_found(bool useGlobalJson) + public void MigrationOutputsErrorWhenNoProjectsFound(bool useGlobalJson) { var projectDirectory = TestAssetsManager.CreateTestDirectory("Migration_outputs_error_when_no_projects_found"); @@ -353,7 +368,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_migrates_and_publishes_projects_with_runtimes() + public void ItMigratesAndPublishesProjectsWithRuntimes() { var projectName = "PJTestAppSimple"; var projectDirectory = TestAssetsManager @@ -369,7 +384,7 @@ namespace Microsoft.DotNet.Migration.Tests [WindowsOnlyTheory] [InlineData("DesktopTestProjects", "AutoAddDesktopReferencesDuringMigrate", true)] [InlineData("TestProjects", "PJTestAppSimple", false)] - public void It_auto_add_desktop_references_during_migrate(string testGroup, string projectName, bool isDesktopApp) + public void ItAutoAddDesktopReferencesDuringMigrate(string testGroup, string projectName, bool isDesktopApp) { var runtime = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); var testAssetManager = GetTestGroupTestAssetsManager(testGroup); @@ -384,7 +399,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_builds_a_migrated_app_with_a_indirect_dependency() + public void ItBuildsAMigratedAppWithAnIndirectDependency() { const string projectName = "ProjectA"; var solutionDirectory = @@ -399,7 +414,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_migrates_project_with_output_name() + public void ItMigratesProjectWithOutputName() { string projectName = "AppWithOutputAssemblyName"; string expectedOutputName = "MyApp"; @@ -426,10 +441,10 @@ namespace Microsoft.DotNet.Migration.Tests [Theory] [InlineData("LibraryWithoutNetStandardLibRef")] [InlineData("LibraryWithNetStandardLibRef")] - public void It_migrates_and_builds_library(string projectName) + public void ItMigratesAndBuildsLibrary(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, - callingMethod: $"{nameof(It_migrates_and_builds_library)}-projectName").Path; + callingMethod: $"{nameof(ItMigratesAndBuildsLibrary)}-projectName").Path; MigrateProject(projectDirectory); Restore(projectDirectory, projectName); @@ -437,7 +452,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void It_fails_gracefully_when_migrating_app_with_missing_dependency() + public void ItFailsGracefullyWhenMigratingAppWithMissingDependency() { string projectName = "MigrateAppWithMissingDep"; var projectDirectory = Path.Combine(GetTestGroupTestAssetsManager("NonRestoredTestProjects").CreateTestInstance(projectName).Path, "MyApp");