Migration: excluded files need to be removed (#5485)

* WIP

* Implement Remove attribute

* Enable tests

* Fix test

* Try a shorter test name

* Try more shortened test names

* Shorten some more

* Merge issues

* Try shortinging names more

* Fix test errors related to test asset renaming
This commit is contained in:
Justin Goshi 2017-01-28 15:14:17 -10:00 committed by Livar
parent e38bc4950c
commit 5aded80a7b
55 changed files with 394 additions and 174 deletions

View file

@ -1,20 +0,0 @@
{
"version": "1.0.0-*",
"namedResource": [ "My.Alias", "Strings.resx" ],
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}

View file

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"namedResource": [ "My.Alias", "Strings.resx" ],
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}

View file

@ -43,7 +43,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
foreach (var item in msbuildProject.Items)
{
if (string.IsNullOrEmpty(item.Include) && string.IsNullOrEmpty(item.Update))
if (string.IsNullOrEmpty(item.Include) &&
string.IsNullOrEmpty(item.Remove) &&
string.IsNullOrEmpty(item.Update))
{
item.Parent.RemoveChild(item);
}

View file

@ -133,9 +133,17 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
condition: ic => ic != null,
emitBuiltInIncludes: false);
private RemoveContextTransform RemoveCompileFilesTransform =>
new RemoveContextTransform(
"Compile",
condition: ic => ic != null);
private IncludeContextTransform EmbedFilesTransform =>
new IncludeContextTransform("EmbeddedResource", transformMappings: false, condition: ic => ic != null);
private RemoveContextTransform RemoveEmbedFilesTransform =>
new RemoveContextTransform("EmbeddedResource", condition: ic => ic != null);
private IncludeContextTransform CopyToOutputFilesTransform =>
new IncludeContextTransform("Content", transformMappings: true)
.WithMetadata("CopyToOutputDirectory", "PreserveNewest");
@ -157,14 +165,22 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
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) =>
CompileFilesTransform.Transform(compilerOptions.CompileInclude);
private Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>> RemoveCompileFilesTransformExecute =>
(compilerOptions, projectDirectory, projectType) =>
RemoveCompileFilesTransform.Transform(compilerOptions.CompileInclude);
private Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>> EmbedFilesTransformExecute =>
(compilerOptions, projectDirectory, projectType) =>
EmbedFilesTransform.Transform(GetEmbedIncludeContext(compilerOptions));
private Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>> RemoveEmbedFilesTransformExecute =>
(compilerOptions, projectDirectory, projectType) =>
RemoveEmbedFilesTransform.Transform(GetEmbedIncludeContext(compilerOptions));
private Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>> CopyToOutputFilesTransformExecute =>
(compilerOptions, projectDirectory, projectType) =>
{
@ -183,6 +199,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
private readonly CommonCompilerOptions _configurationBuildOptions;
private List<AddPropertyTransform<CommonCompilerOptions>> _propertyTransforms;
private List<Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>>> _removeContextTransformExecutes;
private List<Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>>> _includeContextTransformExecutes;
private readonly ITransformApplicator _transformApplicator;
@ -229,6 +246,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
_propertyTransforms.AddRange(EmitEntryPointTransforms);
_propertyTransforms.AddRange(KeyFileTransforms);
_removeContextTransformExecutes =
new List<Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>>>()
{
RemoveCompileFilesTransformExecute,
RemoveEmbedFilesTransformExecute
};
_includeContextTransformExecutes =
new List<Func<CommonCompilerOptions, string, ProjectType, IEnumerable<ProjectItemElement>>>()
{
@ -311,6 +335,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
}
}
foreach (var removeContextTransformExecutes in _removeContextTransformExecutes)
{
var nonConfigurationOutput =
removeContextTransformExecutes(compilerOptions, projectDirectory, projectType);
var configurationOutput =
removeContextTransformExecutes(configurationCompilerOptions, projectDirectory, projectType);
if (configurationOutput != null)
{
transformApplicator.Execute(configurationOutput, itemGroup, mergeExisting: true);
}
}
foreach (var includeContextTransformExecute in _includeContextTransformExecutes)
{
var nonConfigurationOutput =
@ -318,7 +355,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
var configurationOutput =
includeContextTransformExecute(configurationCompilerOptions, projectDirectory, projectType);
if (configurationOutput != null)
{
transformApplicator.Execute(configurationOutput, itemGroup, mergeExisting: true);
@ -326,25 +362,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
}
}
private void RemoveCommonIncludes(IEnumerable<ProjectItemElement> itemsToRemoveFrom,
IEnumerable<ProjectItemElement> otherItems)
{
foreach (var item1 in itemsToRemoveFrom)
{
if (item1 == null)
{
continue;
}
foreach (
var item2 in
otherItems.Where(
i => i != null && string.Equals(i.ItemType, item1.ItemType, StringComparison.Ordinal)))
{
item1.Include = string.Join(";", item1.Includes().Except(item2.Includes()));
}
}
}
private bool PropertiesAreEqual(ProjectPropertyElement nonConfigurationOutput, ProjectPropertyElement configurationOutput)
{
if (configurationOutput != null && nonConfigurationOutput != null)
@ -369,6 +386,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
transformApplicator.Execute(transform.Transform(compilerOptions), propertyGroup, mergeExisting: true);
}
foreach (var removeContextTransformExecutes in _removeContextTransformExecutes)
{
var transform = removeContextTransformExecutes(compilerOptions, projectDirectory, projectType);
if (transform != null)
{
transformApplicator.Execute(
transform,
itemGroup,
mergeExisting: true);
}
}
foreach (var includeContextTransformExecute in _includeContextTransformExecutes)
{
var transform = includeContextTransformExecute(compilerOptions, projectDirectory, projectType);

View file

@ -1,7 +1,11 @@
// 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 Microsoft.DotNet.Tools.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
{
@ -25,5 +29,74 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
}
public abstract U ConditionallyTransform(T source);
protected string FormatGlobPatternsForMsbuild(IEnumerable<string> patterns, string projectDirectory)
{
if (patterns == null)
{
return string.Empty;
}
List<string> mutatedPatterns = new List<string>(patterns.Count());
foreach (var pattern in patterns)
{
// Do not use forward slashes
// https://github.com/Microsoft/msbuild/issues/724
var mutatedPattern = pattern.Replace('/', '\\');
// MSBuild cannot copy directories
mutatedPattern = ReplaceDirectoriesWithGlobs(mutatedPattern, projectDirectory);
mutatedPatterns.Add(mutatedPattern);
}
return string.Join(";", mutatedPatterns);
}
private string ReplaceDirectoriesWithGlobs(string pattern, string projectDirectory)
{
if (PatternIsDirectory(pattern, projectDirectory))
{
return $"{pattern.TrimEnd(new char[] { '\\' })}\\**\\*";
}
else
{
return pattern;
}
}
private bool PatternIsDirectory(string pattern, string projectDirectory)
{
// TODO: what about /some/path/**/somedir?
// Should this even be migrated?
var path = pattern;
if (!Path.IsPathRooted(path))
{
path = Path.Combine(projectDirectory, path);
}
return Directory.Exists(path);
}
protected string ConvertTargetPathToMsbuildMetadata(string targetPath)
{
var targetIsFile = MappingsTargetPathIsFile(targetPath);
if (targetIsFile)
{
return targetPath;
}
return $"{targetPath}%(FileName)%(Extension)";
}
private bool MappingsTargetPathIsFile(string targetPath)
{
var normalizedTargetPath = PathUtility.GetPathWithDirectorySeparator(targetPath);
return normalizedTargetPath[normalizedTargetPath.Length - 1] != Path.DirectorySeparatorChar;
}
}
}

View file

@ -172,80 +172,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
return transformSet.Select(t => t.Item1.Transform(t.Item2));
}
protected string FormatGlobPatternsForMsbuild(IEnumerable<string> patterns, string projectDirectory)
{
if (patterns == null)
{
return string.Empty;
}
List<string> mutatedPatterns = new List<string>(patterns.Count());
foreach (var pattern in patterns)
{
// Do not use forward slashes
// https://github.com/Microsoft/msbuild/issues/724
var mutatedPattern = pattern.Replace('/', '\\');
// MSBuild cannot copy directories
mutatedPattern = ReplaceDirectoriesWithGlobs(mutatedPattern, projectDirectory);
mutatedPatterns.Add(mutatedPattern);
}
return string.Join(";", mutatedPatterns);
}
private string ReplaceDirectoriesWithGlobs(string pattern, string projectDirectory)
{
if (PatternIsDirectory(pattern, projectDirectory))
{
return $"{pattern.TrimEnd(new char[] { '\\' })}\\**\\*";
}
else
{
return pattern;
}
}
private AddItemTransform<IncludeContext> AddMappingToTransform(
AddItemTransform<IncludeContext> addItemTransform,
string targetPath)
{
return _mappingsToTransfrom(addItemTransform, targetPath);
}
private bool PatternIsDirectory(string pattern, string projectDirectory)
{
// TODO: what about /some/path/**/somedir?
// Should this even be migrated?
var path = pattern;
if (!Path.IsPathRooted(path))
{
path = Path.Combine(projectDirectory, path);
}
return Directory.Exists(path);
}
private string ConvertTargetPathToMsbuildMetadata(string targetPath)
{
var targetIsFile = MappingsTargetPathIsFile(targetPath);
if (targetIsFile)
{
return targetPath;
}
return $"{targetPath}%(FileName)%(Extension)";
}
private bool MappingsTargetPathIsFile(string targetPath)
{
var normalizedTargetPath = PathUtility.GetPathWithDirectorySeparator(targetPath);
return normalizedTargetPath[normalizedTargetPath.Length - 1] != Path.DirectorySeparatorChar;
}
}
}

View file

@ -0,0 +1,110 @@
// 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 Microsoft.DotNet.Internal.ProjectModel.Files;
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectJsonMigration.Models;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
{
internal class RemoveContextTransform : ConditionalTransform<IncludeContext, IEnumerable<ProjectItemElement>>
{
protected virtual Func<string, RemoveItemTransform<IncludeContext>> RemoveTransformGetter =>
(itemName) => new RemoveItemTransform<IncludeContext>(
itemName,
includeContext =>
{
var fullRemoveSet = includeContext.ExcludePatterns.OrEmptyIfNull()
.Union(includeContext.ExcludeFiles.OrEmptyIfNull());
return FormatGlobPatternsForMsbuild(fullRemoveSet, includeContext.SourceBasePath);
},
includeContext =>
{
return includeContext != null &&
(
(includeContext.ExcludePatterns != null && includeContext.ExcludePatterns.Count > 0)
||
(includeContext.ExcludeFiles != null && includeContext.ExcludeFiles.Count > 0)
);
});
private Func<string, string, RemoveItemTransform<IncludeContext>> MappingsRemoveTransformGetter =>
(itemName, targetPath) => AddMappingToTransform(RemoveTransformGetter(itemName), targetPath);
private Func<RemoveItemTransform<IncludeContext>, string, RemoveItemTransform<IncludeContext>> _mappingsToTransfrom;
private readonly string _itemName;
private readonly List<ItemMetadataValue<IncludeContext>> _metadata = new List<ItemMetadataValue<IncludeContext>>();
public RemoveContextTransform(
string itemName,
Func<IncludeContext, bool> condition = null
) : base(condition)
{
_itemName = itemName;
_mappingsToTransfrom = (removeItemTransform, targetPath) =>
{
var msbuildLinkMetadataValue = ConvertTargetPathToMsbuildMetadata(targetPath);
return removeItemTransform.WithMetadata("Link", msbuildLinkMetadataValue);
};
}
public override IEnumerable<ProjectItemElement> ConditionallyTransform(IncludeContext source)
{
var transformSet = CreateTransformSet(source);
return transformSet.Select(t => t.Item1.Transform(t.Item2));
}
private IEnumerable<Tuple<RemoveItemTransform<IncludeContext>, IncludeContext>> CreateTransformSet(IncludeContext source)
{
var transformSet = new List<Tuple<RemoveItemTransform<IncludeContext>, IncludeContext>>
{
Tuple.Create(RemoveTransformGetter(_itemName), source)
};
if (source == null)
{
return transformSet;
}
// Mappings must be executed before the transform set to prevent a the
// non-mapped items that will merge with mapped items from being encompassed
foreach (var mappingEntry in source.Mappings.OrEmptyIfNull())
{
var targetPath = mappingEntry.Key;
var includeContext = mappingEntry.Value;
transformSet.Insert(0,
Tuple.Create(
MappingsRemoveTransformGetter(_itemName, targetPath),
includeContext));
}
foreach (var metadataElement in _metadata)
{
foreach (var transform in transformSet)
{
transform.Item1.WithMetadata(metadataElement);
}
}
return transformSet;
}
private RemoveItemTransform<IncludeContext> AddMappingToTransform(
RemoveItemTransform<IncludeContext> removeItemTransform,
string targetPath)
{
return _mappingsToTransfrom(removeItemTransform, targetPath);
}
}
}

View file

@ -0,0 +1,69 @@
// 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;
using System.Collections.Generic;
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration.Models;
namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
{
internal class RemoveItemTransform<T> : ConditionalTransform<T, ProjectItemElement>
{
private readonly ProjectRootElement _itemObjectGenerator = ProjectRootElement.Create();
private readonly string _itemName;
private readonly Func<T, string> _removeValueFunc;
private readonly List<ItemMetadataValue<T>> _metadata = new List<ItemMetadataValue<T>>();
public RemoveItemTransform(
string itemName,
Func<T, string> removeValueFunc,
Func<T, bool> condition)
: base(condition)
{
_itemName = itemName;
_removeValueFunc = removeValueFunc;
}
public RemoveItemTransform<T> WithMetadata(ItemMetadataValue<T> metadata)
{
_metadata.Add(metadata);
return this;
}
public RemoveItemTransform<T> WithMetadata(
string metadataName,
string metadataValue,
bool expressedAsAttribute = false)
{
_metadata.Add(new ItemMetadataValue<T>(
metadataName,
metadataValue,
expressedAsAttribute: expressedAsAttribute));
return this;
}
public override ProjectItemElement ConditionallyTransform(T source)
{
string removeValue = _removeValueFunc(source);
var item = _itemObjectGenerator.AddItem(_itemName, "PlaceHolderSinceNullOrEmptyCannotBePassedToConstructor");
item.Include = null;
item.Remove = removeValue;
foreach (var metadata in _metadata)
{
if (metadata.ShouldWriteMetadata(source))
{
var metametadata = item.AddMetadata(metadata.MetadataName, metadata.GetMetadataValue(source));
metametadata.Condition = metadata.Condition;
metametadata.ExpressedAsAttribute = metadata.ExpressedAsAttribute;
}
}
return item;
}
}
}

View file

@ -43,7 +43,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
public void ItHasWarningWhenMigratingADeprecatedProjectJson()
{
var testProjectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile")
.CreateInstance()
.WithSourceFiles()
.Root
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
public void ItHasErrorWhenMigratingADeprecatedNamedResourceOptionProjectJson()
{
var testProjectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedNamedResourceOption")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedNamedResource")
.CreateInstance()
.WithSourceFiles()
.Root

View file

@ -420,12 +420,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
}
[Theory]
[InlineData("compile", "Compile", "")]
[InlineData("embed", "EmbeddedResource", ";rootfile.cs")]
[InlineData("copyToOutput", "Content", ";rootfile.cs")]
[InlineData("compile", "Compile", 3, "")]
[InlineData("embed", "EmbeddedResource", 3, ";rootfile.cs")]
[InlineData("copyToOutput", "Content", 2, ";rootfile.cs")]
private void MigratingGroupIncludeExcludePopulatesAppropriateProjectItemElement(
string group,
string itemName,
int expectedNumberOfCompileItems,
string expectedRootFiles)
{
var testDirectory = Temp.CreateDirectory().Path;
@ -446,7 +447,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var mockProj = RunBuildOptionsRuleOnPj(pj,
testDirectory: testDirectory);
mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(2);
mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal))
.Should().Be(expectedNumberOfCompileItems);
var defaultIncludePatterns = GetDefaultIncludePatterns(group);
var defaultExcludePatterns = GetDefaultExcludePatterns(group);
@ -455,7 +457,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
VerifyContentMetadata(item);
if (item.Include.Contains(@"src\file1.cs"))
if (string.IsNullOrEmpty(item.Include))
{
item.Remove.Should()
.Be(@"src\**\*;rootfile.cs;src\file2.cs");
}
else if (item.Include.Contains(@"src\file1.cs"))
{
item.Include.Should().Be(@"src\file1.cs;src\file2.cs");
item.Exclude.Should().Be(@"src\file2.cs");

View file

@ -15,10 +15,10 @@ namespace Microsoft.DotNet.Migration.Tests
public class GivenThatIWantToMigrateDeprecatedProjects : TestBase
{
[Fact]
public void WhenMigratingAProjectWithDeprecatedPackOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedPackOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedPackOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedPack")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -52,10 +52,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedPackOptionsItSucceeds()
public void MigrateDeprecatedPack()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedPackOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedPack")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -82,17 +82,17 @@ namespace Microsoft.DotNet.Migration.Tests
var outputDir = projectDirectory.GetDirectory("bin", "Debug");
outputDir.Should().Exist()
.And.HaveFile("PJAppWithDeprecatedPackOptions.1.0.0.nupkg");
.And.HaveFile("PJDeprecatedPack.1.0.0.nupkg");
var outputPackage = outputDir.GetFile("PJAppWithDeprecatedPackOptions.1.0.0.nupkg");
var outputPackage = outputDir.GetFile("PJDeprecatedPack.1.0.0.nupkg");
var zip = ZipFile.Open(outputPackage.FullName, ZipArchiveMode.Read);
zip.Entries.Should().Contain(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec")
zip.Entries.Should().Contain(e => e.FullName == "PJDeprecatedPack.nuspec")
.And.Contain(e => e.FullName == "content/Content1.txt")
.And.Contain(e => e.FullName == "content/Content2.txt");
var manifestReader = new StreamReader(
zip.Entries.First(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec").Open());
zip.Entries.First(e => e.FullName == "PJDeprecatedPack.nuspec").Open());
// NOTE: Commented out those that are not migrated.
// https://microsoft.sharepoint.com/teams/netfx/corefx/_layouts/15/WopiFrame.aspx?sourcedoc=%7B0cfbc196-0645-4781-84c6-5dffabd76bee%7D&action=edit&wd=target%28Planning%2FMSBuild%20CLI%20integration%2Eone%7C41D470DD-CF44-4595-8E05-0CE238864B55%2FProject%2Ejson%20Migration%7CA553D979-EBC6-484B-A12E-036E0730864A%2F%29
@ -120,10 +120,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompilationOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedCompilationOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompilationOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompilation")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -141,10 +141,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompilationOptionsItSucceeds()
public void MigratingDeprecatedCompilation()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompilationOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompilation")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -166,10 +166,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedContentOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedContentOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedContentOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedContent")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -191,10 +191,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedContentOptionsItSucceeds()
public void MigratingDeprecatedContent()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedContentOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedContent")
.CreateInstance()
.WithSourceFiles()
.Root
@ -248,10 +248,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompileOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedCompileOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -269,10 +269,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompileOptionsItSucceeds()
public void MigratingDeprecatedCompile()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile")
.CreateInstance()
.WithSourceFiles()
.Root
@ -295,10 +295,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompileBuiltInOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedCompileBuiltInOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileBuiltInOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileBuiltIn")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -314,10 +314,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompileBuiltInOptionsItSucceeds()
public void MigratingDeprecatedCompileBuiltIn()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileBuiltInOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileBuiltIn")
.CreateInstance()
.WithSourceFiles()
.Root
@ -341,10 +341,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompileExcludeOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedCompileExcludeOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileExcludeOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileExclude")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -360,10 +360,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedCompileExcludeOptionsItSucceeds()
public void MigratingDeprecatedCompileExclude()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileExcludeOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileExclude")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -378,18 +378,17 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute("restore")
.Should().Pass();
// Issue: https://github.com/dotnet/cli/issues/5461
//new DotnetCommand()
// .WithWorkingDirectory(projectDirectory)
// .Execute("build -c Debug")
// .Should().Pass();
new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.Execute("build -c Debug")
.Should().Pass();
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedResourceOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedResourceOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResource")
.CreateInstance()
.WithSourceFiles()
.Root
@ -408,10 +407,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedResourceOptionsItSucceeds()
public void MigratingDeprecatedResource()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResource")
.CreateInstance()
.WithSourceFiles()
.Root
@ -440,10 +439,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedResourceBuiltInOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedResourceBuiltInOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceBuiltInOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceBuiltIn")
.CreateInstance()
.WithSourceFiles()
.Root
@ -460,10 +459,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingDeprecatedBuiltInResItSucceeds()
public void MigratingDeprecatedResourceBuiltIn()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceBuiltInOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceBuiltIn")
.CreateInstance()
.WithSourceFiles()
.Root
@ -493,10 +492,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedResourceExcludeOptionsWarningsArePrinted()
public void WhenMigratingDeprecatedResourceExcludeOptionsWarningsArePrinted()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceExcludeOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceExclude")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -512,10 +511,10 @@ namespace Microsoft.DotNet.Migration.Tests
}
[Fact]
public void WhenMigratingAProjectWithDeprecatedResourceExcludeOptionsItSucceeds()
public void MigratingDeprecatedResourceExclude()
{
var projectDirectory = TestAssets
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceExcludeOptions")
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceExclude")
.CreateInstance()
.WithSourceFiles()
.Root;
@ -530,17 +529,16 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute("restore")
.Should().Pass();
// Issue: https://github.com/dotnet/cli/issues/5461
//new DotnetCommand()
// .WithWorkingDirectory(projectDirectory)
// .Execute("build -c Debug")
// .Should().Pass();
new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.Execute("build -c Debug")
.Should().Pass();
//var cmd = new DotnetCommand()
// .WithWorkingDirectory(projectDirectory)
// .ExecuteWithCapturedOutput("run -c Debug");
//cmd.Should().Pass();
//cmd.StdOut.Should().Contain("0 Resources Found:");
var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("run -c Debug");
cmd.Should().Pass();
cmd.StdOut.Should().Contain("0 Resources Found:");
}
}
}