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 => projectFolderName,
|
||||||
compilerOptions => compilerOptions.OutputName != null);
|
compilerOptions => compilerOptions.OutputName != null);
|
||||||
|
|
||||||
|
private string[] _compilePatternsBlackList = new string[] {
|
||||||
|
"**/*.cs"
|
||||||
|
};
|
||||||
|
|
||||||
private IncludeContextTransform CompileFilesTransform =>
|
private IncludeContextTransform CompileFilesTransform =>
|
||||||
new IncludeContextTransform(
|
new IncludeContextTransform(
|
||||||
"Compile",
|
"Compile",
|
||||||
transformMappings: false,
|
transformMappings: false,
|
||||||
|
patternsBlackList: _compilePatternsBlackList,
|
||||||
condition: ic => ic != null,
|
condition: ic => ic != null,
|
||||||
emitBuiltInIncludes: false);
|
emitBuiltInIncludes: false);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
||||||
&& includeContext.IncludeFiles != null
|
&& includeContext.IncludeFiles != null
|
||||||
&& includeContext.IncludeFiles.Count > 0);
|
&& 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 =>
|
protected virtual Func<string, AddItemTransform<IncludeContext>> IncludeExcludeTransformGetter =>
|
||||||
(itemName) => new AddItemTransform<IncludeContext>(
|
(itemName) => new AddItemTransform<IncludeContext>(
|
||||||
itemName,
|
itemName,
|
||||||
|
@ -36,6 +46,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
||||||
fullIncludeSet = fullIncludeSet.Union(includeContext.BuiltInsInclude.OrEmptyIfNull());
|
fullIncludeSet = fullIncludeSet.Union(includeContext.BuiltInsInclude.OrEmptyIfNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_patternsBlackList != null)
|
||||||
|
{
|
||||||
|
fullIncludeSet = fullIncludeSet.Where((pattern) => !IsPatternBlackListed(pattern));
|
||||||
|
}
|
||||||
|
|
||||||
return FormatGlobPatternsForMsbuild(fullIncludeSet, includeContext.SourceBasePath);
|
return FormatGlobPatternsForMsbuild(fullIncludeSet, includeContext.SourceBasePath);
|
||||||
},
|
},
|
||||||
includeContext =>
|
includeContext =>
|
||||||
|
@ -50,7 +65,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
||||||
{
|
{
|
||||||
return includeContext != null &&
|
return includeContext != null &&
|
||||||
(
|
(
|
||||||
(includeContext.IncludePatterns != null && includeContext.IncludePatterns.Count > 0)
|
(includeContext.IncludePatterns != null && includeContext.IncludePatterns.Where((pattern) => !IsPatternBlackListed(pattern)).Count() > 0)
|
||||||
||
|
||
|
||||||
(_emitBuiltInIncludes &&
|
(_emitBuiltInIncludes &&
|
||||||
includeContext.BuiltInsInclude != null &&
|
includeContext.BuiltInsInclude != null &&
|
||||||
|
@ -68,6 +83,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
||||||
|
|
||||||
private readonly string _itemName;
|
private readonly string _itemName;
|
||||||
private bool _transformMappings;
|
private bool _transformMappings;
|
||||||
|
private string[] _patternsBlackList;
|
||||||
private bool _emitBuiltInIncludes;
|
private bool _emitBuiltInIncludes;
|
||||||
private readonly List<ItemMetadataValue<IncludeContext>> _metadata = new List<ItemMetadataValue<IncludeContext>>();
|
private readonly List<ItemMetadataValue<IncludeContext>> _metadata = new List<ItemMetadataValue<IncludeContext>>();
|
||||||
|
|
||||||
|
@ -75,11 +91,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
||||||
string itemName,
|
string itemName,
|
||||||
bool transformMappings = true,
|
bool transformMappings = true,
|
||||||
Func<IncludeContext, bool> condition = null,
|
Func<IncludeContext, bool> condition = null,
|
||||||
bool emitBuiltInIncludes = true) : base(condition)
|
bool emitBuiltInIncludes = true,
|
||||||
|
string[] patternsBlackList = null) : base(condition)
|
||||||
{
|
{
|
||||||
_itemName = itemName;
|
_itemName = itemName;
|
||||||
_transformMappings = transformMappings;
|
_transformMappings = transformMappings;
|
||||||
_emitBuiltInIncludes = emitBuiltInIncludes;
|
_emitBuiltInIncludes = emitBuiltInIncludes;
|
||||||
|
_patternsBlackList = patternsBlackList;
|
||||||
|
|
||||||
_mappingsToTransfrom = (addItemTransform, targetPath) =>
|
_mappingsToTransfrom = (addItemTransform, targetPath) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -641,6 +641,21 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
BuildMSBuild(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)
|
private void VerifyAutoInjectedDesktopReferences(DirectoryInfo projectDirectory, string projectName, bool shouldBePresent)
|
||||||
{
|
{
|
||||||
if (projectName != null)
|
if (projectName != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue