preserve whitespace
This commit is contained in:
parent
f34a870bf7
commit
c9f9421b93
3 changed files with 16 additions and 5 deletions
|
@ -7,6 +7,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.Build.Evaluation;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectJsonMigration;
|
||||
using Microsoft.DotNet.Internal.ProjectModel;
|
||||
|
@ -49,7 +50,9 @@ namespace Microsoft.DotNet.Tools.Migrate
|
|||
var projectsToMigrate = GetProjectsToMigrate(_projectArg);
|
||||
|
||||
var msBuildTemplate = _templateFile != null ?
|
||||
ProjectRootElement.TryOpen(_templateFile) : _temporaryDotnetNewProject.MSBuildProject;
|
||||
ProjectRootElement.Open(_templateFile,
|
||||
ProjectCollection.GlobalProjectCollection,
|
||||
preserveFormatting: true) : _temporaryDotnetNewProject.MSBuildProject;
|
||||
|
||||
var sdkVersion = _sdkVersion ?? _temporaryDotnetNewProject.MSBuildProject.GetSdkVersion();
|
||||
|
||||
|
@ -188,7 +191,7 @@ namespace Microsoft.DotNet.Tools.Migrate
|
|||
{
|
||||
IEnumerable<string> projects = null;
|
||||
|
||||
if (projectArg.EndsWith(Project.FileName, StringComparison.OrdinalIgnoreCase))
|
||||
if (projectArg.EndsWith(ProjectModel.Project.FileName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
projects = Enumerable.Repeat(projectArg, 1);
|
||||
}
|
||||
|
@ -202,7 +205,7 @@ namespace Microsoft.DotNet.Tools.Migrate
|
|||
}
|
||||
else if (Directory.Exists(projectArg))
|
||||
{
|
||||
projects = Directory.EnumerateFiles(projectArg, Project.FileName, SearchOption.AllDirectories);
|
||||
projects = Directory.EnumerateFiles(projectArg, ProjectModel.Project.FileName, SearchOption.AllDirectories);
|
||||
if (!projects.Any())
|
||||
{
|
||||
throw new Exception($"No project.json file found in '{projectArg}'");
|
||||
|
|
|
@ -4,6 +4,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.ProjectJsonMigration;
|
||||
using Microsoft.Build.Evaluation;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Migrate
|
||||
{
|
||||
|
@ -52,7 +53,9 @@ namespace Microsoft.DotNet.Tools.Migrate
|
|||
var templateProjPath = Path.Combine(temporaryDotnetNewMSBuildDirectory,
|
||||
c_temporaryDotnetNewMSBuildProjectName + ".csproj");
|
||||
|
||||
return ProjectRootElement.Open(templateProjPath);
|
||||
return ProjectRootElement.Open(templateProjPath,
|
||||
ProjectCollection.GlobalProjectCollection,
|
||||
preserveFormatting: true);
|
||||
}
|
||||
|
||||
private void RunCommand(string commandToExecute, IEnumerable<string> args, string workingDirectory)
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
[InlineData("TestAppWithRuntimeOptions")]
|
||||
[InlineData("TestAppWithContents")]
|
||||
[InlineData("AppWithAssemblyInfo")]
|
||||
public void It_migrates_apps(string projectName)
|
||||
public void It_migrates_apps_and_puts_newline_at_end_of_file(string projectName)
|
||||
{
|
||||
var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, identifier: projectName)
|
||||
.WithLockFiles()
|
||||
|
@ -41,6 +41,11 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
outputsIdentical.Should().BeTrue();
|
||||
|
||||
VerifyAllMSBuildOutputsRunnable(projectDirectory);
|
||||
|
||||
var outputCsProj = Path.Combine(projectDirectory, projectName + ".csproj");
|
||||
var csproj = File.ReadAllText(outputCsProj);
|
||||
Console.WriteLine(csproj);
|
||||
csproj.EndsWith(Environment.NewLine).Should().Be(true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue