Adding GenerateRuntimeConfigurationFiles when migrating a test project.
This commit is contained in:
parent
86272a8812
commit
9d96bf8c20
2 changed files with 32 additions and 0 deletions
|
@ -113,6 +113,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
new IncludeContextTransform("Content", transformMappings: true)
|
||||
.WithMetadata("CopyToOutputDirectory", "PreserveNewest");
|
||||
|
||||
private AddPropertyTransform<Project> GenerateRuntimeConfigurationFilesTransform =>
|
||||
new AddPropertyTransform<Project>(
|
||||
"GenerateRuntimeConfigurationFiles",
|
||||
project => "true",
|
||||
project => project.GetProjectType() == ProjectType.Test);
|
||||
|
||||
private Func<CommonCompilerOptions, string, IEnumerable<ProjectItemElement>> CompileFilesTransformExecute =>
|
||||
(compilerOptions, projectDirectory) =>
|
||||
CompileFilesTransform.Transform(GetCompileIncludeContext(compilerOptions, projectDirectory));
|
||||
|
@ -219,6 +225,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
_transformApplicator,
|
||||
migrationSettings.ProjectDirectory);
|
||||
}
|
||||
|
||||
var transformOutput = GenerateRuntimeConfigurationFilesTransform.Transform(
|
||||
migrationRuleInputs.DefaultProjectContext.ProjectFile);
|
||||
_transformApplicator.Execute(transformOutput, propertyGroup, mergeExisting: true);
|
||||
}
|
||||
|
||||
private void PerformConfigurationPropertyAndItemMappings(
|
||||
|
|
|
@ -480,6 +480,28 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingTestProjectAddsGenerateRuntimeConfigurationFiles()
|
||||
{
|
||||
var mockProj = RunBuildOptionsRuleOnPj(@"
|
||||
{
|
||||
""testRunner"": ""xunit""
|
||||
}");
|
||||
|
||||
mockProj.Properties.Count(p => p.Name == "GenerateRuntimeConfigurationFiles").Should().Be(1);
|
||||
mockProj.Properties.First(p => p.Name == "GenerateRuntimeConfigurationFiles").Value.Should().Be("true");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingANonTestProjectDoesNotAddGenerateRuntimeConfigurationFiles()
|
||||
{
|
||||
var mockProj = RunBuildOptionsRuleOnPj(@"
|
||||
{
|
||||
}");
|
||||
|
||||
mockProj.Properties.Count(p => p.Name == "GenerateRuntimeConfigurationFiles").Should().Be(0);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetDefaultExcludePatterns(string group)
|
||||
{
|
||||
return group == "copyToOutput" ? ProjectFilesCollection.DefaultPublishExcludePatterns
|
||||
|
|
Loading…
Add table
Reference in a new issue