Ignore explicit glob **/*.cs
This commit is contained in:
parent
56d8071361
commit
000734d1ef
5 changed files with 73 additions and 2 deletions
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true,
|
||||
"compile": {
|
||||
"include": [
|
||||
"**/*.cs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,10 +110,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
compilerOptions => projectFolderName,
|
||||
compilerOptions => compilerOptions.OutputName != null);
|
||||
|
||||
private string[] _compilePatternsBlackList = new string[] {
|
||||
"**/*.cs"
|
||||
};
|
||||
|
||||
private IncludeContextTransform CompileFilesTransform =>
|
||||
new IncludeContextTransform(
|
||||
"Compile",
|
||||
transformMappings: false,
|
||||
patternsBlackList: _compilePatternsBlackList,
|
||||
condition: ic => ic != null,
|
||||
emitBuiltInIncludes: false);
|
||||
|
||||
|
|
|
@ -25,6 +25,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
|||
&& includeContext.IncludeFiles != null
|
||||
&& includeContext.IncludeFiles.Count > 0);
|
||||
|
||||
private bool IsPatternBlackListed(string pattern)
|
||||
{
|
||||
if (_patternsBlackList == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _patternsBlackList.Contains(pattern.Replace('\\', '/'));
|
||||
}
|
||||
|
||||
protected virtual Func<string, AddItemTransform<IncludeContext>> IncludeExcludeTransformGetter =>
|
||||
(itemName) => new AddItemTransform<IncludeContext>(
|
||||
itemName,
|
||||
|
@ -36,6 +46,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
|||
fullIncludeSet = fullIncludeSet.Union(includeContext.BuiltInsInclude.OrEmptyIfNull());
|
||||
}
|
||||
|
||||
if (_patternsBlackList != null)
|
||||
{
|
||||
fullIncludeSet = fullIncludeSet.Where((pattern) => !IsPatternBlackListed(pattern));
|
||||
}
|
||||
|
||||
return FormatGlobPatternsForMsbuild(fullIncludeSet, includeContext.SourceBasePath);
|
||||
},
|
||||
includeContext =>
|
||||
|
@ -50,7 +65,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
|||
{
|
||||
return includeContext != null &&
|
||||
(
|
||||
(includeContext.IncludePatterns != null && includeContext.IncludePatterns.Count > 0)
|
||||
(includeContext.IncludePatterns != null && includeContext.IncludePatterns.Where((pattern) => !IsPatternBlackListed(pattern)).Count() > 0)
|
||||
||
|
||||
(_emitBuiltInIncludes &&
|
||||
includeContext.BuiltInsInclude != null &&
|
||||
|
@ -68,6 +83,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
|||
|
||||
private readonly string _itemName;
|
||||
private bool _transformMappings;
|
||||
private string[] _patternsBlackList;
|
||||
private bool _emitBuiltInIncludes;
|
||||
private readonly List<ItemMetadataValue<IncludeContext>> _metadata = new List<ItemMetadataValue<IncludeContext>>();
|
||||
|
||||
|
@ -75,11 +91,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
|||
string itemName,
|
||||
bool transformMappings = true,
|
||||
Func<IncludeContext, bool> condition = null,
|
||||
bool emitBuiltInIncludes = true) : base(condition)
|
||||
bool emitBuiltInIncludes = true,
|
||||
string[] patternsBlackList = null) : base(condition)
|
||||
{
|
||||
_itemName = itemName;
|
||||
_transformMappings = transformMappings;
|
||||
_emitBuiltInIncludes = emitBuiltInIncludes;
|
||||
_patternsBlackList = patternsBlackList;
|
||||
|
||||
_mappingsToTransfrom = (addItemTransform, targetPath) =>
|
||||
{
|
||||
|
|
|
@ -640,6 +640,21 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
Restore(projectDirectory, projectName);
|
||||
BuildMSBuild(projectDirectory, projectName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItMigratesAndBuildsAppWithExplicitIncludeGlob()
|
||||
{
|
||||
const string projectName = "TestAppWithExplicitIncludeGlob";
|
||||
var projectDirectory = TestAssets.Get(projectName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.FullName;
|
||||
|
||||
MigrateProject(projectDirectory);
|
||||
Restore(projectDirectory, projectName);
|
||||
BuildMSBuild(projectDirectory, projectName);
|
||||
}
|
||||
|
||||
private void VerifyAutoInjectedDesktopReferences(DirectoryInfo projectDirectory, string projectName, bool shouldBePresent)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue