Merge branch 'rel/1.0.0' into dev/jgoshi/handleDeprecatedPJ

This commit is contained in:
Justin Goshi 2017-01-26 14:28:37 -08:00
commit 2cc4f3f166
6 changed files with 65 additions and 3 deletions

View file

@ -13,7 +13,7 @@ The current official release of the csproj-enabled CLI tools is **CLI Preview 4*
There are a couple of things to keep in mind: There are a couple of things to keep in mind:
* Preview 4 CLI bits are still **in development** so some rough edges are to be expected. * Preview 4 CLI bits are still **in development** so some rough edges are to be expected.
* Preview 4 bits **do not support** project.json so you will have to either keep Preview 2 tools around or migrate your project. You can find more information on this using the [project.json to csproj instructions](https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/ProjectJsonToCSProj.md). * Preview 4 bits **do not support** project.json so you will have to either keep Preview 2 tools around or migrate your project or add a global.json file to your project to target preview2. You can find more information on this using the [project.json to csproj instructions](https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/ProjectJsonToCSProj.md).
* Preview 4 refers to the **CLI tools only** and does not cover Visual Studio, VS Code or Visual Studio for Mac. * Preview 4 refers to the **CLI tools only** and does not cover Visual Studio, VS Code or Visual Studio for Mac.
* We welcome any and all issues that relate to MSBuild-based tools, so feel free to try them out and leave comments and file any bugs/problems. * We welcome any and all issues that relate to MSBuild-based tools, so feel free to try them out and leave comments and file any bugs/problems.

View file

@ -0,0 +1,9 @@
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}

View file

@ -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"
}
}
}

View file

@ -110,10 +110,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
compilerOptions => projectFolderName, compilerOptions => projectFolderName,
compilerOptions => compilerOptions.OutputName != null); compilerOptions => compilerOptions.OutputName != null);
private string[] _compilePatternsToExclude = new string[] {
"**/*.cs"
};
private IncludeContextTransform CompileFilesTransform => private IncludeContextTransform CompileFilesTransform =>
new IncludeContextTransform( new IncludeContextTransform(
"Compile", "Compile",
transformMappings: false, transformMappings: false,
patternsToExclude: _compilePatternsToExclude,
condition: ic => ic != null, condition: ic => ic != null,
emitBuiltInIncludes: false); emitBuiltInIncludes: false);

View file

@ -25,6 +25,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
&& includeContext.IncludeFiles != null && includeContext.IncludeFiles != null
&& includeContext.IncludeFiles.Count > 0); && includeContext.IncludeFiles.Count > 0);
private bool IsPatternExcluded(string pattern)
{
return _patternsToExclude.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 +41,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
fullIncludeSet = fullIncludeSet.Union(includeContext.BuiltInsInclude.OrEmptyIfNull()); fullIncludeSet = fullIncludeSet.Union(includeContext.BuiltInsInclude.OrEmptyIfNull());
} }
fullIncludeSet = fullIncludeSet.Where((pattern) => !IsPatternExcluded(pattern));
return FormatGlobPatternsForMsbuild(fullIncludeSet, includeContext.SourceBasePath); return FormatGlobPatternsForMsbuild(fullIncludeSet, includeContext.SourceBasePath);
}, },
includeContext => includeContext =>
@ -50,7 +57,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) => !IsPatternExcluded(pattern)).Count() > 0)
|| ||
(_emitBuiltInIncludes && (_emitBuiltInIncludes &&
includeContext.BuiltInsInclude != null && includeContext.BuiltInsInclude != null &&
@ -68,6 +75,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
private readonly string _itemName; private readonly string _itemName;
private bool _transformMappings; private bool _transformMappings;
private string[] _patternsToExclude;
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 +83,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[] patternsToExclude = null) : base(condition)
{ {
_itemName = itemName; _itemName = itemName;
_transformMappings = transformMappings; _transformMappings = transformMappings;
_emitBuiltInIncludes = emitBuiltInIncludes; _emitBuiltInIncludes = emitBuiltInIncludes;
_patternsToExclude = patternsToExclude ?? Array.Empty<string>();
_mappingsToTransfrom = (addItemTransform, targetPath) => _mappingsToTransfrom = (addItemTransform, targetPath) =>
{ {

View file

@ -641,6 +641,20 @@ 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;
MigrateProject(projectDirectory.FullName);
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)