Merge branch 'rel/1.0.0' into test3formultipletfm

This commit is contained in:
Faizan Ahmad 2016-10-26 21:46:55 +05:30
commit 679ea57acf
28 changed files with 390 additions and 194 deletions

1
.cliversion Normal file
View file

@ -0,0 +1 @@
latest

2
.toolversions Normal file
View file

@ -0,0 +1,2 @@
microsoft.dotnet.buildtools=1.0.26-prerelease-00802-01
microsoft.dotnet.buildtools.run=1.0.0-prerelease-00807-04

View file

@ -1 +0,0 @@
1.0.0-preview2-002733

View file

@ -1 +0,0 @@
1.0.26-prerelease-00621-06

View file

@ -13,16 +13,10 @@ possible and can triage effectively.
The below steps are something that we believe is not a huge increase in process,
but would help us react much faster to any issues that are filed.
1. Check if the [known issues](known-issues.md) cover the issue you are running
1. Check if the [known issues](https://github.com/dotnet/core/blob/master/cli/known-issues.md) cover the issue you are running
into. We are collecting issues that are known and that have workarounds, so it
could be that you can get unblocked pretty easily.
2. Add a label to determine which type of issue it is. If it is a defect, use
the "bug" label, if it is a suggestion for a feature, use the "enhancement"
label. This helps the team get to defects more effectively.
3. Unless you are sure in which milestone the issue falls into, leave it blank.
4. /cc the person that the issue should be assigned to (or @blackdwarf) so that person
would get notified. In this way the correct person can immediately jump on the
issue and triage it.

View file

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

View file

@ -0,0 +1,29 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": "1.0.1",
"TestLibraryAsAPackage": {
"version": "1.0.0",
"target": "package"
}
},
"frameworks": {
"netcoreapp1.0": {}
},
"runtimes": {
"win7-x64": {},
"win7-x86": {},
"osx.10.10-x64": {},
"osx.10.11-x64": {},
"ubuntu.14.04-x64": {},
"ubuntu.16.04-x64": {},
"centos.7-x64": {},
"rhel.7.2-x64": {},
"debian.8-x64": {},
"fedora.23-x64": {},
"opensuse.13.2-x64": {}
}
}

View file

@ -0,0 +1,24 @@
// 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;
namespace TestLibrary
{
public static class Helper
{
/// <summary>
/// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
/// </summary>
/// <returns>A message</returns>
public static string GetMessage()
{
return "This string came from the test library!";
}
public static void SayHi()
{
Console.WriteLine("Hello there!");
}
}
}

View file

@ -0,0 +1,18 @@
{
"version": "1.0.0-*",
"buildOptions": {
"nowarn": [
"CS1591"
],
"xmlDoc": true,
"additionalArguments": [
"-highentropyva+"
]
},
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.5": {}
}
}

View file

@ -0,0 +1,3 @@
{
"projects": [ "." ]
}

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk">
<Version>1.0.0-alpha-20161019-1</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="dotnet-desktop-and-portable">
<Version>1.0.0-*</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-dependency-tool-invoker">
<Version>1.0.0-*</Version>
</DotNetCliToolReference>
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,12 @@
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World!");
}
}
}

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SdkBrandName>Microsoft .NET Core 1.0.1 - SDK Preview 2</SdkBrandName>
<SdkBrandName>Microsoft .NET Core 1.0.1 - SDK Preview 3</SdkBrandName>
<SharedFrameworkBrandName>Microsoft .NET Core 1.0.1 - Runtime</SharedFrameworkBrandName>
<SharedHostBrandName>Microsoft .NET Core 1.0.0 - Host</SharedHostBrandName>
<HostFxrBrandName>Microsoft .NET Core 1.0.0 - Host FX Resolver</HostFxrBrandName>

View file

@ -1,82 +0,0 @@
#
# 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.
#
param(
[string]$Architecture="x64")
$RepoRoot = "$PSScriptRoot"
# Install a stage 0
Write-Host "Installing .NET Core CLI Stage 0 from branchinfo channel"
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel $env:CHANNEL -Architecture $Architecture -Verbose
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
# Disable first run since we want to control all package sources
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Setup BuildTools vars
$BUILD_TOOLS_VERSION = Get-Content "$RepoRoot\BuildToolsVersion.txt"
$BUILD_TOOLS_PATH=$RepoRoot + "\build_tools"
$BUILD_TOOLS_SOURCE='https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json'
$BUILD_TOOLS_SEMAPHORE=$BUILD_TOOLS_PATH + "\init-tools.completed"
$INIT_TOOLS_LOG=$RepoRoot + "\init-tools.log"
$PROJECT_JSON_FILE=$BUILD_TOOLS_PATH + "\project.json"
$PROJECT_JSON_CONTENTS="{ `"dependencies`": { `"Microsoft.DotNet.BuildTools`": `"" + $BUILD_TOOLS_VERSION + "`" }, `"frameworks`": { `"netcoreapp1.0`": { } } }"
$PACKAGES_DIR=$RepoRoot + "\.nuget\packages"
$BUILD_TOOLS_PACKAGE_PATH=$PACKAGES_DIR + "\Microsoft.DotNet.BuildTools\" + $BUILD_TOOLS_VERSION + "\lib"
$DOTNET_EXE_CMD=$env:DOTNET_INSTALL_DIR + "\dotnet.exe"
# If build tools are already installed, escape
if (Test-Path "$BUILD_TOOLS_SEMAPHORE")
{
Write-Host "Tools are already initialized"
exit 0
}
# Check for build tools
if (!(Test-Path "$BUILD_TOOLS_PATH"))
{
mkdir "$BUILD_TOOLS_PATH" | Out-Null
}
# Write the build tools project.json file
"$PROJECT_JSON_CONTENTS" | Set-Content "$PROJECT_JSON_FILE"
# Restore build tools
$args="restore $PROJECT_JSON_FILE --packages $PACKAGES_DIR --source $BUILD_TOOLS_SOURCE"
Start-Process -FilePath $DOTNET_EXE_CMD -ArgumentList $args -Wait -RedirectStandardOutput $INIT_TOOLS_LOG -NoNewWindow
if (!(Test-Path "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd"))
{
Write-Host "ERROR: Could not restore build tools correctly. See '$INIT_TOOLS_LOG' for more details"
exit 1
}
# Bring down the CLI for build tools
$DOTNET_PATH=$BUILD_TOOLS_PATH + "\dotnetcli"
Write-Host "Installing Build Tools CLI version..."
if (!(Test-Path "$DOTNET_PATH"))
{
mkdir "$DOTNET_PATH"
}
$DOTNET_VERSION = Get-Content "$RepoRoot\BuildToolsCliVersion.txt"
$DOTNET_LOCAL_PATH=$DOTNET_PATH
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel "rel-1.0.0" -Version "$DOTNET_VERSION" -InstallDir "$DOTNET_LOCAL_PATH"
if (!(Test-Path "$DOTNET_LOCAL_PATH"))
{
Write-Host "Could not install Build Tools CLI version correctly"
exit 1
}
# Initialize build tools
cmd /c "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd $RepoRoot $DOTNET_LOCAL_PATH\dotnet.exe $BUILD_TOOLS_PATH" >> "$INIT_TOOLS_LOG"
Write-Host "Done initializing tools."
Write-Host "Init-Tools completed for BuildTools Version: $BUILD_TOOLS_VERSION" > $BUILD_TOOLS_SEMAPHORE

View file

@ -1,56 +0,0 @@
#!/usr/bin/env bash
#
# 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.
#
set -e
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
$DIR/scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose
__init_tools_log=$DIR/init-tools.log
__BUILD_TOOLS_CLI_VERSION=$(cat "$DIR/BuildToolsCliVersion.txt")
__BUILD_TOOLS_DIR=$DIR/build_tools
__BUILD_TOOLS_CLI_DIR=$__BUILD_TOOLS_DIR/dotnetcli/
__BUILD_TOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json
__BUILD_TOOLS_PACKAGE_VERSION=$(cat $DIR/BuildToolsVersion.txt)
__BUILD_TOOLS_PATH=$NUGET_PACKAGES/Microsoft.DotNet.BuildTools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
__BUILD_TOOLS_SEMAPHORE=$__BUILD_TOOLS_DIR/init-tools.completed
__DOTNET_CMD=$__BUILD_TOOLS_CLI_DIR/dotnet
__PROJECT_JSON_PATH=$__BUILD_TOOLS_DIR/$__BUILD_TOOLS_PACKAGE_VERSION
__PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json
__PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"netcoreapp1.0\": { } } }"
if [ ! -e "$__PROJECT_JSON_FILE" ]; then
mkdir -p "$__PROJECT_JSON_PATH"
echo "$__PROJECT_JSON_CONTENTS" > "$__PROJECT_JSON_FILE"
if [ ! -d "$__BUILD_TOOLS_CLI_DIR" ]; then
echo "Installing Build Tools CLI Version: $__BUILD_TOOLS_CLI_VERSION"
"$DIR/scripts/obtain/dotnet-install.sh" --channel rel-1.0.0 --version "$__BUILD_TOOLS_CLI_VERSION" --install-dir "$__BUILD_TOOLS_CLI_DIR"
fi
if [ ! -d "$__BUILD_TOOLS_PATH" ]; then
echo "Restoring build tools version $__BUILD_TOOLS_PACKAGE_VERSION..."
"$__DOTNET_CMD" restore "$__PROJECT_JSON_FILE" --packages "$NUGET_PACKAGES" --source "$__BUILD_TOOLS_SOURCE"
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."; fi
find .
fi
echo "Initializing build tools..."
"$__BUILD_TOOLS_PATH/init-tools.sh" "$DIR" "$__DOTNET_CMD" "$__BUILD_TOOLS_DIR" >> "$__init_tools_log" 2>&1
echo "Init-Tools completed for BuildTools Version: $__BUILD_TOOLS_PACKAGE_VERSION" > "$__BUILD_TOOLS_SEMAPHORE"
echo "Done initializing tools"
else
echo "Tools are already initialized"
fi

View file

@ -59,15 +59,35 @@ if (!(Test-Path $env:DOTNET_INSTALL_DIR))
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
}
& "$RepoRoot\init-tools.ps1" -Architecture $Architecture
if($LASTEXITCODE -ne 0) { throw "Failed to install Init Tools" }
# Disable first run since we want to control all package sources
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# set the base tools directory
$toolsLocalPath = Join-Path $PSScriptRoot "build_tools"
$bootStrapperPath = Join-Path $toolsLocalPath "bootstrap.ps1"
# if the boot-strapper script doesn't exist then download it
if ((Test-Path $bootStrapperPath) -eq 0)
{
if ((Test-Path $toolsLocalPath) -eq 0)
{
mkdir $toolsLocalPath | Out-Null
}
# download boot-strapper script
Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/buildtools/master/bootstrap/bootstrap.ps1" -OutFile $bootStrapperPath
}
# now execute it
& $bootStrapperPath -RepositoryRoot (Get-Location) -ToolsLocalPath $toolsLocalPath -CliLocalPath $env:DOTNET_INSTALL_DIR | Out-File (Join-Path (Get-Location) "bootstrap.log")
if ($LastExitCode -ne 0)
{
Write-Output "Boot-strapping failed with exit code $LastExitCode, see bootstrap.log for more information."
exit $LastExitCode
}
# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
# Disable first run since we want to control all package sources
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
if ($NoBuild)
{
Write-Host "Not building due to --nobuild"

View file

@ -6,6 +6,41 @@
set -e
machine_has() {
hash "$1" > /dev/null 2>&1
return $?
}
check_min_reqs() {
if ! machine_has "curl"; then
echo "run-build: Error: curl is required to download dotnet. Install curl to proceed." >&2
return 1
fi
return 0
}
# args:
# remote_path - $1
# [out_path] - $2 - stdout if not provided
download() {
eval $invocation
local remote_path=$1
local out_path=${2:-}
local failed=false
if [ -z "$out_path" ]; then
curl --retry 10 -sSL --create-dirs $remote_path || failed=true
else
curl --retry 10 -sSL --create-dirs -o $out_path $remote_path || failed=true
fi
if [ "$failed" = true ]; then
echo "run-build: Error: Download failed" >&2
return 1
fi
}
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@ -14,7 +49,6 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
REPOROOT="$DIR"
OLDPATH="$PATH"
ARCHITECTURE="x64"
source "$REPOROOT/scripts/common/_prettyprint.sh"
@ -98,7 +132,23 @@ done < "$REPOROOT/branchinfo.txt"
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$ARCHITECTURE
[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR
$REPOROOT/init-tools.sh
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
toolsLocalPath="$REPOROOT/build_tools"
bootStrapperPath="$toolsLocalPath/bootstrap.sh"
if [ ! -f $bootStrapperPath ]; then
if [ ! -d $toolsLocalPath ]; then
mkdir $toolsLocalPath
fi
download "https://raw.githubusercontent.com/dotnet/buildtools/master/bootstrap/bootstrap.sh" "$bootStrapperPath"
chmod u+x $bootStrapperPath
fi
$bootStrapperPath --repositoryRoot "$REPOROOT" --toolsLocalPath "$toolsLocalPath" --cliInstallPath $DOTNET_INSTALL_DIR > bootstrap.log
if [ $? != 0 ]; then
echo "run-build: Error: Boot-strapping failed with exit code $?, see bootstrap.log for more information." >&2
exit $?
fi
# Put stage 0 on the PATH (for this shell only)
PATH="$DOTNET_INSTALL_DIR:$PATH"

View file

@ -16,6 +16,8 @@ namespace Microsoft.DotNet.Cli.Utils
string RuntimeConfigJsonPath { get; }
string FullOutputPath { get; }
Dictionary<string, string> EnvironmentVariables { get; }
}
}

View file

@ -39,6 +39,17 @@ namespace Microsoft.DotNet.Cli.Utils
}
}
public string FullOutputPath
{
get
{
return _project
.AllEvaluatedProperties
.FirstOrDefault(p => p.Name.Equals("TargetDir"))
.EvaluatedValue;
}
}
public Dictionary<string, string> EnvironmentVariables
{
get

View file

@ -42,19 +42,22 @@ namespace Microsoft.DotNet.Cli.Utils
string outputPath,
string buildBasePath)
{
var projectContext = GetProjectContextFromDirectory(
var projectFactory = new ProjectFactory(_environment);
var project = projectFactory.GetProject(
projectDirectory,
framework);
framework,
configuration,
buildBasePath,
outputPath);
if (projectContext == null)
if (project == null)
{
return null;
}
var buildOutputPath =
projectContext.GetOutputPaths(configuration, buildBasePath, outputPath).RuntimeFiles.BasePath;
var buildOutputPath = project.FullOutputPath;
if (! Directory.Exists(buildOutputPath))
if (!Directory.Exists(buildOutputPath))
{
Reporter.Verbose.WriteLine($"outputpathresolver: {buildOutputPath} does not exist");
return null;
@ -62,34 +65,7 @@ namespace Microsoft.DotNet.Cli.Utils
return _environment.GetCommandPathFromRootPath(buildOutputPath, commandName);
}
private ProjectContext GetProjectContextFromDirectory(string directory, NuGetFramework framework)
{
if (directory == null || framework == null)
{
return null;
}
var projectRootPath = directory;
if (!File.Exists(Path.Combine(projectRootPath, Project.FileName)))
{
return null;
}
var projectContext = ProjectContext.Create(
projectRootPath,
framework,
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
if (projectContext.RuntimeIdentifier == null)
{
return null;
}
return projectContext;
}
internal override CommandResolutionStrategy GetCommandResolutionStrategy()
{
return CommandResolutionStrategy.OutputPath;

View file

@ -67,6 +67,15 @@ namespace Microsoft.DotNet.Cli.Utils
}
}
public string FullOutputPath
{
get
{
return
ProjectContext.GetOutputPaths(_configuration, _buildBasePath, _outputPath).RuntimeFiles.BasePath;
}
}
public Dictionary<string, string> EnvironmentVariables
{
get

View file

@ -66,7 +66,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration
projectFileDependenciesForFramework = project.GetTargetFramework(framework).Dependencies;
}
foreach (var projectFileDependency in projectFileDependenciesForFramework)
foreach (var projectFileDependency in
projectFileDependenciesForFramework.Where(p =>
p.LibraryRange.TypeConstraint == LibraryDependencyTarget.Project))
{
var dependencyName = projectFileDependency.Name;
@ -105,7 +107,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
FindPossibleProjectDependencies(projectContext.ProjectFile.ProjectFilePath);
var projectDependencies = new List<ProjectDependency>();
foreach (var projectExport in projectExports)
foreach (var projectExport in
projectExports.Where(p => p.Library.Identity.Type == LibraryType.Project))
{
var projectExportName = projectExport.Library.Identity.Name;
ProjectDependency projectDependency;

View file

@ -273,8 +273,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
mergedItem.UnionExcludes(existingItem.Excludes());
mergedItem.UnionExcludes(item.Excludes());
mergedItem.AddMetadata(existingItem.Metadata);
mergedItem.AddMetadata(item.Metadata);
mergedItem.AddMetadata(MergeMetadata(existingItem.Metadata, item.Metadata));
item.RemoveIncludes(commonIncludes);
existingItem.RemoveIncludes(commonIncludes);
@ -289,6 +288,37 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
return mergeResult;
}
private ICollection<ProjectMetadataElement> MergeMetadata(
ICollection<ProjectMetadataElement> existingMetadataElements,
ICollection<ProjectMetadataElement> newMetadataElements)
{
var mergedMetadata = new List<ProjectMetadataElement>(existingMetadataElements);
foreach (var newMetadata in newMetadataElements)
{
var existingMetadata = mergedMetadata.FirstOrDefault(m =>
m.Name.Equals(newMetadata.Name, StringComparison.OrdinalIgnoreCase));
if (existingMetadata == null)
{
mergedMetadata.Add(newMetadata);
}
else
{
MergeMetadata(existingMetadata, newMetadata);
}
}
return mergedMetadata;
}
public void MergeMetadata(ProjectMetadataElement existingMetadata, ProjectMetadataElement newMetadata)
{
if (existingMetadata.Value != newMetadata.Value)
{
existingMetadata.Value = string.Join(";", new [] { existingMetadata.Value, newMetadata.Value });
}
}
private IEnumerable<ProjectItemElement> FindExistingItemsWithSameCondition(
ProjectItemElement item,
ProjectRootElement project,

View file

@ -69,7 +69,9 @@ namespace Microsoft.DotNet.Tools.Restore3
{
var msbuildArgs = new List<string>()
{
"/t:Restore"
"/NoLogo",
"/t:Restore",
"/ConsoleLoggerParameters:Verbosity=Minimal"
};
if (sourceOption.HasValue())

View file

@ -1,6 +1,7 @@
// 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.IO;
using FluentAssertions;
using Microsoft.DotNet.ProjectModel;
@ -15,6 +16,16 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{
private static readonly NuGetFramework s_desktopTestFramework = FrameworkConstants.CommonFrameworks.Net451;
private RepoDirectoriesProvider _repoDirectoriesProvider;
public GivenAProjectDependenciesCommandFactory()
{
_repoDirectoriesProvider = new RepoDirectoriesProvider();
Environment.SetEnvironmentVariable(
Constants.MSBUILD_EXE_PATH,
Path.Combine(_repoDirectoriesProvider.Stage2Sdk, "MSBuild.dll"));
}
[WindowsOnlyFact]
public void It_resolves_desktop_apps_defaulting_to_Debug_Configuration()
{
@ -46,6 +57,40 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
}
[WindowsOnlyFact]
public void It_resolves_desktop_apps_with_MSBuild_defaulting_to_Debug_Configuration()
{
var configuration = "Debug";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
var testInstance = testAssetManager.CreateTestInstance("MSBuildAppWithMultipleFrameworksAndTools", "i")
.WithLockFiles();
var projectFile = Path.Combine(testInstance.TestRoot, "MSBuildAppWithMultipleFrameworksAndTools.csproj");
new Restore3Command()
.ExecuteWithCapturedOutput($"{projectFile} -s {_repoDirectoriesProvider.TestPackages}")
.Should()
.Pass();
new Build3Command()
.Execute($"{projectFile} --configuration {configuration}")
.Should()
.Pass();
var factory = new ProjectDependenciesCommandFactory(
s_desktopTestFramework,
null,
null,
null,
testInstance.TestRoot);
var command = factory.Create("dotnet-desktop-and-portable", null);
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
}
[WindowsOnlyFact]
public void It_resolves_desktop_apps_when_configuration_is_Debug()
{

View file

@ -260,6 +260,40 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().BeEmpty();
}
[Fact]
public void Migrating_same_file_with_multiple_mappings_string_joins_the_mappings_in_PackagePath()
{
var mockProj = RunPackOptionsRuleOnPj(@"
{
""packOptions"": {
""files"": {
""include"": [""path/to/some/file.cs""],
""mappings"": {
""other/path/file.cs"": ""path/to/some/file.cs"",
""different/path/file1.cs"": ""path/to/some/file.cs""
}
}
}
}");
var expectedPackagePath = string.Join(
";",
new [] {
Path.Combine("different", "path"),
Path.Combine("other", "path")
});
var contentItems = mockProj.Items
.Where(item => item.ItemType.Equals("Content", StringComparison.Ordinal))
.Where(item =>
item.GetMetadataWithName("Pack").Value == "true" &&
item.GetMetadataWithName("PackagePath") != null);
contentItems.Count().Should().Be(1);
contentItems.First().Include.Should().Be(@"path\to\some\file.cs");
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be(expectedPackagePath);
}
private ProjectRootElement RunPackOptionsRuleOnPj(string packOptions, string testDirectory = null)
{
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;

View file

@ -1,6 +1,7 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using System;
@ -39,6 +40,27 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
projectReference.Parent.Condition.Should().BeEmpty();
}
[Fact]
public void It_does_not_migrate_a_dependency_with_target_package_that_has_a_matching_project_as_a_ProjectReference()
{
var testAssetsManager = GetTestGroupTestAssetsManager("NonRestoredTestProjects");
var solutionDirectory =
testAssetsManager.CreateTestInstance("AppWithProjectDependencyAsTarget", callingMethod: "p").Path;
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj, null);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
mockProj.AddPropertyGroup());
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
var projectReferences = mockProj.Items.Where(
item => item.ItemType.Equals("ProjectReference", StringComparison.Ordinal));
projectReferences.Should().BeEmpty();
}
[Fact]
public void TFM_specific_Project_dependencies_are_migrated_to_ProjectReference_under_condition_ItemGroup()
{