Merge pull request #3937 from eerhardt/msbuild-runtimeconfig

Generate runtimeconfig.json and runtimeconfig.dev.json from MSBuild
This commit is contained in:
Eric Erhardt 2016-07-26 23:19:47 -05:00 committed by GitHub
commit 0d7c722189
43 changed files with 517 additions and 152 deletions

View file

@ -28,8 +28,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.Depend
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "EndToEnd", "test\EndToEnd\EndToEnd.xproj", "{65741CB1-8AEE-4C66-8198-10A7EA0E4258}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Test.Utilities", "test\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Test.Utilities.xproj", "{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestProjects", "TestProjects", "{713CBFBB-5392-438D-B766-A9A585EF1BB8}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet", "src\dotnet\dotnet.xproj", "{60CF7E6C-D6C8-439D-B7B7-D8A27E29BE2C}"
@ -149,6 +147,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{FF498306-2
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -273,22 +273,6 @@ Global
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.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
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Debug|x64.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|Any CPU.Build.0 = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|x64.ActiveCfg = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|x64.Build.0 = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{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
{60CF7E6C-D6C8-439D-B7B7-D8A27E29BE2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60CF7E6C-D6C8-439D-B7B7-D8A27E29BE2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60CF7E6C-D6C8-439D-B7B7-D8A27E29BE2C}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -913,6 +897,22 @@ Global
{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
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Debug|x64.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|Any CPU.Build.0 = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|x64.ActiveCfg = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.Release|x64.Build.0 = Release|Any CPU
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -925,7 +925,6 @@ Global
{DCDFE282-03DE-4DBC-B90C-CC3CE3EC8162} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{688870C8-9843-4F9E-8576-D39290AD0F25} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{65741CB1-8AEE-4C66-8198-10A7EA0E4258} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{E4F46EAB-B5A5-4E60-9B9D-40A1FADBF45C} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{713CBFBB-5392-438D-B766-A9A585EF1BB8} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{60CF7E6C-D6C8-439D-B7B7-D8A27E29BE2C} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{833FFEE1-7EED-4F51-8DFD-946D48833333} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
@ -973,5 +972,6 @@ Global
{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}
EndGlobalSection
EndGlobal

View file

@ -57,5 +57,9 @@
"ClassLibrary2",
"ClassLibrary3"
]
},
"packageFolders": {
"/foo/packages": {},
"/foo/packages2": {}
}
}

View file

@ -91,6 +91,14 @@
<Copy SourceFiles="@(SharedFramework)"
DestinationFiles="@(SharedFramework->'$(StageDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />
<!-- TEMP HACK: need to restore with the current stage, until we get a Stage0 with the new NuGet build -->
<ItemGroup>
<SrcLockFiles Include="$(SrcDirectory)/**/project.lock.json" />
</ItemGroup>
<Delete Files="@(SrcLockFiles)" />
<DotNetRestore ToolPath="%(Stage.DotnetDir)"
WorkingDirectory="$(SrcDirectory)" />
<!-- Publish DotNet -->
<DotNetPublish ToolPath="%(Stage.DotnetDir)"
NativeSubdirectory="True"

View file

@ -23,6 +23,11 @@
<Message Text="Publishing Archiver" />
<!-- TEMP HACK: need to restore with the current stage, until we get a Stage0 with the new NuGet build -->
<Delete Files="$(RepoRoot)/tools/Archiver/project.lock.json" />
<DotNetRestore ToolPath="$(Stage2Directory)"
WorkingDirectory="$(RepoRoot)/tools/Archiver" />
<DotNetPublish ToolPath="$(Stage2Directory)"
WorkingDirectory="$(RepoRoot)/tools/Archiver"
Output="$(ToolsOutputDirectory)"

View file

@ -20,7 +20,7 @@
"System.Runtime.Serialization.Primitives": "4.1.1",
"System.Xml.XmlSerializer": "4.0.11",
"WindowsAzure.Storage": "6.2.2-preview",
"NuGet.CommandLine.XPlat": "3.5.0-beta2-1484",
"NuGet.CommandLine.XPlat": "3.5.0-rc1-1653",
"Microsoft.Build.Framework": "0.1.0-preview-00024-160610",
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00024-160610"
},

View file

@ -55,7 +55,7 @@ namespace Microsoft.DotNet.Cli.Utils
return Path.Combine(
GetBaseToolPath(packageId),
version.ToNormalizedString(),
version.ToNormalizedString().ToLowerInvariant(),
framework.GetShortFolderName(),
"project.lock.json");
}
@ -65,7 +65,7 @@ namespace Microsoft.DotNet.Cli.Utils
return Path.Combine(
_packagesDirectory,
".tools",
packageId);
packageId.ToLowerInvariant());
}
private IEnumerable<NuGetVersion> GetAvailableToolVersions(string packageId)

View file

@ -56,6 +56,20 @@ namespace Microsoft.DotNet.Tools.Common
return path + trailingCharacter;
}
public static string EnsureNoTrailingSlash(string path)
{
if (!string.IsNullOrEmpty(path))
{
char lastChar = path[path.Length - 1];
if (lastChar == Path.DirectorySeparatorChar || lastChar == '/')
{
path = path.Substring(0, path.Length - 1);
}
}
return path;
}
public static void EnsureParentDirectory(string filePath)
{
string directory = Path.GetDirectoryName(filePath);

View file

@ -8,10 +8,10 @@
"Microsoft.DotNet.ProjectModel": {
"target": "project"
},
"NuGet.Versioning": "3.5.0-beta2-1484",
"NuGet.Packaging": "3.5.0-beta2-1484",
"NuGet.Frameworks": "3.5.0-beta2-1484",
"NuGet.ProjectModel": "3.5.0-beta2-1484"
"NuGet.Versioning": "3.5.0-rc1-1653",
"NuGet.Packaging": "3.5.0-rc1-1653",
"NuGet.Frameworks": "3.5.0-rc1-1653",
"NuGet.ProjectModel": "3.5.0-rc1-1653"
},
"frameworks": {
"net451": {

View file

@ -50,10 +50,10 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
_compilerOptions = _context.ProjectFile.GetCompilerOptions(_context.TargetFramework, configuration);
}
public void MakeCompilationOutputRunnable()
public void MakeCompilationOutputRunnable(bool skipRuntimeConfig = false)
{
CopyContentFiles();
ExportRuntimeAssets();
ExportRuntimeAssets(skipRuntimeConfig);
}
private void VerifyCoreClrPresenceInPackageGraph()
@ -67,13 +67,13 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
.Any();
// coreclr should be present for standalone apps
if (! isCoreClrPresent)
if (!isCoreClrPresent)
{
throw new InvalidOperationException("Expected coreclr library not found in package graph. Please try running dotnet restore again.");
}
}
private void ExportRuntimeAssets()
private void ExportRuntimeAssets(bool skipRuntimeConfig)
{
if (_context.TargetFramework.IsDesktop())
{
@ -81,7 +81,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
}
else
{
MakeCompilationOutputRunnableForCoreCLR();
MakeCompilationOutputRunnableForCoreCLR(skipRuntimeConfig);
}
}
@ -93,9 +93,9 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
GenerateBindingRedirects(_exporter);
}
private void MakeCompilationOutputRunnableForCoreCLR()
{
WriteDepsFileAndCopyProjectDependencies(_exporter);
private void MakeCompilationOutputRunnableForCoreCLR(bool skipRuntimeConfig)
{
WriteDepsFileAndCopyProjectDependencies(_exporter, skipRuntimeConfig);
var isRunnable = _compilerOptions.EmitEntryPoint ?? _context.ProjectFile.OverrideIsRunnable;
@ -155,14 +155,14 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
}
}
private void WriteDepsFileAndCopyProjectDependencies(LibraryExporter exporter)
private void WriteDepsFileAndCopyProjectDependencies(LibraryExporter exporter, bool skipRuntimeConfig)
{
var exports = exporter.GetAllExports().ToList();
var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name);
var platformExclusionList = _context.GetPlatformExclusionList(exportsLookup);
var filteredExports = exports.FilterExports(platformExclusionList);
WriteConfigurationFiles(exports, filteredExports, exports, includeDevConfig: true);
WriteConfigurationFiles(exports, filteredExports, exports, includeDevConfig: true, skipRuntimeConfig: skipRuntimeConfig);
var projectExports = exporter.GetAllProjectTypeDependencies();
CopyAssemblies(projectExports);
@ -176,10 +176,11 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
IEnumerable<LibraryExport> allExports,
IEnumerable<LibraryExport> depsRuntimeExports,
IEnumerable<LibraryExport> depsCompilationExports,
bool includeDevConfig)
bool includeDevConfig,
bool skipRuntimeConfig = false)
{
WriteDeps(depsRuntimeExports, depsCompilationExports);
if (_context.ProjectFile.HasRuntimeOutput(_configuration))
if (_context.ProjectFile.HasRuntimeOutput(_configuration) && !skipRuntimeConfig)
{
WriteRuntimeConfig(allExports);
if (includeDevConfig)
@ -275,8 +276,17 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
private void AddAdditionalProbingPaths(JObject runtimeOptions)
{
var additionalProbingPaths = new JArray(_context.PackagesDirectory);
runtimeOptions.Add("additionalProbingPaths", additionalProbingPaths);
if (_context.LockFile != null)
{
var additionalProbingPaths = new JArray();
foreach (var packageFolder in _context.LockFile.PackageFolders)
{
// DotNetHost doesn't handle additional probing paths with a trailing slash
additionalProbingPaths.Add(PathUtility.EnsureNoTrailingSlash(packageFolder.Path));
}
runtimeOptions.Add("additionalProbingPaths", additionalProbingPaths);
}
}
public void WriteDeps(IEnumerable<LibraryExport> runtimeExports, IEnumerable<LibraryExport> compilationExports)

View file

@ -4,7 +4,7 @@
using System.IO;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.Extensions.EnvironmentAbstractions;
using Microsoft.DotNet.ProjectModel.Resolution;
using NuGet.Configuration;
namespace Microsoft.DotNet.Configurer
{
@ -23,7 +23,7 @@ namespace Microsoft.DotNet.Configurer
{
if (string.IsNullOrEmpty(_nugetCachePath))
{
_nugetCachePath = PackageDependencyProvider.ResolvePackagesPath(null, null);
_nugetCachePath = NuGetPathContext.Create(new NullSettings()).UserPackageFolder;
}
return _nugetCachePath;

View file

@ -0,0 +1,141 @@
// 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 Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using NuGet.ProjectModel;
namespace Microsoft.DotNet.Cli.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 RuntimeOutputPath { get; set; }
[Required]
public string OutputName { get; set; }
[Required]
public string LockFilePath { get; set; }
public string RawRuntimeOptions { get; set; }
public bool IncludeDevConfig { get; set; }
private LockFile LockFile { get; set; }
public override bool Execute()
{
LockFile = LockFileCache.Instance.GetLockFile(LockFilePath);
WriteRuntimeConfig();
if (IncludeDevConfig)
{
WriteDevRuntimeConfig();
}
return true;
}
private void WriteRuntimeConfig()
{
RuntimeConfig config = new RuntimeConfig();
config.RuntimeOptions = new RuntimeOptions();
AddFramework(config.RuntimeOptions);
AddRuntimeOptions(config.RuntimeOptions);
var runtimeConfigJsonFile =
Path.Combine(RuntimeOutputPath, OutputName + FileNameSuffixes.RuntimeConfigJson);
WriteToJsonFile(runtimeConfigJsonFile, 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 AddRuntimeOptions(RuntimeOptions runtimeOptions)
{
if (string.IsNullOrEmpty(RawRuntimeOptions))
{
return;
}
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);
var runtimeConfigDevJsonFile =
Path.Combine(RuntimeOutputPath, OutputName + FileNameSuffixes.RuntimeConfigDevJson);
WriteToJsonFile(runtimeConfigDevJsonFile, 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(PathUtility.EnsureNoTrailingSlash(packageFolder.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

@ -0,0 +1,37 @@
// 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.Cli.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

@ -63,7 +63,7 @@ namespace Microsoft.DotNet.Cli.Tasks
LibraryExporter libraryExporter = projectContext.CreateExporter(Configuration, buildBasePath);
Executable executable = new Executable(projectContext, outputPaths, libraryExporter, Configuration);
executable.MakeCompilationOutputRunnable();
executable.MakeCompilationOutputRunnable(skipRuntimeConfig: true);
}
return true;

View file

@ -0,0 +1,14 @@
// 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.Cli.Tasks
{
internal class RuntimeConfig
{
public RuntimeOptions RuntimeOptions { get; set; }
public RuntimeConfig()
{
}
}
}

View file

@ -0,0 +1,16 @@
// 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.Cli.Tasks
{
internal class RuntimeConfigFramework
{
public string Name { get; set; }
public string Version { get; set; }
public RuntimeConfigFramework()
{
}
}
}

View file

@ -0,0 +1,23 @@
// 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.Cli.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

@ -20,6 +20,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
public IList<LockFileProjectLibrary> ProjectLibraries { get; set; } = new List<LockFileProjectLibrary>();
public IList<LockFileTarget> Targets { get; set; } = new List<LockFileTarget>();
public ExportFile ExportFile { get; set; }
public IList<LockFilePackageFolder> PackageFolders { get; set; } = new List<LockFilePackageFolder>();
public LockFile(string lockFilePath)
{

View file

@ -0,0 +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.
namespace Microsoft.DotNet.ProjectModel.Graph
{
public class LockFilePackageFolder
{
public string Path { get; set; }
}
}

View file

@ -117,6 +117,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
lockFile.Targets = ReadObject(cursor.Value<JObject>("targets"), ReadTarget);
lockFile.ProjectFileDependencyGroups = ReadObject(cursor.Value<JObject>("projectFileDependencyGroups"), ReadProjectFileDependencyGroup);
ReadLibrary(cursor.Value<JObject>("libraries"), lockFile);
lockFile.PackageFolders = ReadObject(cursor.Value<JObject>("packageFolders"), ReadPackageFolder);
return lockFile;
}
@ -194,6 +195,20 @@ namespace Microsoft.DotNet.ProjectModel.Graph
return target;
}
private LockFilePackageFolder ReadPackageFolder(string property, JToken json)
{
var jobject = json as JObject;
if (jobject == null)
{
throw FileFormatException.Create("The value type is not an object.", json);
}
var packageFolder = new LockFilePackageFolder();
packageFolder.Path = property;
return packageFolder;
}
private LockFileTargetLibrary ReadTargetLibrary(string property, JToken json)
{
var jobject = json as JObject;

View file

@ -3,14 +3,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Resolution;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Frameworks;
namespace Microsoft.DotNet.ProjectModel
@ -210,7 +210,6 @@ namespace Microsoft.DotNet.ProjectModel
}
RootDirectory = globalSettings?.DirectoryPath ?? RootDirectory;
PackagesDirectory = PackagesDirectory ?? PackageDependencyProvider.ResolvePackagesPath(RootDirectory, globalSettings);
FrameworkReferenceResolver frameworkReferenceResolver;
if (string.IsNullOrEmpty(ReferenceAssembliesPath))
@ -228,6 +227,17 @@ namespace Microsoft.DotNet.ProjectModel
ReadLockFile(diagnostics);
// some callers only give ProjectContextBuilder a LockFile
ProjectDirectory = ProjectDirectory ?? TryGetProjectDirectoryFromLockFile();
INuGetPathContext nugetPathContext = null;
if (ProjectDirectory != null)
{
nugetPathContext = NuGetPathContext.Create(ProjectDirectory);
}
PackagesDirectory = PackagesDirectory ?? nugetPathContext?.UserPackageFolder;
var validLockFile = true;
string lockFileValidationMessage = null;
@ -271,7 +281,7 @@ namespace Microsoft.DotNet.ProjectModel
target = SelectTarget(LockFile, isPortable);
if (target != null)
{
var nugetPackageResolver = new PackageDependencyProvider(PackagesDirectory, frameworkReferenceResolver);
var nugetPackageResolver = new PackageDependencyProvider(nugetPathContext, frameworkReferenceResolver);
var msbuildProjectResolver = new MSBuildDependencyProvider(Project, ProjectResolver);
ScanLibraries(target, lockFileLookup, libraries, msbuildProjectResolver, nugetPackageResolver, projectResolver);
@ -377,6 +387,18 @@ namespace Microsoft.DotNet.ProjectModel
diagnostics);
}
private string TryGetProjectDirectoryFromLockFile()
{
string result = null;
if (LockFile != null && !string.IsNullOrEmpty(LockFile.LockFilePath))
{
result = Path.GetDirectoryName(LockFile.LockFilePath);
}
return result;
}
private void ReadLockFile(ICollection<DiagnosticMessage> diagnostics)
{
try

View file

@ -8,6 +8,7 @@ using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using Microsoft.DotNet.ProjectModel.Graph;
using NuGet.Common;
using NuGet.Frameworks;
using NuGet.Packaging;
@ -15,12 +16,16 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
{
public class PackageDependencyProvider
{
private readonly VersionFolderPathResolver _packagePathResolver;
private readonly FallbackPackagePathResolver _packagePathResolver;
private readonly FrameworkReferenceResolver _frameworkReferenceResolver;
public PackageDependencyProvider(string packagesPath, FrameworkReferenceResolver frameworkReferenceResolver)
public PackageDependencyProvider(INuGetPathContext nugetPathContext, FrameworkReferenceResolver frameworkReferenceResolver)
{
_packagePathResolver = new VersionFolderPathResolver(packagesPath);
if (nugetPathContext != null)
{
_packagePathResolver = new FallbackPackagePathResolver(nugetPathContext);
}
_frameworkReferenceResolver = frameworkReferenceResolver;
}
@ -40,8 +45,8 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
var dependencies = new List<LibraryRange>(targetLibrary.Dependencies.Count + targetLibrary.FrameworkAssemblies.Count);
PopulateDependencies(dependencies, targetLibrary, targetFramework);
var path = _packagePathResolver.GetInstallPath(package.Name, package.Version);
var exists = Directory.Exists(path);
var path = _packagePathResolver?.GetPackageDirectory(package.Name, package.Version);
bool exists = path != null;
if (exists)
{
@ -155,35 +160,5 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
{
return string.Equals(Path.GetFileName(path), "_._", StringComparison.Ordinal);
}
public static string ResolvePackagesPath(string rootDirectory, GlobalSettings settings)
{
// Order
// 1. global.json { "packages": "..." }
// 2. EnvironmentNames.PackagesStore environment variable
// 3. NuGet.config repositoryPath (maybe)?
// 4. {DefaultLocalRuntimeHomeDir}\packages
if (!string.IsNullOrEmpty(settings?.PackagesPath))
{
return Path.Combine(rootDirectory, settings.PackagesPath);
}
var runtimePackages = Environment.GetEnvironmentVariable(EnvironmentNames.PackagesStore);
if (!string.IsNullOrEmpty(runtimePackages))
{
return runtimePackages;
}
var profileDirectory = Environment.GetEnvironmentVariable("USERPROFILE");
if (string.IsNullOrEmpty(profileDirectory))
{
profileDirectory = Environment.GetEnvironmentVariable("HOME");
}
return Path.Combine(profileDirectory, ".nuget", "packages");
}
}
}

View file

@ -9,8 +9,9 @@
"target": "project"
},
"Newtonsoft.Json": "9.0.1",
"NuGet.Packaging": "3.5.0-beta2-1484",
"NuGet.RuntimeModel": "3.5.0-beta2-1484",
"NuGet.Configuration": "3.5.0-rc1-1653",
"NuGet.Packaging": "3.5.0-rc1-1653",
"NuGet.RuntimeModel": "3.5.0-rc1-1653",
"System.Reflection.Metadata": "1.3.0"
},
"frameworks": {

View file

@ -117,7 +117,9 @@ namespace Microsoft.Extensions.DependencyModel
{
return new JObject(
libraries.Select(library =>
new JProperty(library.Name + DependencyContextStrings.VersionSeperator + library.Version, WriteTargetLibrary(library))));
// TODO: remove the hack of calling "ToLowerInvariant()" on library Name and Version once
// https://github.com/dotnet/core-setup/pull/64/ is merged and taken into the CLI
new JProperty(library.Name.ToLowerInvariant() + DependencyContextStrings.VersionSeperator + library.Version.ToLowerInvariant(), WriteTargetLibrary(library))));
}
private JObject WritePortableTarget(IReadOnlyList<RuntimeLibrary> runtimeLibraries, IReadOnlyList<CompilationLibrary> compilationLibraries)
@ -145,7 +147,9 @@ namespace Microsoft.Extensions.DependencyModel
var library = (Library)compilationLibrary ?? (Library)runtimeLibrary;
targetObject.Add(
new JProperty(library.Name + DependencyContextStrings.VersionSeperator + library.Version,
// TODO: remove the hack of calling "ToLowerInvariant()" on library Name and Version once
// https://github.com/dotnet/core-setup/pull/64/ is merged and taken into the CLI
new JProperty(library.Name.ToLowerInvariant() + DependencyContextStrings.VersionSeperator + library.Version.ToLowerInvariant(),
WritePortableTargetLibrary(runtimeLibrary, compilationLibrary)
)
);
@ -313,7 +317,9 @@ namespace Microsoft.Extensions.DependencyModel
{
var allLibraries =
context.RuntimeLibraries.Cast<Library>().Concat(context.CompileLibraries)
.GroupBy(library => library.Name + DependencyContextStrings.VersionSeperator + library.Version);
// TODO: remove the hack of calling "ToLowerInvariant()" on library Name and Version once
// https://github.com/dotnet/core-setup/pull/64/ is merged and taken into the CLI
.GroupBy(library => library.Name.ToLowerInvariant() + DependencyContextStrings.VersionSeperator + library.Version.ToLowerInvariant());
return new JObject(allLibraries.Select(libraries => new JProperty(libraries.Key, WriteLibrary(libraries.First()))));
}

View file

@ -53,7 +53,8 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
if (ResolverUtils.TryResolvePackagePath(_fileSystem, library, _packageCacheDirectory, out packagePath))
{
var hashAlgorithm = library.Hash.Substring(0, hashSplitterPos);
var cacheHashPath = Path.Combine(packagePath, $"{library.Name}.{library.Version}.nupkg.{hashAlgorithm}");
var cacheHashFileName = $"{library.Name.ToLowerInvariant()}.{library.Version.ToLowerInvariant()}.nupkg.{hashAlgorithm}";
var cacheHashPath = Path.Combine(packagePath, cacheHashFileName);
if (_fileSystem.File.Exists(cacheHashPath) &&
_fileSystem.File.ReadAllText(cacheHashPath) == library.Hash.Substring(hashSplitterPos + 1))

View file

@ -12,7 +12,11 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
{
internal static bool TryResolvePackagePath(IFileSystem fileSystem, CompilationLibrary library, string basePath, out string packagePath)
{
packagePath = Path.Combine(basePath, library.Name, library.Version);
packagePath = Path.Combine(
basePath,
library.Name.ToLowerInvariant(),
library.Version.ToLowerInvariant());
if (fileSystem.Directory.Exists(packagePath))
{
return true;

View file

@ -13,6 +13,7 @@ using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Resolution;
using NuGet.Configuration;
namespace Microsoft.DotNet.Tools.Compiler.Fsc
{
@ -296,7 +297,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
private static FscCommandSpec ResolveFsc(List<string> fscArgs, string temp)
{
var nugetPackagesRoot = PackageDependencyProvider.ResolvePackagesPath(null, null);
var nugetPackagesRoot = NuGetPathContext.Create(Directory.GetCurrentDirectory())?.UserPackageFolder;
var depsFile = Path.Combine(AppContext.BaseDirectory, "dotnet-compile-fsc" + FileNameSuffixes.DepsJson);
var depsJsonCommandResolver = new DepsJsonCommandResolver(nugetPackagesRoot);

View file

@ -39,7 +39,6 @@
<!-- Default settings for .NET Core build logic -->
<PropertyGroup>
<GenerateDependencyFile Condition=" '$(GenerateDependencyFile)' == '' ">true</GenerateDependencyFile>
<GenerateRuntimeConfigurationFiles Condition=" '$(GenerateRuntimeConfigurationFiles)' == '' ">true</GenerateRuntimeConfigurationFiles>
<!-- 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>-->

View file

@ -17,7 +17,12 @@
<_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
</PropertyGroup>
<PropertyGroup>
<GenerateRuntimeConfigurationFiles Condition=" '$(GenerateRuntimeConfigurationFiles)' == '' and '$(OutputType)' == 'exe' ">true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<UsingTask TaskName="GenerateRuntimeConfigurationFiles" AssemblyFile="$(MicrosoftDotNetCoreBuildTasksDirectory)Microsoft.DotNet.Core.Build.Tasks.dll" />
<UsingTask TaskName="MakeNetCoreRunnable" AssemblyFile="$(MicrosoftDotNetCoreBuildTasksDirectory)Microsoft.DotNet.Core.Build.Tasks.dll" />
<PropertyGroup>
@ -47,8 +52,15 @@
<Target Name="GenerateRuntimeConfigurationFiles"
Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'">
<!-- TODO: Split up MakeNetCoreRunnable and implement this target-->
<!-- Putting this here to show the structure that we should use in production -->
<!--
TODO: Get RawRuntimeOptions from where it lives in the MSBuild world
-->
<GenerateRuntimeConfigurationFiles LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
RuntimeOutputPath="$(TargetDir)"
OutputName="$(AssemblyName)"
RawRuntimeOptions=""
IncludeDevConfig="true" />
</Target>
<!--

View file

@ -9,6 +9,7 @@ using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Common;
using NuGet.Frameworks;
namespace Microsoft.DotNet.Tools.Run
@ -145,13 +146,17 @@ namespace Microsoft.DotNet.Tools.Run
}
List<string> hostArgs = new List<string>();
if (!_context.TargetFramework.IsDesktop())
if (!_context.TargetFramework.IsDesktop() && _context.LockFile != null)
{
// Add Nuget Packages Probing Path
var nugetPackagesRoot = _context.PackagesDirectory;
var probingPathArg = "--additionalprobingpath";
hostArgs.Insert(0, nugetPackagesRoot);
hostArgs.Insert(0, probingPathArg);
// Add Nuget Packages Probing Paths
const string probingPathArg = "--additionalprobingpath";
foreach (var packageFolder in _context.LockFile.PackageFolders)
{
// DotNetHost doesn't handle additional probing paths with a trailing slash
hostArgs.Insert(0, PathUtility.EnsureNoTrailingSlash(packageFolder.Path));
hostArgs.Insert(0, probingPathArg);
}
}
// Now launch the output and give it the results

View file

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.Tools.Test;
using Microsoft.Extensions.Testing.Abstractions;
using NuGet.Protocol.Core.v3;
namespace Microsoft.DotNet.Cli.Tools.Test
{

View file

@ -34,10 +34,10 @@
},
"dependencies": {
"NuGet.Commands": {
"version": "3.5.0-beta2-1484",
"version": "3.5.0-rc1-1653",
"exclude": "compile"
},
"NuGet.CommandLine.XPlat": "3.5.0-beta2-1484",
"NuGet.CommandLine.XPlat": "3.5.0-rc1-1653",
"Newtonsoft.Json": "9.0.1",
"System.Text.Encoding.CodePages": "4.0.1",
"System.Diagnostics.FileVersionInfo": "4.0.0",
@ -77,11 +77,11 @@
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00024-160610",
"Microsoft.Build.Targets": "0.1.0-preview-00024-160610",
"Microsoft.Build": "0.1.0-preview-00024-160610",
"Microsoft.Net.Compilers.NetCore": "1.3.0",
"Microsoft.Net.Compilers.netcore": "1.3.0",
"Microsoft.Net.Compilers.Targets.NetCore": "0.1.5-dev",
"Microsoft.Cci": "4.0.0-rc3-24128-00",
"Microsoft.Composition": "1.0.30",
"Microsoft.NuGet.Build.Tasks": "1.0.0-alpha-000001",
"Microsoft.NuGet.Build.Tasks": "1.0.0-alpha-000002",
"Microsoft.DotNet.Core.Build.Tasks": {
"target": "project"

View file

@ -167,7 +167,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var command = factory.Create("dotnet-tool-with-output-name", null);
command.CommandArgs.Should().Contain(
Path.Combine("ToolWithOutputName", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
Path.Combine("toolwithoutputname", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
}
}
}

View file

@ -20,10 +20,10 @@
},
"System.Diagnostics.TraceSource": "4.0.0",
"System.Runtime.Serialization.Primitives": "4.1.1",
"NuGet.Versioning": "3.5.0-beta2-1484",
"NuGet.Packaging": "3.5.0-beta2-1484",
"NuGet.Frameworks": "3.5.0-beta2-1484",
"NuGet.ProjectModel": "3.5.0-beta2-1484",
"NuGet.Versioning": "3.5.0-rc1-1653",
"NuGet.Packaging": "3.5.0-rc1-1653",
"NuGet.Frameworks": "3.5.0-rc1-1653",
"NuGet.ProjectModel": "3.5.0-rc1-1653",
"Microsoft.DotNet.ProjectModel": {
"target": "project"
},

View file

@ -120,6 +120,17 @@ namespace Microsoft.DotNet.ProjectModel.Tests
Assert.NotNull(LockFileReader.Read(lockFilePath, designTime: true));
}
[Fact]
public void TestPackageFoldersLoadCorrectly()
{
var lockFilePath = GetLockFilePath("valid");
var lockFile = LockFileReader.Read(lockFilePath, designTime: false);
Assert.Equal(2, lockFile.PackageFolders.Count);
Assert.Equal("/foo/packages", lockFile.PackageFolders[0].Path);
Assert.Equal("/foo/packages2", lockFile.PackageFolders[1].Path);
}
private static int LibraryNumberFromName(Microsoft.DotNet.ProjectModel.Graph.LockFileTargetLibrary library)
{
var libraryName = library.Name;

View file

@ -3,6 +3,7 @@ using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Resolution;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Configuration;
using NuGet.Frameworks;
using NuGet.Versioning;
using Xunit;
@ -15,7 +16,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
[Fact]
public void GetDescriptionShouldNotModifyTarget()
{
var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references"));
var provider = new PackageDependencyProvider(NuGetPathContext.Create("/foo/packages"), new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary();
package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0");
@ -46,7 +47,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
[Fact]
public void HasCompileTimePlaceholderChecksAllCompileTimeAssets()
{
var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references"));
var provider = new PackageDependencyProvider(NuGetPathContext.Create("/foo/packages"), new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary();
package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0");
@ -74,7 +75,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
[Fact]
public void HasCompileTimePlaceholderReturnsFalseIfEmpty()
{
var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references"));
var provider = new PackageDependencyProvider(NuGetPathContext.Create("/foo/packages"), new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary();
package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0");

View file

@ -60,6 +60,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOutContainingIgnoreCase(string pattern)
{
Execute.Assertion.ForCondition(_commandResult.StdOut.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0)
.FailWith(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}"));
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
{
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success)

View file

@ -8,7 +8,7 @@
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e4f46eab-b5a5-4e60-9b9d-40a1fadbf45c</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Tools.Test.Utilities</RootNamespace>
<RootNamespace>Microsoft.DotNet.Tools.Tests.Utilities</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
</PropertyGroup>
@ -17,4 +17,4 @@
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
</Project>

View file

@ -131,7 +131,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
// targets
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
library.Should().HavePropertyAsObject("compile")
@ -139,7 +139,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
//libraries
var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
library.Should().HavePropertyValue("sha512", "HASH");
library.Should().HavePropertyValue("type", "package");
library.Should().HavePropertyValue("serviceable", true);
@ -178,7 +178,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
// targets
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
@ -203,7 +203,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
//libraries
var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
library.Should().HavePropertyValue("sha512", "HASH");
library.Should().HavePropertyValue("type", "package");
library.Should().HavePropertyValue("serviceable", true);
@ -256,7 +256,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
// targets
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
@ -280,7 +280,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
//libraries
var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
library.Should().HavePropertyValue("sha512", "HASH");
library.Should().HavePropertyValue("type", "package");
library.Should().HavePropertyValue("serviceable", true);
@ -317,7 +317,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
// targets
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target/runtime").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
library.Should().HavePropertyAsObject("runtime")
@ -327,7 +327,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
//libraries
var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
library.Should().HavePropertyValue("sha512", "HASH");
library.Should().HavePropertyValue("type", "package");
library.Should().HavePropertyValue("serviceable", true);
@ -364,7 +364,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
// targets
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var runtimeTargets = library.Should().HavePropertyAsObject("runtimeTargets").Subject;
@ -412,7 +412,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target/runtime").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var resources = library.Should().HavePropertyAsObject("resources").Subject;
var resource = resources.Should().HavePropertyAsObject("en-US/Fruits.resources.dll").Subject;
resource.Should().HavePropertyValue("locale", "en-US");
@ -446,7 +446,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
var resources = library.Should().HavePropertyAsObject("resources").Subject;
var resource = resources.Should().HavePropertyAsObject("en-US/Fruits.resources.dll").Subject;
resource.Should().HavePropertyValue("locale", "en-US");
@ -478,7 +478,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
// targets
var targets = result.Should().HavePropertyAsObject("targets").Subject;
var target = targets.Should().HavePropertyAsObject("Target").Subject;
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject;
library.Should().HavePropertyValue("compileOnly", true);
}

View file

@ -93,17 +93,17 @@ namespace Microsoft.Extensions.DependencyModel
private void ValidateRuntimeLibrariesFullClr(CommandResult result, string appname)
{
// entry assembly
result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}");
result.Should().HaveStdOutContaining($"Runtime {appname.ToLowerInvariant()}:{appname}");
// project dependency
result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator");
result.Should().HaveStdOutContaining("Runtime dependencycontextvalidator:DependencyContextValidator");
}
private void ValidateCompilationLibrariesFullClr(CommandResult result, string appname)
{
// entry assembly
result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.exe");
result.Should().HaveStdOutContaining($"Compilation {appname.ToLowerInvariant()}:{appname}.exe");
// project dependency
result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll");
result.Should().HaveStdOutContaining("Compilation dependencycontextvalidator:DependencyContextValidator.dll");
// system assembly
result.Should().HaveStdOutContaining("Compilation mscorlib:mscorlib.dll");
}
@ -112,22 +112,21 @@ namespace Microsoft.Extensions.DependencyModel
private void ValidateRuntimeLibraries(CommandResult result, string appname)
{
// entry assembly
result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}");
result.Should().HaveStdOutContaining($"Runtime {appname.ToLowerInvariant()}:{appname}");
// project dependency
result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator");
result.Should().HaveStdOutContaining("Runtime dependencycontextvalidator:DependencyContextValidator");
// system assembly
result.Should().HaveStdOutContaining("Runtime System.Linq:System.Linq");
result.Should().HaveStdOutContainingIgnoreCase("Runtime System.Linq:System.Linq");
}
private void ValidateCompilationLibraries(CommandResult result, string appname)
{
// entry assembly
result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.dll");
result.Should().HaveStdOutContaining($"Compilation {appname.ToLowerInvariant()}:{appname}.dll");
// project dependency
result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll");
result.Should().HaveStdOutContaining("Compilation dependencycontextvalidator:DependencyContextValidator.dll");
// system assembly
result.Should().HaveStdOutContaining("Compilation System.Linq:System.Linq.dll");
result.Should().HaveStdOutContainingIgnoreCase("Compilation System.Linq:System.Linq.dll");
}
}
}

View file

@ -19,7 +19,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void SholdUseEnvironmentVariableToGetDefaultLocation()
{
var result = PackageCacheCompilationAssemblyResolver.GetDefaultPackageCacheDirectory(GetDefaultEnviroment());
var result = PackageCacheCompilationAssemblyResolver.GetDefaultPackageCacheDirectory(GetDefaultEnvironment());
result.Should().Be(CachePath);
}
@ -55,10 +55,10 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void ChecksHashFile()
{
var packagePath = Path.Combine(CachePath, F.DefaultPackageName, F.DefaultVersion);
var packagePath = GetPackagesPath(F.DefaultPackageName, F.DefaultVersion);
var fileSystem = FileSystemMockBuilder.Create()
.AddFile(
Path.Combine(packagePath, $"{F.DefaultPackageName}.{F.DefaultVersion}.nupkg.{F.DefaultHashAlgoritm}"),
GetHashFilePath(packagePath),
"WRONGHASH"
)
.AddFiles(packagePath, F.DefaultAssemblies)
@ -74,10 +74,10 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void ResolvesAllAssemblies()
{
var packagePath = Path.Combine(CachePath, F.DefaultPackageName, F.DefaultVersion);
var packagePath = GetPackagesPath(F.DefaultPackageName, F.DefaultVersion);
var fileSystem = FileSystemMockBuilder.Create()
.AddFile(
Path.Combine(packagePath, $"{F.DefaultPackageName}.{F.DefaultVersion}.nupkg.{F.DefaultHashAlgoritm}"),
GetHashFilePath(packagePath),
F.DefaultHashValue
)
.AddFiles(packagePath, F.TwoAssemblies)
@ -98,10 +98,10 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void FailsWhenOneOfAssembliesNotFound()
{
var packagePath = Path.Combine(CachePath, F.DefaultPackageName, F.DefaultVersion);
var packagePath = GetPackagesPath(F.DefaultPackageName, F.DefaultVersion);
var fileSystem = FileSystemMockBuilder.Create()
.AddFile(
Path.Combine(packagePath, $"{F.DefaultPackageName}.{F.DefaultVersion}.nupkg.{F.DefaultHashAlgoritm}"),
GetHashFilePath(packagePath),
F.DefaultHashValue
)
.AddFiles(packagePath, F.DefaultAssemblyPath)
@ -117,13 +117,23 @@ namespace Microsoft.Extensions.DependencyModel.Tests
.And.Contain(library.Name);
}
private IEnvironment GetDefaultEnviroment()
private IEnvironment GetDefaultEnvironment()
{
return EnvironmentMockBuilder.Create()
.AddVariable("DOTNET_PACKAGES_CACHE", CachePath)
.Build();
}
private static string GetPackagesPath(string id, string version)
{
return PackageResolverTest.GetPackagesPath(CachePath, id, version);
}
private static string GetHashFilePath(string packagePath)
{
return Path.Combine(
packagePath,
$"{F.DefaultPackageName.ToLowerInvariant()}.{F.DefaultVersion.ToLowerInvariant()}.nupkg.{F.DefaultHashAlgoritm}");
}
}
}

View file

@ -17,7 +17,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
private static string PackagesPath = Path.Combine("package", "directory", "location");
[Fact]
public void SholdUseEnvironmentVariableToGetDefaultLocation()
public void ShouldUseEnvironmentVariableToGetDefaultLocation()
{
var environment = EnvironmentMockBuilder.Create()
.AddVariable("NUGET_PACKAGES", PackagesPath)
@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void SholdUseNugetUnderUserProfileOnWindows()
public void ShouldUseNugetUnderUserProfileOnWindows()
{
var environment = EnvironmentMockBuilder.Create()
.AddVariable("USERPROFILE", "User Profile")
@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
}
[Fact]
public void SholdUseNugetUnderHomeOnNonWindows()
public void ShouldUseNugetUnderHomeOnNonWindows()
{
var environment = EnvironmentMockBuilder.Create()
.AddVariable("HOME", "User Home")
@ -53,7 +53,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void ResolvesAllAssemblies()
{
var packagePath = Path.Combine(PackagesPath, F.DefaultPackageName, F.DefaultVersion);
var packagePath = GetPackagesPath(F.DefaultPackageName, F.DefaultVersion);
var fileSystem = FileSystemMockBuilder.Create()
.AddFiles(packagePath, F.TwoAssemblies)
.Build();
@ -73,7 +73,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[Fact]
public void FailsWhenOneOfAssembliesNotFound()
{
var packagePath = Path.Combine(PackagesPath, F.DefaultPackageName, F.DefaultVersion);
var packagePath = GetPackagesPath(F.DefaultPackageName, F.DefaultVersion);
var fileSystem = FileSystemMockBuilder.Create()
.AddFiles(packagePath, F.DefaultAssemblyPath)
.Build();
@ -87,5 +87,15 @@ namespace Microsoft.Extensions.DependencyModel.Tests
.Contain(F.SecondAssemblyPath)
.And.Contain(library.Name);
}
private static string GetPackagesPath(string id, string version)
{
return GetPackagesPath(PackagesPath, id, version);
}
internal static string GetPackagesPath(string basePath, string id, string version)
{
return Path.Combine(basePath, id.ToLowerInvariant(), version.ToLowerInvariant());
}
}
}

View file

@ -278,7 +278,11 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
foreach (var library in new[] { Tuple.Create("Microsoft.Data.OData", "5.6.4"), Tuple.Create("TestLibraryWithResources", "1.0.0") })
{
var resources = depsJson["targets"][".NETCoreApp,Version=v1.0"][library.Item1 + "/" + library.Item2]["resources"];
var resources = depsJson
["targets"]
[".NETCoreApp,Version=v1.0"]
[library.Item1.ToLowerInvariant() + "/" + library.Item2.ToLowerInvariant()]
["resources"];
resources.Should().NotBeNull();

View file

@ -76,7 +76,7 @@ A command is running to initially populate your local package cache, to improve
[Fact]
public void It_creates_a_sentinel_file_under_the_nuget_cache_folder()
{
_nugetCacheFolder.Should().HaveDirectory("Microsoft.NETCore.App");
_nugetCacheFolder.Should().HaveDirectory("microsoft.netcore.app");
}
private string GetDotnetVersion()