Merge pull request #5090 from livarcocc/migrate_app_config
Emitting a None item for App.config if one exists side-by-side to the project.json
This commit is contained in:
commit
10a1695d6c
2 changed files with 24 additions and 0 deletions
|
@ -130,6 +130,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
project => "true",
|
project => "true",
|
||||||
project => project.GetProjectType() == ProjectType.Test);
|
project => project.GetProjectType() == ProjectType.Test);
|
||||||
|
|
||||||
|
private AddItemTransform<ProjectContext> AppConfigTransform =>
|
||||||
|
new AddItemTransform<ProjectContext>(
|
||||||
|
"None",
|
||||||
|
projectContext => "App.config",
|
||||||
|
projectContext => string.Empty,
|
||||||
|
projectContext => File.Exists(Path.Combine(projectContext.ProjectDirectory, "App.config")));
|
||||||
|
|
||||||
private Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>>CompileFilesTransformExecute =>
|
private Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>>CompileFilesTransformExecute =>
|
||||||
(compilerOptions, projectDirectory, projectType) =>
|
(compilerOptions, projectDirectory, projectType) =>
|
||||||
CompileFilesTransform.Transform(GetCompileIncludeContext(compilerOptions, projectDirectory));
|
CompileFilesTransform.Transform(GetCompileIncludeContext(compilerOptions, projectDirectory));
|
||||||
|
@ -258,6 +265,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
var transformOutput = GenerateRuntimeConfigurationFilesTransform.Transform(
|
var transformOutput = GenerateRuntimeConfigurationFilesTransform.Transform(
|
||||||
migrationRuleInputs.DefaultProjectContext.ProjectFile);
|
migrationRuleInputs.DefaultProjectContext.ProjectFile);
|
||||||
_transformApplicator.Execute(transformOutput, propertyGroup, mergeExisting: true);
|
_transformApplicator.Execute(transformOutput, propertyGroup, mergeExisting: true);
|
||||||
|
|
||||||
|
var appConfigTransformOutput = AppConfigTransform.Transform(migrationRuleInputs.DefaultProjectContext);
|
||||||
|
_transformApplicator.Execute(appConfigTransformOutput, itemGroup, mergeExisting: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PerformConfigurationPropertyAndItemMappings(
|
private void PerformConfigurationPropertyAndItemMappings(
|
||||||
|
|
|
@ -553,6 +553,20 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
mockProj.Properties.Count(p => p.Name == "GenerateRuntimeConfigurationFiles").Should().Be(0);
|
mockProj.Properties.Count(p => p.Name == "GenerateRuntimeConfigurationFiles").Should().Be(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void MigratingAnAppWithAppConfigAddsItAsNoneToTheCsProj()
|
||||||
|
{
|
||||||
|
var tempDirectory = Temp.CreateDirectory().Path;
|
||||||
|
File.Create(Path.Combine(tempDirectory, "App.config")).Dispose();
|
||||||
|
var mockProj = RunBuildOptionsRuleOnPj(@"
|
||||||
|
{
|
||||||
|
}",
|
||||||
|
tempDirectory);
|
||||||
|
|
||||||
|
mockProj.Items.Count(i => i.ItemType == "None").Should().Be(1);
|
||||||
|
mockProj.Items.First(i => i.ItemType == "None").Include.Should().Be("App.config");
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> GetDefaultExcludePatterns(string group)
|
private static IEnumerable<string> GetDefaultExcludePatterns(string group)
|
||||||
{
|
{
|
||||||
var defaultExcludePatterns = new List<string>(group == "copyToOutput" ?
|
var defaultExcludePatterns = new List<string>(group == "copyToOutput" ?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue