This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Sdks attribute in
dotnet new
templates (#4916)
* Move dotnet-new templates to Sdk attribute * Update to MSBuild 15.1.0-preview-000454-01 To pick up a fix for dotnet/msbuild#1431. * Fix template newlines * Fix casing on Microsoft.Net.Sdk * Move migration test csproj's to Sdk attribute * Disable parallel sdk restore Each SDK restore operation will try to manipulate the same assets.json file since the dependency name&version are injected into a common csproj file. This can cause runtime failures when two NuGets try to restore the project at once. * Make casing of SDK 'NET' and not 'Net' * Remove redundatn imports * Fix test string * Additional race * Replacing the SDK with the Web.Sdk when it is a Web project. * Fixing the test by writting the csproj before running the migration rule.
- Loading branch information
Piotr Puszkiewicz
authored
Dec 5, 2016
1 parent
dc3d88c
commit d6cab4a
Showing
30 changed files
with
179 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateWebSdkRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.IO; | ||
using Microsoft.Build.Construction; | ||
|
||
namespace Microsoft.DotNet.ProjectJsonMigration.Rules | ||
{ | ||
//HACK to workaround https://github.com/Microsoft/msbuild/issues/1429 | ||
internal class MigrateWebSdkRule : IMigrationRule | ||
{ | ||
private static string GetContainingFolderName(string projectDirectory) | ||
{ | ||
projectDirectory = projectDirectory.TrimEnd(new char[] { '/', '\\' }); | ||
return Path.GetFileName(projectDirectory); | ||
} | ||
|
||
public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) | ||
{ | ||
var project = migrationRuleInputs.DefaultProjectContext.ProjectFile; | ||
var type = project.GetProjectType(); | ||
|
||
if(type == ProjectType.Web) | ||
{ | ||
ReplaceSdkWithWebSdk(migrationSettings); | ||
} | ||
} | ||
|
||
private void ReplaceSdkWithWebSdk(MigrationSettings migrationSettings) | ||
{ | ||
string csprojName = $"{GetContainingFolderName(migrationSettings.ProjectDirectory)}.csproj"; | ||
var outputProject = Path.Combine(migrationSettings.OutputDirectory, csprojName); | ||
|
||
var csprojContent = File.ReadAllText(outputProject); | ||
csprojContent = csprojContent.Replace("Sdk=\"Microsoft.NET.Sdk\"", "Sdk=\"Microsoft.NET.Sdk.Web\""); | ||
|
||
File.WriteAllText(outputProject, csprojContent); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.