Merge pull request #4008 from eerhardt/msbuild-RemoveSdk

Remove the SDK artifacts from the CLI.
This commit is contained in:
Eric Erhardt 2016-08-11 17:31:47 -05:00 committed by GitHub
commit 150abf543b
30 changed files with 46 additions and 14559 deletions

View file

@ -148,12 +148,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{FF498306-2
build\test\TestProjects.targets = build\test\TestProjects.targets
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Core.Build.Tasks", "src\Microsoft.DotNet.Core.Build.Tasks\Microsoft.DotNet.Core.Build.Tasks.xproj", "{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Tests.Utilities", "test\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.xproj", "{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Core.Build.Tasks.Tests", "test\Microsoft.DotNet.Core.Build.Tasks.Tests\Microsoft.DotNet.Core.Build.Tasks.Tests.xproj", "{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "publish", "publish", "{27B12960-ABB0-4903-9C60-5E9157E659C8}"
ProjectSection(SolutionItems) = preProject
build\publish\Microsoft.DotNet.Cli.Badge.targets = build\publish\Microsoft.DotNet.Cli.Badge.targets
@ -860,22 +856,6 @@ Global
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{49D7318E-D198-4E2B-BBEA-3A24D805F88D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Debug|x64.ActiveCfg = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Debug|x64.Build.0 = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Release|Any CPU.Build.0 = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Release|x64.ActiveCfg = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.Release|x64.Build.0 = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -892,22 +872,6 @@ Global
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Debug|x64.ActiveCfg = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Debug|x64.Build.0 = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Release|Any CPU.Build.0 = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Release|x64.ActiveCfg = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.Release|x64.Build.0 = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -964,9 +928,7 @@ Global
{FD7D515A-D10F-4F49-B8AE-21CF7ED071AE} = {89905EC4-BC0F-443B-8ADF-691321F10108}
{8E3354BD-827F-41B7-9EE6-6BE1F1EDD8E9} = {89905EC4-BC0F-443B-8ADF-691321F10108}
{FF498306-2DE2-47F6-8C35-3CF0589CF2B8} = {89905EC4-BC0F-443B-8ADF-691321F10108}
{E8E7D24B-4830-4662-80A8-255D6FE3B0BE} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{EDD6C92D-0A58-4FCB-A0E9-9D0FFC045177} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{27B12960-ABB0-4903-9C60-5E9157E659C8} = {89905EC4-BC0F-443B-8ADF-691321F10108}
EndGlobalSection
EndGlobal

View file

@ -2,28 +2,12 @@
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.DotNet.Core.Sdk": "1.0.0-alpha-20160811-3",
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
}
}
}
},
"runtimes": {
"win7-x64": {},
"win7-x86": {},
"win81-x64": {},
"win81-x86": {},
"win10-x64": {},
"win10-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

@ -1,17 +0,0 @@
<!--
***********************************************************************************************
Microsoft.NETCore.ImportBefore.props
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NETCoreProps Condition="'$(NETCoreProps)'==''">$(MSBuildExtensionsPath)\Microsoft.DotNet.Core.Sdk.props</NETCoreProps>
</PropertyGroup>
<Import Condition="Exists('$(NETCoreProps)')" Project="$(NETCoreProps)" />
</Project>

View file

@ -1,17 +0,0 @@
<!--
***********************************************************************************************
Microsoft.NETCore.ImportAfter.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NETCoreTargets Condition="'$(NETCoreTargets)'==''">$(MSBuildExtensionsPath)\Microsoft.DotNet.Core.Sdk.targets</NETCoreTargets>
</PropertyGroup>
<Import Condition="Exists('$(NETCoreTargets)')" Project="$(NETCoreTargets)" />
</Project>

View file

@ -1,68 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<!-- User-facing configuration-agnostic defaults -->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform>AnyCPU</Platform>
<FileAlignment>512</FileAlignment>
<GlobalExclude>bin\**;obj\**;</GlobalExclude>
</PropertyGroup>
<!-- User-facing configuration-specific defaults -->
<PropertyGroup>
<!-- TODO: This property can't be set in the CLI since ResolveNuGetPackageAssets needs an exact RID from the project.json, and the RID is made up of the PlatformTarget -->
<!--<PlatformTarget>AnyCPU</PlatformTarget>-->
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>$(NoWarn);1701</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<!-- Default settings for .NET Core build logic -->
<PropertyGroup>
<GenerateDependencyFile Condition=" '$(GenerateDependencyFile)' == '' ">true</GenerateDependencyFile>
<!-- This will turn off the base 'ResolveNuGetPackages' target since it is UWP specific, and .NET Core needs it to be split up -->
<!--<ResolveNuGetPackages>false</ResolveNuGetPackages>-->
</PropertyGroup>
<PropertyGroup>
<NoStdLib>true</NoStdLib>
<!-- TODO: Need to figure out runtimes -->
<!-- TODO: Below are hacks eerhardt made on top of davkean's .props file -->
<!-- Temp Hack: davkean had this, but that casues all references not to be copied to output dir:
<CopyNuGetImplementations>false</CopyNuGetImplementations>
This will be set to false during "build", but set to true during "publish"
-->
<!-- Temp Hack: https://github.com/dotnet/roslyn/issues/12167 -->
<NoLogo>true</NoLogo>
<!-- Need to revisit this and see if this is the correct default for both Debug and Release -->
<DebugType>portable</DebugType>
<!-- Temp Hack: https://github.com/Microsoft/msbuild/issues/720 -->
<OverrideToolHost Condition=" '$(DotnetHostPath)' != '' and '$(OverrideToolHost)' == ''">$(DotnetHostPath)</OverrideToolHost>
</PropertyGroup>
</Project>

View file

@ -1,120 +0,0 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MicrosoftDotNetCoreBuildTasksDirectoryRoot>$(MSBuildThisFileDirectory)../../lib/</MicrosoftDotNetCoreBuildTasksDirectoryRoot>
<MicrosoftDotNetCoreBuildTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">netstandard1.6</MicrosoftDotNetCoreBuildTasksTFM>
<MicrosoftDotNetCoreBuildTasksTFM Condition=" '$(MicrosoftDotNetCoreBuildTasksTFM)' == ''">net451</MicrosoftDotNetCoreBuildTasksTFM>
<MicrosoftDotNetCoreBuildTasksDirectory>$(MicrosoftDotNetCoreBuildTasksDirectoryRoot)$(MicrosoftDotNetCoreBuildTasksTFM)/</MicrosoftDotNetCoreBuildTasksDirectory>
<!-- If the build task directory doesn't exist (since we aren't in a NuGet package), load the task assembly in the tools path -->
<MicrosoftDotNetCoreBuildTasksDirectory Condition=" !Exists('$(MicrosoftDotNetCoreBuildTasksDirectory)') ">$(MSBuildToolsPath)/</MicrosoftDotNetCoreBuildTasksDirectory>
</PropertyGroup>
<PropertyGroup>
<!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
to prevent it from outputting a warning (MSB3644).
-->
<_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
</PropertyGroup>
<PropertyGroup>
<GenerateRuntimeConfigurationFiles Condition=" '$(GenerateRuntimeConfigurationFiles)' == '' and '$(OutputType)' == 'exe' ">true</GenerateRuntimeConfigurationFiles>
<UserRuntimeConfig Condition=" '$(UserRuntimeConfig)' == '' ">$(MSBuildProjectDirectory)/runtimeconfig.template.json</UserRuntimeConfig>
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">1.0.0</VersionPrefix>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' "></VersionSuffix>
<Version Condition=" '$(Version)' == '' and '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
<Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version>
</PropertyGroup>
<UsingTask TaskName="GenerateDepsFile" AssemblyFile="$(MicrosoftDotNetCoreBuildTasksDirectory)Microsoft.DotNet.Core.Build.Tasks.dll" />
<UsingTask TaskName="GenerateRuntimeConfigurationFiles" AssemblyFile="$(MicrosoftDotNetCoreBuildTasksDirectory)Microsoft.DotNet.Core.Build.Tasks.dll" />
<PropertyGroup>
<CoreBuildDependsOn>
$(CoreBuildDependsOn);
GenerateDependencyFile;
GenerateRuntimeConfigurationFiles
</CoreBuildDependsOn>
</PropertyGroup>
<Target Name="GenerateDependencyFile"
Condition=" '$(GenerateDependencyFile)' == 'true'">
<!--
TODO: Is this the best way? Should we just tell CSC to output $(AssemblyName).dll directly?
-->
<Move SourceFiles="$(TargetPath)" DestinationFiles="$(TargetDir)/$(AssemblyName).dll" />
<!--
TODO: Get RuntimeIdentifier
-->
<GenerateDepsFile LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
DepsFilePath="$(TargetDir)$(AssemblyName).deps.json"
TargetFramework="$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)"
AssemblyName="$(AssemblyName)"
AssemblyVersion="$(Version)"
RuntimeIdentifier="" />
<!--
TODO: When OutputType == 'exe' and !IsPortable, we need to verify CoreClr is present in the deps graph, and copy in a host to the output
See https://github.com/dotnet/cli/blob/6b54ae0bcc5c63e7c989ac19d851f234f9172bea/src/Microsoft.DotNet.Compiler.Common/Executable.cs#L102-L107
-->
</Target>
<Target Name="GenerateRuntimeConfigurationFiles"
Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'">
<GenerateRuntimeConfigurationFiles LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
RuntimeConfigPath="$(TargetDir)/$(AssemblyName).runtimeconfig.json"
RuntimeConfigDevPath="$(TargetDir)/$(AssemblyName).runtimeconfig.dev.json"
UserRuntimeConfig="$(UserRuntimeConfig)" />
</Target>
<!--
============================================================
GetRunInformation
Returns the ProcessStart information that can be used to run this project.
============================================================
-->
<Target Name="GetRunInformation"
DependsOnTargets="GenerateRunInformation"
Outputs="@(RunInformation)" />
<Target Name="GenerateRunInformation">
<ItemGroup>
<RunInformation Include="$(MSBuildProjectFullPath)">
<!-- TODO: Need to get the Muxer path from MSBuild -->
<CommandName>dotnet</CommandName>
<Args>exec;$(TargetDir)/$(AssemblyName).dll</Args>
</RunInformation>
</ItemGroup>
</Target>
<!--
============================================================
Publish
Override the "in-box" publish, which is very ClickOnce centric.
============================================================
-->
<PropertyGroup>
<PublishDependsOn>
Build;
CopyPublishArtifacts
</PublishDependsOn>
<PublishDir Condition=" '$(PublishDir)' == '' ">$(OutDir)publish\</PublishDir>
</PropertyGroup>
<Target
Name="Publish"
DependsOnTargets="$(PublishDependsOn)" />
<Target Name="CopyPublishArtifacts">
<Message Text="TODO: Implement CopyPublishArtifacts" />
</Target>
</Project>

View file

@ -1,270 +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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Extensions.DependencyModel;
using NuGet.Frameworks;
using NuGet.Packaging.Core;
using NuGet.ProjectModel;
namespace Microsoft.DotNet.Core.Build.Tasks
{
public class DependencyContextBuilder
{
public DependencyContextBuilder()
{
}
public DependencyContext Build(
string projectName,
string projectVersion,
CompilationOptions compilerOptions,
LockFile lockFile,
NuGetFramework framework,
string runtime)
{
LockFileTarget lockFileTarget = lockFile.GetTarget(framework, runtime);
IEnumerable<LockFileTargetLibrary> runtimeExports = lockFileTarget.Libraries;
// TODO: get this from the lock file once https://github.com/NuGet/Home/issues/2695 is fixed.
var platformPackageName = "Microsoft.NETCore.App";
var platformExport = lockFileTarget
.Libraries
.FirstOrDefault(e => e.Name.Equals(platformPackageName, StringComparison.OrdinalIgnoreCase));
bool portable = platformExport != null;
if (portable)
{
runtimeExports = FilterPlatformDependencies(runtimeExports, platformExport);
}
var dependencyLookup = runtimeExports
.Select(identity => new Dependency(identity.Name, identity.Version.ToString()))
.ToDictionary(dependency => dependency.Name, StringComparer.OrdinalIgnoreCase);
var libraryLookup = lockFile.Libraries.ToDictionary(l => l.Name, StringComparer.OrdinalIgnoreCase);
var runtimeSignature = GenerateRuntimeSignature(runtimeExports);
IEnumerable<RuntimeLibrary> runtimeLibraries =
new[] { GetProjectLibrary(projectName, projectVersion, lockFile, lockFileTarget, dependencyLookup) }
.Concat(GetLibraries(runtimeExports, libraryLookup, dependencyLookup, runtime: true).Cast<RuntimeLibrary>());
return new DependencyContext(
new TargetInfo(framework.DotNetFrameworkName, runtime, runtimeSignature, portable),
compilerOptions ?? CompilationOptions.Default,
Enumerable.Empty<CompilationLibrary>(), //GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(),
runtimeLibraries,
new RuntimeFallbacks[] { });
}
private static IEnumerable<LockFileTargetLibrary> FilterPlatformDependencies(
IEnumerable<LockFileTargetLibrary> runtimeExports,
LockFileTargetLibrary platformExport)
{
var exportsLookup = runtimeExports.ToDictionary(e => e.Name, StringComparer.OrdinalIgnoreCase);
HashSet<string> exclusionList = GetPlatformExclusionList(platformExport, exportsLookup);
return runtimeExports.Where(e => !exclusionList.Contains(e.Name));
}
private static HashSet<string> GetPlatformExclusionList(
LockFileTargetLibrary platformExport,
IDictionary<string, LockFileTargetLibrary> exportsLookup)
{
var exclusionList = new HashSet<string>();
exclusionList.Add(platformExport.Name);
CollectDependencies(exportsLookup, platformExport.Dependencies, exclusionList);
return exclusionList;
}
private static void CollectDependencies(
IDictionary<string, LockFileTargetLibrary> exportsLookup,
IEnumerable<PackageDependency> dependencies,
HashSet<string> exclusionList)
{
foreach (PackageDependency dependency in dependencies)
{
LockFileTargetLibrary export = exportsLookup[dependency.Id];
if (export.Version.Equals(dependency.VersionRange.MinVersion))
{
exclusionList.Add(export.Name);
CollectDependencies(exportsLookup, export.Dependencies, exclusionList);
}
}
}
private static string GenerateRuntimeSignature(IEnumerable<LockFileTargetLibrary> runtimeExports)
{
var sha1 = SHA1.Create();
var builder = new StringBuilder();
var packages = runtimeExports
.Where(libraryExport => libraryExport.Type == "package");
var separator = "|";
foreach (var libraryExport in packages)
{
builder.Append(libraryExport.Name);
builder.Append(separator);
builder.Append(libraryExport.Version.ToString());
builder.Append(separator);
}
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()));
builder.Clear();
foreach (var hashByte in hash)
{
builder.AppendFormat("{0:x2}", hashByte);
}
return builder.ToString();
}
private RuntimeLibrary GetProjectLibrary(
string projectName,
string projectVersion,
LockFile lockFile,
LockFileTarget lockFileTarget,
Dictionary<string, Dependency> dependencyLookup)
{
RuntimeAssetGroup[] runtimeAssemblyGroups = new[] { new RuntimeAssetGroup(string.Empty, $"{projectName}.dll") };
List<Dependency> dependencies = new List<Dependency>();
IEnumerable<ProjectFileDependencyGroup> projectFileDependencies = lockFile
.ProjectFileDependencyGroups
.Where(dg => dg.FrameworkName == string.Empty ||
dg.FrameworkName == lockFileTarget.TargetFramework.DotNetFrameworkName);
foreach (string projectFileDependency in projectFileDependencies.SelectMany(dg => dg.Dependencies))
{
int separatorIndex = projectFileDependency.IndexOf(' ');
string dependencyName = separatorIndex > 0 ?
projectFileDependency.Substring(0, separatorIndex) :
projectFileDependency;
Dependency dependency;
if (dependencyLookup.TryGetValue(dependencyName, out dependency))
{
dependencies.Add(dependency);
}
}
return new RuntimeLibrary(
type: "project",
name: projectName,
version: projectVersion,
hash: string.Empty,
runtimeAssemblyGroups: runtimeAssemblyGroups,
nativeLibraryGroups: new RuntimeAssetGroup[] { },
resourceAssemblies: new ResourceAssembly[] { },
dependencies: dependencies.ToArray(),
serviceable: false);
}
private IEnumerable<Library> GetLibraries(
IEnumerable<LockFileTargetLibrary> exports,
IDictionary<string, LockFileLibrary> libraryLookup,
IDictionary<string, Dependency> dependencyLookup,
bool runtime)
{
return exports.Select(export => GetLibrary(export, libraryLookup, dependencyLookup, runtime));
}
private Library GetLibrary(
LockFileTargetLibrary export,
IDictionary<string, LockFileLibrary> libraryLookup,
IDictionary<string, Dependency> dependencyLookup,
bool runtime)
{
var type = export.Type;
// TEMPORARY: All packages are serviceable in RC2
// See https://github.com/dotnet/cli/issues/2569
var serviceable = export.Type == "package";
var libraryDependencies = new HashSet<Dependency>();
foreach (PackageDependency libraryDependency in export.Dependencies)
{
Dependency dependency;
if (dependencyLookup.TryGetValue(libraryDependency.Id, out dependency))
{
libraryDependencies.Add(dependency);
}
}
string hash = string.Empty;
LockFileLibrary library;
if (libraryLookup.TryGetValue(export.Name, out library))
{
hash = "sha512-" + library.Sha512;
}
if (runtime)
{
return new RuntimeLibrary(
type.ToLowerInvariant(),
export.Name,
export.Version.ToString(),
hash,
CreateRuntimeAssemblyGroups(export),
CreateNativeLibraryGroups(export),
export.ResourceAssemblies.Select(CreateResourceAssembly),
libraryDependencies,
serviceable
);
}
//else
//{
// IEnumerable<string> assemblies = export
// .CompilationAssemblies
// .Select(libraryAsset => libraryAsset.RelativePath);
// return new CompilationLibrary(
// type.ToString().ToLowerInvariant(),
// export.Library.Identity.Name,
// export.Library.Identity.Version.ToString(),
// export.Library.Hash,
// assemblies,
// libraryDependencies,
// serviceable);
//}
return null;
}
private IReadOnlyList<RuntimeAssetGroup> CreateRuntimeAssemblyGroups(LockFileTargetLibrary export)
{
List<RuntimeAssetGroup> assemblyGroups = new List<RuntimeAssetGroup>();
assemblyGroups.Add(
new RuntimeAssetGroup(string.Empty, export.RuntimeAssemblies.Select(a => a.Path)));
// TODO RuntimeTargets
//export.RuntimeTargets.GroupBy(l => l.)
return assemblyGroups;
}
private IReadOnlyList<RuntimeAssetGroup> CreateNativeLibraryGroups(LockFileTargetLibrary export)
{
return new[] { new RuntimeAssetGroup(string.Empty, export.NativeLibraries.Select(a => a.Path)) };
}
private ResourceAssembly CreateResourceAssembly(LockFileItem resourceAssembly)
{
// TODO: implement
return null;
//return new ResourceAssembly(
// path: resourceAssembly.Path,
// locale: resourceAssembly.Locale
// );
}
}
}

View file

@ -1,57 +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.
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Extensions.DependencyModel;
using Newtonsoft.Json;
using NuGet.Frameworks;
using NuGet.ProjectModel;
namespace Microsoft.DotNet.Core.Build.Tasks
{
/// <summary>
/// Generates the $(project).deps.json file.
/// </summary>
public class GenerateDepsFile : Task
{
[Required]
public string LockFilePath { get; set; }
[Required]
public string DepsFilePath { get; set; }
[Required]
public string TargetFramework { get; set; }
public string RuntimeIdentifier { get; set; }
[Required]
public string AssemblyName { get; set; }
[Required]
public string AssemblyVersion { get; set; }
public override bool Execute()
{
LockFile lockFile = LockFileCache.Instance.GetLockFile(LockFilePath);
DependencyContext dependencyContext = new DependencyContextBuilder().Build(
projectName: AssemblyName,
projectVersion: AssemblyVersion,
compilerOptions: null, // TODO: PreservceCompliationContext
lockFile: lockFile,
framework: TargetFramework == null ? null : NuGetFramework.Parse(TargetFramework),
runtime: RuntimeIdentifier);
var writer = new DependencyContextWriter();
using (var fileStream = File.Create(DepsFilePath))
{
writer.Write(dependencyContext, fileStream);
}
return true;
}
}
}

View file

@ -1,146 +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.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using NuGet.ProjectModel;
namespace Microsoft.DotNet.Core.Build.Tasks
{
/// <summary>
/// Generates the $(project).runtimeconfig.json and optionally $(project).runtimeconfig.dev.json files
/// for a project.
/// </summary>
public class GenerateRuntimeConfigurationFiles : Task
{
[Required]
public string LockFilePath { get; set; }
[Required]
public string RuntimeConfigPath { get; set; }
public string RuntimeConfigDevPath { get; set; }
public string UserRuntimeConfig { get; set; }
private LockFile LockFile { get; set; }
public override bool Execute()
{
LockFile = LockFileCache.Instance.GetLockFile(LockFilePath);
WriteRuntimeConfig();
if (!string.IsNullOrEmpty(RuntimeConfigDevPath))
{
WriteDevRuntimeConfig();
}
return true;
}
private void WriteRuntimeConfig()
{
RuntimeConfig config = new RuntimeConfig();
config.RuntimeOptions = new RuntimeOptions();
AddFramework(config.RuntimeOptions);
AddUserRuntimeOptions(config.RuntimeOptions);
WriteToJsonFile(RuntimeConfigPath, config);
}
private void AddFramework(RuntimeOptions runtimeOptions)
{
// TODO: get this from the lock file once https://github.com/NuGet/Home/issues/2695 is fixed.
var packageName = "Microsoft.NETCore.App";
var redistExport = LockFile
.Libraries
.FirstOrDefault(e => e.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase));
if (redistExport != null)
{
RuntimeConfigFramework framework = new RuntimeConfigFramework();
framework.Name = redistExport.Name;
framework.Version = redistExport.Version.ToNormalizedString();
runtimeOptions.Framework = framework;
}
}
private void AddUserRuntimeOptions(RuntimeOptions runtimeOptions)
{
if (string.IsNullOrEmpty(UserRuntimeConfig) || !File.Exists(UserRuntimeConfig))
{
return;
}
var rawRuntimeOptions = File.ReadAllText(UserRuntimeConfig);
var runtimeOptionsFromProject = JObject.Parse(rawRuntimeOptions);
foreach (var runtimeOption in runtimeOptionsFromProject)
{
runtimeOptions.RawOptions.Add(runtimeOption.Key, runtimeOption.Value);
}
}
private void WriteDevRuntimeConfig()
{
RuntimeConfig devConfig = new RuntimeConfig();
devConfig.RuntimeOptions = new RuntimeOptions();
AddAdditionalProbingPaths(devConfig.RuntimeOptions);
WriteToJsonFile(RuntimeConfigDevPath, devConfig);
}
private void AddAdditionalProbingPaths(RuntimeOptions runtimeOptions)
{
foreach (var packageFolder in LockFile.PackageFolders)
{
if (runtimeOptions.AdditionalProbingPaths == null)
{
runtimeOptions.AdditionalProbingPaths = new List<string>();
}
// DotNetHost doesn't handle additional probing paths with a trailing slash
runtimeOptions.AdditionalProbingPaths.Add(EnsureNoTrailingDirectorySeparator(packageFolder.Path));
}
}
private static string EnsureNoTrailingDirectorySeparator(string path)
{
if (!string.IsNullOrEmpty(path))
{
char lastChar = path[path.Length - 1];
if (lastChar == Path.DirectorySeparatorChar)
{
path = path.Substring(0, path.Length - 1);
}
}
return path;
}
private static void WriteToJsonFile(string fileName, object value)
{
JsonSerializer serializer = new JsonSerializer();
serializer.ContractResolver = new CamelCasePropertyNamesContractResolver();
serializer.Formatting = Formatting.Indented;
serializer.DefaultValueHandling = DefaultValueHandling.Ignore;
using (JsonTextWriter writer = new JsonTextWriter(new StreamWriter(File.Create(fileName))))
{
serializer.Serialize(writer, value);
}
}
}
}

View file

@ -1,37 +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.
using System.Collections.Concurrent;
using NuGet.Common;
using NuGet.ProjectModel;
namespace Microsoft.DotNet.Core.Build.Tasks
{
internal class LockFileCache
{
public static LockFileCache Instance { get; } = new LockFileCache();
private ConcurrentDictionary<string, LockFile> _cache = new ConcurrentDictionary<string, LockFile>();
private LockFileCache()
{
}
public LockFile GetLockFile(string path)
{
LockFile result;
if (!_cache.TryGetValue(path, out result))
{
result = LoadLockFile(path);
_cache[path] = result;
}
return result;
}
private LockFile LoadLockFile(string path)
{
// TODO adapt task logger to Nuget Logger
return LockFileUtilities.GetLockFile(path, NullLogger.Instance);
}
}
}

View file

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e8e7d24b-4830-4662-80a8-255d6fe3b0be</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Core.Build.Tasks</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -1,3 +0,0 @@
using System.Reflection;
[assembly: AssemblyMetadataAttribute("Serviceable", "True")]

View file

@ -1,14 +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.
namespace Microsoft.DotNet.Core.Build.Tasks
{
internal class RuntimeConfig
{
public RuntimeOptions RuntimeOptions { get; set; }
public RuntimeConfig()
{
}
}
}

View file

@ -1,16 +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.
namespace Microsoft.DotNet.Core.Build.Tasks
{
internal class RuntimeConfigFramework
{
public string Name { get; set; }
public string Version { get; set; }
public RuntimeConfigFramework()
{
}
}
}

View file

@ -1,23 +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.
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.DotNet.Core.Build.Tasks
{
internal class RuntimeOptions
{
public RuntimeConfigFramework Framework { get; set; }
public List<string> AdditionalProbingPaths { get; set; }
[JsonExtensionData]
public IDictionary<string, JToken> RawOptions { get; } = new Dictionary<string, JToken>();
public RuntimeOptions()
{
}
}
}

View file

@ -1,33 +0,0 @@
{
"version": "1.0.0-featmsbuild-*",
"buildOptions": {
"keyFile": "../../tools/Key.snk",
"warningsAsErrors": true
},
"dependencies": {
"NuGet.ProjectModel": "3.5.0-rc1-1697",
"Microsoft.Extensions.DependencyModel": "1.0.1-beta-000914"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"Microsoft.Build.Utilities.v4.0": {
"type": "build"
},
"Microsoft.Build.Framework": {
"type": "build"
}
}
},
"netstandard1.6": {
"imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50"
],
"dependencies": {
"Microsoft.Build.Framework": "0.1.0-preview-00029-160805",
"Microsoft.Build.Tasks.Core": "0.1.0-preview-00029-160805",
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00029-160805"
}
}
}
}

View file

@ -1,38 +1,34 @@
// 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.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
namespace Microsoft.DotNet.Cli
{
/// <summary>
/// A class which encapsulates logic needed to forward arguments from the current process to another process
/// invoked with the dotnet.exe host.
/// </summary>
/// <summary>
/// A class which encapsulates logic needed to forward arguments from the current process to another process
/// invoked with the dotnet.exe host.
/// </summary>
public class ForwardingApp
{
private const string s_hostExe = "dotnet";
private readonly string _forwardApplicationPath;
private readonly string[] _argsToForward;
private readonly IEnumerable<string> _argsToForward;
private readonly string _depsFile;
private readonly string _runtimeConfig;
private readonly string _additionalProbingPath;
private readonly Dictionary<string, string> _environmentVariables;
private Dictionary<string, string> _environmentVariables;
private readonly string[] _allArgs;
public ForwardingApp(
string forwardApplicationPath,
string[] argsToForward,
string depsFile = null,
string forwardApplicationPath,
IEnumerable<string> argsToForward,
string depsFile = null,
string runtimeConfig = null,
string additionalProbingPath = null,
Dictionary<string, string> environmentVariables = null)
@ -43,7 +39,7 @@ namespace Microsoft.DotNet.Cli
_runtimeConfig = runtimeConfig;
_additionalProbingPath = additionalProbingPath;
_environmentVariables = environmentVariables;
var allArgs = new List<string>();
allArgs.Add("exec");
@ -99,6 +95,15 @@ namespace Microsoft.DotNet.Cli
return process.ExitCode;
}
public ForwardingApp WithEnvironmentVariable(string name, string value)
{
_environmentVariables = _environmentVariables ?? new Dictionary<string, string>();
_environmentVariables.Add(name, value);
return this;
}
private string GetHostExeName()
{
return $"{s_hostExe}{FileNameSuffixes.CurrentPlatform.Exe}";

View file

@ -6,8 +6,6 @@ using Microsoft.DotNet.PlatformAbstractions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Cli
{
@ -35,18 +33,9 @@ namespace Microsoft.DotNet.Cli
{
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
{ "DotnetHostPath", GetHostPath() },
{ "BaseNuGetRuntimeIdentifier", GetCurrentBaseRid() },
{ "Platform", GetCurrentArchitecture() },
{ "PlatformTarget", GetCurrentArchitecture() }
};
}
private static string GetCurrentBaseRid()
{
return RuntimeEnvironment.GetRuntimeIdentifier()
.Replace("-" + RuntimeEnvironment.RuntimeArchitecture, "");
}
private static string GetHostPath()
{
return new Muxer().MuxerPath;
@ -58,10 +47,5 @@ namespace Microsoft.DotNet.Cli
AppContext.BaseDirectory,
s_msbuildExeName);
}
private static string GetCurrentArchitecture()
{
return RuntimeEnvironment.RuntimeArchitecture;
}
}
}

View file

@ -3,14 +3,12 @@
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.DotNet.Core.Sdk": "1.0.0-alpha-20160811-3",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
},
"runtimes": {
"$currentruntime$": {}
}
}

View file

@ -98,15 +98,6 @@ namespace Microsoft.DotNet.Tools.New
File.Move(
Path.Combine(projectDirectory, "project.json.template"),
projectJsonFile);
string originalProjectJsonText = File.ReadAllText(projectJsonFile);
string replacedProjectJsonText = originalProjectJsonText
.Replace("$currentruntime$", RuntimeEnvironment.GetRuntimeIdentifier());
if (replacedProjectJsonText != originalProjectJsonText)
{
File.WriteAllText(projectJsonFile, replacedProjectJsonText);
}
}
private static void ReplaceFileTemplateNames(string projectDirectory)

View file

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.Tools.Restore
{
@ -19,11 +16,18 @@ namespace Microsoft.DotNet.Tools.Restore
}
prefixArgs.Add("restore");
var result = new NuGetForwardingApp(Enumerable.Concat(
prefixArgs,
args).ToArray()).Execute();
var nugetApp = new NuGetForwardingApp(Enumerable.Concat(prefixArgs, args));
return result;
// setting NUGET_XPROJ_WRITE_TARGETS will tell nuget restore to install .props and .targets files
// coming from NuGet packages
const string nugetXProjWriteTargets = "NUGET_XPROJ_WRITE_TARGETS";
bool setXProjWriteTargets = Environment.GetEnvironmentVariable(nugetXProjWriteTargets) == null;
if (setXProjWriteTargets)
{
nugetApp.WithEnvironmentVariable(nugetXProjWriteTargets, "true");
}
return nugetApp.Execute();
}
}
}

View file

@ -1,14 +1,10 @@
// 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.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.DotNet.Cli;
namespace Microsoft.DotNet.Tools.Restore
{
@ -17,7 +13,7 @@ namespace Microsoft.DotNet.Tools.Restore
private const string s_nugetExeName = "NuGet.CommandLine.XPlat.dll";
private readonly ForwardingApp _forwardingApp;
public NuGetForwardingApp(string[] argsToForward)
public NuGetForwardingApp(IEnumerable<string> argsToForward)
{
_forwardingApp = new ForwardingApp(
GetNuGetExePath(),
@ -29,6 +25,13 @@ namespace Microsoft.DotNet.Tools.Restore
return _forwardingApp.Execute();
}
public NuGetForwardingApp WithEnvironmentVariable(string name, string value)
{
_forwardingApp.WithEnvironmentVariable(name, value);
return this;
}
private static string GetNuGetExePath()
{
return Path.Combine(

View file

@ -51,6 +51,7 @@
},
"System.Diagnostics.TraceSource": "4.0.0",
"System.Diagnostics.TextWriterTraceListener": "4.0.0",
"System.Resources.Writer": "4.0.0",
"System.Runtime.Serialization.Primitives": "4.1.1",
"System.Private.DataContractSerialization": "4.1.1",
"System.Text.RegularExpressions": "4.1.0",
@ -59,13 +60,9 @@
"exclude": "compile"
},
"Microsoft.Build": "0.1.0-preview-00029-160805",
"Microsoft.Build.Framework": "0.1.0-preview-00029-160805",
"Microsoft.DotNet.Core.Build.Tasks": {
"target": "project"
},
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000914"
},
"frameworks": {

View file

@ -1,71 +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.
using System.IO;
using FluentAssertions.Json;
using Microsoft.Extensions.DependencyModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NuGet.Common;
using NuGet.Frameworks;
using NuGet.ProjectModel;
using Xunit;
namespace Microsoft.DotNet.Core.Build.Tasks.Tests
{
public class GivenADependencyContextBuilder
{
/// <summary>
/// Tests that DependencyContextBuilder generates DependencyContexts correctly.
/// </summary>
[Theory]
[InlineData("dotnet.new", "1.0.0")]
[InlineData("simple.dependencies", "1.0.0")]
public void ItBuildsDependencyContextsFromProjectLockFiles(string mainProjectName, string mainProjectVersion)
{
LockFile lockFile = LockFileUtilities.GetLockFile($"{mainProjectName}.project.lock.json", NullLogger.Instance);
DependencyContext dependencyContext = new DependencyContextBuilder().Build(
mainProjectName,
mainProjectVersion,
compilerOptions: null,
lockFile: lockFile,
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10,
runtime: null);
JObject result = Save(dependencyContext);
JObject baseline = ReadJson($"{mainProjectName}.deps.json");
baseline
.Should()
.BeEquivalentTo(result);
}
private static JObject ReadJson(string path)
{
using (JsonTextReader jsonReader = new JsonTextReader(File.OpenText(path)))
{
JsonSerializer serializer = new JsonSerializer();
return serializer.Deserialize<JObject>(jsonReader);
}
}
private JObject Save(DependencyContext dependencyContext)
{
using (var memoryStream = new MemoryStream())
{
new DependencyContextWriter().Write(dependencyContext, memoryStream);
using (var readStream = new MemoryStream(memoryStream.ToArray()))
{
using (var textReader = new StreamReader(readStream))
{
using (var reader = new JsonTextReader(textReader))
{
return JObject.Load(reader);
}
}
}
}
}
}
}

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>edd6c92d-0a58-4fcb-a0e9-9d0ffc045177</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Core.Build.Tasks.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -1,23 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v1.0",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v1.0": {
"dotnet.new/1.0.0": {
"runtime": {
"dotnet.new.dll": {}
}
}
}
},
"libraries": {
"dotnet.new/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View file

@ -1,31 +0,0 @@
{
"version": "1.0.0-*",
"buildOptions": {
"keyFile": "../../tools/Key.snk"
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.DotNet.Core.Build.Tasks": {
"target": "project"
},
"Microsoft.DotNet.InternalAbstractions": {
"target": "project"
},
"xunit": "2.2.0-beta3-build3330",
"FluentAssertions.Json": "4.12.0",
"dotnet-test-xunit": "1.0.0-rc2-318883-21"
},
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.0": {
"imports": [
"netstandardapp1.5",
"dotnet5.4",
"portable-net451+win8"
]
}
}
}

View file

@ -1,60 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v1.0",
"signature": "a813617eb7d3bb5d69fa51d48f64bc6455d8ca5f"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v1.0": {
"simple.dependencies/1.0.0": {
"dependencies": {
"System.Collections.NonGeneric": "4.0.1",
"Newtonsoft.Json": "9.0.1"
},
"runtime": {
"simple.dependencies.dll": {}
}
},
"newtonsoft.json/9.0.1": {
"dependencies": {
"System.Runtime.Serialization.Primitives": "4.1.1"
},
"runtime": {
"lib/netstandard1.0/Newtonsoft.Json.dll": {}
}
},
"system.collections.nongeneric/4.0.1": {
"runtime": {
"lib/netstandard1.3/System.Collections.NonGeneric.dll": {}
}
},
"system.runtime.serialization.primitives/4.1.1": {
"runtime": {
"lib/netstandard1.3/System.Runtime.Serialization.Primitives.dll": {}
}
}
}
},
"libraries": {
"simple.dependencies/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"newtonsoft.json/9.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw=="
},
"system.collections.nongeneric/4.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-hMxFT2RhhlffyCdKLDXjx8WEC5JfCvNozAZxCablAuFRH74SCV4AgzE8yJCh/73bFnEoZgJ9MJmkjQ0dJmnKqA=="
},
"system.runtime.serialization.primitives/4.1.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HZ6Du5QrTG8MNJbf4e4qMO3JRAkIboGT5Fk804uZtg3Gq516S7hAqTm2UZKUHa7/6HUGdVy3AqMQKbns06G/cg=="
}
}
}