Merge branch 'rel/1.0.0' of https://github.com/dotnet/cli into test-fx
This commit is contained in:
commit
ab455e6bb9
58 changed files with 1123 additions and 456 deletions
445
Documentation/specs/canonical.md
Normal file
445
Documentation/specs/canonical.md
Normal file
|
@ -0,0 +1,445 @@
|
|||
Canonical scenarios
|
||||
===================
|
||||
|
||||
# Contents
|
||||
|
||||
* [Overview](#overview)
|
||||
* [Acquisition](#acquisition)
|
||||
* Scenarios
|
||||
* [Starting a new console application](#starting-a-new-console-application)
|
||||
* [Starting a new class library](#starting-a-new-class-library)
|
||||
* [Adding 3rd party dependencies to the projects](#adding-3rd-party-dependencies-to-the-projects)
|
||||
* [Running unit tests](#running-unit-tests)
|
||||
* [Publishing a shared runtime console application](#publishing-a-shared-runtime-console-application)
|
||||
* [Publishing a self-contained console application for all platforms](#publishing-a-self-contained-console-application-for-all-platforms)
|
||||
* [Packaging a class library](#packaging-a-class-library)
|
||||
* [Installing `dotnet` extensions as tools](#installing-dotnet-extensions-as-tools)
|
||||
|
||||
# Overview
|
||||
|
||||
This document outlines the End-to-End canonical scenarios for the CLI tooling. The scenarios outline the planned steps that the developer needs to to to work with her applications.
|
||||
|
||||
Each scenario is organized around a narrative, which provides an explanation on what the developers are trying to do, steps that are needed for the user to achieve the needed narrative. Steps are organized as commands that the developer would need to execute on the command line to achieve the result.
|
||||
|
||||
These scenarios are focused on console applications and libraries.
|
||||
|
||||
# Acquisition
|
||||
All of the scenarios below assume that the CLI tools have been acquired in some way. The acquisition of the CLI tools is explained in detail in a [separate specification](cli-install-experience.md). This document only contains a very short summary of that document.
|
||||
|
||||
There are two main ways to acquire the CLI toolset:
|
||||
1. Using targeted platform's native installers - this approach is used by developers who want to get stable bits on their development machines and don't mind the system-wide installation and need for elevated priviliges.
|
||||
2. Using a local install (a zip/tarball) - this approach is used by developers who want to enable their build servers to use CLI toolset or who want to have multiple, side-by-side installs.
|
||||
|
||||
The bits that are gotten are same modulo potential differences in stability of the bits, however, the smoothness of the experience is not. With native installers the installers themselves do as much as possible to set up a working environment (installing dependencies where possible, setting needed envioronment variables etc.). Local installs require all of the work to be done by developers after dropping bits on the machine.
|
||||
|
||||
The below scenarios must work regardless of the way used to acquire the tools.
|
||||
|
||||
|
||||
|
||||
# Starting a new console application
|
||||
|
||||
## Narative
|
||||
The developer would like to kick the tires on .NET Core by writing a console application. She would like to use the new .NET Core CLI tooling to help her get started, manage dependencies and quickly test out the console application by running it from source. She would then like to try building the code and running it using the shared host that is installed with the CLI toolset.
|
||||
|
||||
## Steps
|
||||
1. Create a C# console application via `dotnet new` command
|
||||
|
||||
```
|
||||
/myapp> dotnet new myapp
|
||||
|
||||
```
|
||||
2. Edit the C# code
|
||||
|
||||
```
|
||||
namespace myapp
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Restore packages
|
||||
```
|
||||
/myapp> dotnet restore
|
||||
|
||||
[messages about restore progress]
|
||||
|
||||
Writing lock file /myapp/project.lock.json
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
4. Run from source for a quick test
|
||||
|
||||
```
|
||||
/myapp> dotnet run
|
||||
|
||||
Hello World!
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
5. Build a binary that can be executed by the shared host
|
||||
|
||||
```
|
||||
/myapp> dotnet build
|
||||
|
||||
[information about the build]
|
||||
|
||||
Creating build output:
|
||||
/myapp/bin/Debug/netstandardapp1.5/myapp.dll
|
||||
/myapp/bin/Debug/netstandardapp1.5/myapp.deps
|
||||
/myapp/bin/Debug/netstandardapp1.5/[All dependencies' IL assemblies].dll
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
6. Run the built version using the shared host in the installed toolset
|
||||
|
||||
```
|
||||
/myapp> dotnet run /myapp/bin/Debug/netstandardapp1.5/myapp.dll
|
||||
Hello World!
|
||||
```
|
||||
|
||||
|
||||
# Starting a new class library
|
||||
|
||||
## Narrative
|
||||
Once started, the developer wants to also include a class library in order to have a place to share common code. She wants to use the CLI toolset to boostrap this effort as well.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Create a new class library using `dotnet new`
|
||||
|
||||
```
|
||||
/> dotnet new mylib --type lib
|
||||
|
||||
Creating a "mylib" class library in "mylib"
|
||||
|
||||
/mylib>
|
||||
```
|
||||
|
||||
2. Restore the dependencies
|
||||
|
||||
```
|
||||
/mylib> dotnet restore
|
||||
|
||||
[messages about restore progress]
|
||||
|
||||
Writing lock file /mylib/project.lock.json
|
||||
|
||||
/mylib>
|
||||
```
|
||||
|
||||
|
||||
3. Edit the `MyLib.cs` file
|
||||
|
||||
```
|
||||
namespace mylib
|
||||
{
|
||||
public class mylib
|
||||
{
|
||||
public void Method1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. Build the code
|
||||
|
||||
```
|
||||
/mylib> dotnet build
|
||||
|
||||
[information about the build]
|
||||
|
||||
Creating build output:
|
||||
/mylib/bin/Debug/netstandardapp1.5/mylib.dll
|
||||
/mylib/bin/Debug/netstandardapp1.5/mylib.deps
|
||||
/mylib/bin/Debug/netstandardapp1.5/[All dependencies' IL assemblies].dll
|
||||
|
||||
/mylib>
|
||||
|
||||
```
|
||||
|
||||
# Adding 3rd party dependencies to the projects
|
||||
|
||||
## Narrative
|
||||
Working towards a complete application, the developer realizes she needs to add good JSON parsing support. Searching across the internet, she finds JSON.NET to be the most reccomended choice. She now uses the CLI tooling to install a dependency off of NuGet.
|
||||
|
||||
>**NOTE:** the shape of the commands used in this scenario is still being discussed.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Install the package
|
||||
|
||||
```
|
||||
/myapp> dotnet pkg install Newtonsoft.Json --version 8.0.2
|
||||
|
||||
[lots of messages about getting JSON.NET]
|
||||
|
||||
Writing lock file /tests/project.lock.json
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
2. Change the code to use the new dependency
|
||||
|
||||
```
|
||||
using Newtonsoft.Json;
|
||||
namespace myapp
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var thing = JsonConvert.DeserializeObject("{ 'item': 1 }");
|
||||
Console.WriteLine("Hello, World!");
|
||||
Console.WriteLine(thing.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Run code from source
|
||||
|
||||
```
|
||||
/myapp> dotnet run
|
||||
Hello, World!
|
||||
1
|
||||
/myapp>
|
||||
```
|
||||
|
||||
# Running unit tests
|
||||
|
||||
## Narrative
|
||||
Writing tests is important, and our developer knows that. She is now writing out the shared logic in her class library and she wants to make sure that she has test coverage. Investigating the manuals, she realizes that the CLI toolset comes with support for xUnit tests including the test runner.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Create a new xunit test project using `dotnet new`
|
||||
|
||||
```
|
||||
/> dotnet new tests --type xunit
|
||||
Created "tests" xunit test project in "tests".
|
||||
|
||||
/tests>
|
||||
```
|
||||
2. Restore the runner and dependencies
|
||||
|
||||
```
|
||||
/tests> dotnet restore
|
||||
|
||||
[messages about restore progress]
|
||||
|
||||
Writing lock file /tests/project.lock.json
|
||||
|
||||
[messages about tool dependencies restore]
|
||||
|
||||
/tests>
|
||||
```
|
||||
|
||||
3. Add a test to the test class
|
||||
```
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace tests
|
||||
{
|
||||
public class Tests
|
||||
{
|
||||
[Fact]
|
||||
public void AssertTrue() {
|
||||
Assert.True(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Run tests using `dotnet test`
|
||||
|
||||
```
|
||||
/tests> dotnet test
|
||||
|
||||
[information about discovery of tests]
|
||||
|
||||
=== TEST EXECUTION SUMMARY ===
|
||||
test Total: 1, Errors: 0, Failed: 0, Skipped: 0, Time: 0.323s
|
||||
|
||||
/tests>
|
||||
```
|
||||
|
||||
# Publishing a shared runtime console application
|
||||
|
||||
## Narrative
|
||||
Coding away on the application has proven worthwhile and our developer wants to share her progress with another developer on her team. She wants to give just the application and its dependencies. Luckily, another developer can easily install the .NET Core SDK and get a shared host, which would be enough to run the application. The CLI toolset allows our developer to publish just the application's code (in IL) and dependencies.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Publish the application
|
||||
```
|
||||
/myapp> dotnet publish --output /pubapp
|
||||
|
||||
[Lots of messages about publishing stuff]
|
||||
|
||||
Creating publish output:
|
||||
/pubapp/myapp/myapp.dll
|
||||
/pubapp/myapp/myapp.deps
|
||||
/pubapp/myapp/[All dependencies' IL assemblies].dll
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
2. Run the project publish output:
|
||||
```
|
||||
/myapp> cd /pubapp/myapp
|
||||
/pubapp/myapp> dotnet ./myapp.dll
|
||||
Hello, World!
|
||||
|
||||
/published/myapp>
|
||||
```
|
||||
3. The published application can be transferred over to a machine that has the .NET Core shared host installed and it is possible for it to be ran.
|
||||
|
||||
# Publishing a self-contained console application for all platforms
|
||||
|
||||
## Narrative
|
||||
After getting feedback from her collegaue developer, our developer decides to test on another machine. However, this machine doesn't have the shared host installed and she cannot get it installed. Luckily, she realizes that .NET Core has support for self-contained applications
|
||||
|
||||
**NOTE**: some of the behaviors in this scenario are still being discussed with the relevant stakeholders.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Modify the project file to enable it to be published as a standalone, platform-specific application (one that doesn't require `dotnet` on the target machine to run) for the desired platforms by adding the `"runtimes"` section:
|
||||
```
|
||||
{
|
||||
"imports": {
|
||||
"Microsoft.ProjectType.ConsoleApplication": "1.0.0"
|
||||
},
|
||||
"runtimes": {
|
||||
"linux-x64": { },
|
||||
"win7-x64": { }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. Restore the project's dependencies again to ensure the platform-specific depdendencies for the specified runtimes are acquired:
|
||||
```
|
||||
/myapp> dotnet restore
|
||||
|
||||
[lots of messages about restoring stuff]
|
||||
|
||||
Writing lock file /myapp/project.lock.json
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
|
||||
|
||||
3. Publish the project again. In this case, the publish will publish for each runtime in the `project.json` file
|
||||
```
|
||||
/myapp> dotnet publish --output /published/myapp
|
||||
|
||||
[Lots of messages about publishing stuff]
|
||||
|
||||
Creating publish output for (linux-x64):
|
||||
/published/myapp-linux-x64/myapp
|
||||
/published/myapp-linux-x64/myapp.dll
|
||||
/published/myapp-linux-x64/myapp.deps
|
||||
/published/myapp-linux-x64/[All dependencies' IL & platform-specific assemblies, inc. stdlib]
|
||||
|
||||
Creating publish output for (win7-x64):
|
||||
/published/myapp-win7-x64/myapp
|
||||
/published/myapp-win7-x64/myapp.dll
|
||||
/published/myapp-win7-x64/myapp.deps
|
||||
/published/myapp-win7-x64/[All dependencies' IL & platform-specific assemblies, inc. stdlib]
|
||||
|
||||
/myapp>
|
||||
|
||||
```
|
||||
|
||||
4. Any of the outputs above can be xcopied to the platform in question and it will work without having to have the shared host installed.
|
||||
|
||||
5. Publish the project for a specific platform (win7-x64):
|
||||
|
||||
```
|
||||
/myapp> dotnet publish --output /win7/myapp --runtime win7-x64
|
||||
|
||||
[Lots of messages about publishing stuff]
|
||||
|
||||
Creating publish output for (win7-x64):
|
||||
/published/myapp-win7-x64/myapp
|
||||
/published/myapp-win7-x64/myapp.dll
|
||||
/published/myapp-win7-x64/myapp.deps
|
||||
/published/myapp-win7-x64/[All dependencies' IL & platform-specific assemblies, inc. stdlib]
|
||||
|
||||
/myapp>
|
||||
```
|
||||
|
||||
# Packaging a class library
|
||||
|
||||
## Narative
|
||||
The developer wants to take the library she built and package it up as a NuGet package in order to share it with the rest of the ecosystem. Again, she would like to use the CLI toolset to achieve this. Since she wants to be sure that all her code is in a pristine condition, she will also build it one more time, run tests and then package it.
|
||||
|
||||
## Steps
|
||||
1. Build the code to make sure no build errors have crept in
|
||||
|
||||
```
|
||||
/mylib> dotnet build
|
||||
|
||||
[information about the build]
|
||||
|
||||
Creating build output:
|
||||
/myapp/bin/Debug/netstandardapp1.5/myapp.dll
|
||||
/myapp/bin/Debug/netstandardapp1.5/myapp.deps
|
||||
/myapp/bin/Debug/netstandardapp1.5/[All dependencies' IL assemblies].dll
|
||||
|
||||
/mylib>
|
||||
|
||||
```
|
||||
|
||||
2. Switch to the test project and run unit tests
|
||||
|
||||
```console
|
||||
[switch to the directory containg unit tests]
|
||||
/mytests> dotnet test
|
||||
|
||||
[info about tests flies around]
|
||||
|
||||
=== TEST EXECUTION SUMMARY ===
|
||||
test Total: 50, Errors: 0, Failed: 0, Skipped: 0, Time: 5.323s
|
||||
|
||||
/mytests>
|
||||
|
||||
```
|
||||
|
||||
3. Package the library
|
||||
|
||||
```console
|
||||
[switch to the library directory]
|
||||
|
||||
/mylib> dotnet pack
|
||||
|
||||
[information about build is shown]
|
||||
|
||||
Producing nuget package "mylib.1.0.0" for mylib
|
||||
mylib -> /mylib/bin/Debug/mylib.1.0.0.nupkg
|
||||
Producing nuget package "mylib.1.0.0.symbols" for mylib
|
||||
mylib -> /mylib/bin/Debug/mylib.1.0.0.symbols.nupkg
|
||||
|
||||
/mylib>
|
||||
```
|
||||
|
||||
# Installing `dotnet` extensions as tools
|
||||
|
||||
## Narrative
|
||||
As our developer is going further with her usage of the CLI tools, she figures out that there is an easy way to extend the CLI tools on her machine by adding project-level tools to her `project.json`. She uses the CLI to work with the tools and she is able to extend the default toolset to further fit her needs.
|
||||
|
||||
## Steps
|
||||
>**TODO:** at this point, this needs more work to figure out how it will surface; it is listed her so it is not forgotten.
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"dnx": {
|
||||
"projects": "src/*/project.json"
|
||||
"projects": "src/*/project.json;test/src/*/project.json;scripts/*/project.json"
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="102" height="20">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="150" height="20">
|
||||
<linearGradient id="b" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1" />
|
||||
<stop offset="1" stop-opacity=".1" />
|
||||
</linearGradient>
|
||||
<mask id="a">
|
||||
<rect width="102" height="20" rx="3" fill="#fff" />
|
||||
<rect width="150" height="20" rx="3" fill="#fff" />
|
||||
</mask>
|
||||
<g mask="url(#a)">
|
||||
<path fill="#555" d="M0 0h52v20H0z" />
|
||||
<path fill="#007ec6" d="M52 0h50v20H52z" />
|
||||
<path fill="url(#b)" d="M0 0h102v20H0z" />
|
||||
<path fill="#007ec6" d="M52 0h100v20H52z" />
|
||||
<path fill="url(#b)" d="M0 0h150v20H0z" />
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
||||
<text x="26" y="15" fill="#010101" fill-opacity=".3">version</text>
|
||||
<text x="26" y="14">version</text>
|
||||
<text x="76" y="15" fill="#010101" fill-opacity=".3">ver_number</text>
|
||||
<text x="76" y="14">ver_number</text>
|
||||
<text x="100" y="15" fill="#010101" fill-opacity=".3">ver_number</text>
|
||||
<text x="100" y="14">ver_number</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 882 B After Width: | Height: | Size: 885 B |
|
@ -33,6 +33,8 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
_maxTargetLen = targets.Values.Select(t => t.Name.Length).Max();
|
||||
}
|
||||
|
||||
public T Get<T>(string name) => (T)this[name];
|
||||
|
||||
public BuildTargetResult RunTarget(string name) => RunTarget(name, force: false);
|
||||
|
||||
public BuildTargetResult RunTarget(string name, bool force)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.FS;
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public class CompileTargets
|
||||
{
|
||||
public static readonly string CoreCLRVersion = "1.0.1-rc2-23811";
|
||||
public static readonly string AppDepSdkVersion = "1.0.5-prerelease-00001";
|
||||
public static readonly string AppDepSdkVersion = "1.0.6-prerelease-00001";
|
||||
|
||||
public static readonly List<string> AssembliesToCrossGen = GetAssembliesToCrossGen();
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
Rmdir(cmakeOut);
|
||||
Mkdirp(cmakeOut);
|
||||
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
|
||||
// Run the build
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
|
@ -120,13 +120,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target]
|
||||
public static BuildTargetResult CompileStage2(BuildTargetContext c)
|
||||
{
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test"));
|
||||
var result = CompileStage(c,
|
||||
dotnet: DotNetCli.Stage1,
|
||||
outputDir: Dirs.Stage2);
|
||||
|
||||
if (!result.Success)
|
||||
{
|
||||
return result;
|
||||
|
@ -137,7 +138,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging");
|
||||
Mkdirp(packagingOutputDir);
|
||||
foreach(var project in ProjectsToPack)
|
||||
foreach (var project in ProjectsToPack)
|
||||
{
|
||||
// Just build them, we'll pack later
|
||||
DotNetCli.Stage1.Build(
|
||||
|
@ -158,9 +159,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
Rmdir(outputDir);
|
||||
|
||||
dotnet.SetDotNetHome();
|
||||
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var binDir = Path.Combine(outputDir, "bin");
|
||||
var runtimeOutputDir = Path.Combine(outputDir, "runtime", "coreclr");
|
||||
|
||||
|
@ -210,7 +209,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(binDir, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true);
|
||||
|
||||
// Corehostify binaries
|
||||
foreach(var binaryToCorehostify in BinariesForCoreHost)
|
||||
foreach (var binaryToCorehostify in BinariesForCoreHost)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -219,7 +218,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
File.Delete(Path.Combine(binDir, $"{binaryToCorehostify}.exe"));
|
||||
File.Copy(Path.Combine(binDir, $"corehost{Constants.ExeSuffix}"), Path.Combine(binDir, binaryToCorehostify + Constants.ExeSuffix));
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}");
|
||||
}
|
||||
|
@ -234,14 +233,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
// Copy AppDeps
|
||||
result = CopyAppDeps(c, binDir);
|
||||
if(!result.Success)
|
||||
if (!result.Success)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Generate .version file
|
||||
var version = ((BuildVersion)c.BuildContext["BuildVersion"]).SimpleVersion;
|
||||
var content = $@"{version}{Environment.NewLine}{c.BuildContext["CommitHash"]}{Environment.NewLine}";
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}";
|
||||
File.WriteAllText(Path.Combine(outputDir, ".version"), content);
|
||||
|
||||
return c.Success();
|
||||
|
@ -356,7 +355,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
foreach (var assemblyToCrossgen in AssembliesToCrossGen)
|
||||
{
|
||||
c.Info($"Crossgenning {assemblyToCrossgen}");
|
||||
ExecIn(outputDir, crossgen, "-nologo", "-platform_assemblies_paths", outputDir, assemblyToCrossgen);
|
||||
ExecInSilent(outputDir, crossgen, "-nologo", "-platform_assemblies_paths", outputDir, assemblyToCrossgen);
|
||||
}
|
||||
|
||||
c.Info("Crossgen complete");
|
||||
|
|
|
@ -25,10 +25,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION");
|
||||
|
||||
if(string.IsNullOrEmpty(configEnv))
|
||||
if (string.IsNullOrEmpty(configEnv))
|
||||
{
|
||||
configEnv = "Debug";
|
||||
}
|
||||
|
||||
c.BuildContext["Configuration"] = configEnv;
|
||||
|
||||
c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}");
|
||||
|
@ -160,22 +161,22 @@ cmake is required to build the native host 'corehost'";
|
|||
try
|
||||
{
|
||||
// Read the cache file
|
||||
if(File.Exists(cacheTimeFile))
|
||||
if (File.Exists(cacheTimeFile))
|
||||
{
|
||||
var content = File.ReadAllText(cacheTimeFile);
|
||||
if(!string.IsNullOrEmpty(content))
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
cacheTime = DateTime.ParseExact("O", content, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
c.Warn($"Error reading NuGet cache time file, leaving the cache alone");
|
||||
c.Warn($"Error Detail: {ex.ToString()}");
|
||||
}
|
||||
|
||||
if(cacheTime == null || (cacheTime.Value.AddHours(cacheExpiration) < DateTime.UtcNow))
|
||||
if (cacheTime == null || (cacheTime.Value.AddHours(cacheExpiration) < DateTime.UtcNow))
|
||||
{
|
||||
// Cache has expired or the status is unknown, clear it and write the file
|
||||
c.Info("Clearing NuGet cache");
|
||||
|
@ -204,9 +205,9 @@ cmake is required to build the native host 'corehost'";
|
|||
var lines = File.ReadAllLines(path);
|
||||
var dict = new Dictionary<string, string>();
|
||||
c.Verbose("Branch Info:");
|
||||
foreach(var line in lines)
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if(!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line))
|
||||
if (!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
var splat = line.Split(new[] { '=' }, 2);
|
||||
dict[splat[0]] = splat[1];
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
// Set up the environment variables previously defined by common.sh/ps1
|
||||
// This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names)
|
||||
var buildVersion = (BuildVersion)c.BuildContext["BuildVersion"];
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var env = new Dictionary<string, string>()
|
||||
{
|
||||
{ "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() },
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.FS;
|
||||
using static Microsoft.DotNet.Cli.Build.Utils;
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
using static Microsoft.DotNet.Cli.Build.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
foreach (var relativePath in TestPackageProjects)
|
||||
{
|
||||
var fullPath = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages", relativePath.Replace('/', Path.DirectorySeparatorChar));
|
||||
c.Info("Packing: {fullPath}");
|
||||
c.Info($"Packing: {fullPath}");
|
||||
dotnet.Pack("--output", Dirs.TestPackages)
|
||||
.WorkingDirectory(fullPath)
|
||||
.Execute()
|
||||
|
@ -95,7 +95,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var dotnet = DotNetCli.Stage2;
|
||||
foreach (var testProject in TestProjects)
|
||||
{
|
||||
c.Info("Building tests: {project}");
|
||||
c.Info($"Building tests: {testProject}");
|
||||
dotnet.Build()
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test", testProject))
|
||||
.Execute()
|
||||
|
@ -112,7 +112,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
// Need to load up the VS Vars
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
var vsvars = LoadVsVars();
|
||||
var vsvars = LoadVsVars(c);
|
||||
|
||||
// Copy the test projects
|
||||
var testProjectsDir = Path.Combine(Dirs.TestOutput, "TestProjects");
|
||||
|
@ -155,17 +155,17 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var consumers = Path.Combine(c.BuildContext.BuildDirectory, "test", "PackagedCommands", "Consumers");
|
||||
|
||||
// Compile the consumer apps
|
||||
foreach(var dir in Directory.EnumerateDirectories(consumers))
|
||||
foreach (var dir in Directory.EnumerateDirectories(consumers))
|
||||
{
|
||||
dotnet.Build().WorkingDirectory(dir).Execute().EnsureSuccessful();
|
||||
}
|
||||
|
||||
// Test the apps
|
||||
foreach(var dir in Directory.EnumerateDirectories(consumers))
|
||||
foreach (var dir in Directory.EnumerateDirectories(consumers))
|
||||
{
|
||||
var result = dotnet.Exec("hello").WorkingDirectory(dir).CaptureStdOut().CaptureStdErr().Execute();
|
||||
result.EnsureSuccessful();
|
||||
if(!string.Equals("Hello", result.StdOut.Trim(), StringComparison.Ordinal))
|
||||
if (!string.Equals("Hello", result.StdOut.Trim(), StringComparison.Ordinal))
|
||||
{
|
||||
var testName = Path.GetFileName(dir);
|
||||
c.Error($"Packaged Commands Test '{testName}' failed");
|
||||
|
@ -180,7 +180,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target]
|
||||
public static BuildTargetResult ValidateDependencies(BuildTargetContext c)
|
||||
{
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
||||
c.Info("Publishing MultiProjectValidator");
|
||||
|
@ -197,12 +197,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> LoadVsVars()
|
||||
private static Dictionary<string, string> LoadVsVars(BuildTargetContext c)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
c.Verbose("Start Collecting Visual Studio Environment Variables");
|
||||
|
||||
var vsvarsPath = Path.GetFullPath(Path.Combine(Environment.GetEnvironmentVariable("VS140COMNTOOLS"), "..", "..", "VC"));
|
||||
|
||||
|
@ -228,13 +230,27 @@ set");
|
|||
File.Delete(temp);
|
||||
}
|
||||
}
|
||||
|
||||
result.EnsureSuccessful();
|
||||
|
||||
var vars = new Dictionary<string, string>();
|
||||
foreach (var line in result.StdOut.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var splat = line.Split(new[] { '=' }, 2);
|
||||
vars[splat[0]] = splat[1];
|
||||
|
||||
if (splat.Length == 2)
|
||||
{
|
||||
c.Verbose($"Adding variable '{line}'");
|
||||
vars[splat[0]] = splat[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
c.Info($"Skipping VS Env Variable. Unknown format: '{line}'");
|
||||
}
|
||||
}
|
||||
|
||||
c.Verbose("Finish Collecting Visual Studio Environment Variables");
|
||||
|
||||
return vars;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
BinPath = binPath;
|
||||
}
|
||||
|
||||
public void SetDotNetHome()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("DOTNET_HOME", Path.GetDirectoryName(BinPath));
|
||||
}
|
||||
|
||||
public Command Exec(string command, params string[] args)
|
||||
{
|
||||
return Command.Create(Path.Combine(BinPath, $"dotnet{Constants.ExeSuffix}"), Enumerable.Concat(new[] { command }, args));
|
||||
|
|
|
@ -51,13 +51,18 @@ function CheckRequiredVariables
|
|||
|
||||
function UploadFile($Blob, $Uploadfile)
|
||||
{
|
||||
Write-Host "Uploading $Uploadfile to dotnet feed to.."
|
||||
Write-Host "Uploading $Uploadfile to dotnet feed."
|
||||
|
||||
if([string]::IsNullOrEmpty($env:HOME))
|
||||
{
|
||||
$env:HOME=Get-Location
|
||||
}
|
||||
|
||||
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
||||
azure storage blob upload --quiet --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
||||
|
||||
if($LastExitCode -eq 0)
|
||||
if($?)
|
||||
{
|
||||
Write-Host "Successfully uploaded $Uploadfile to dotnet feed."
|
||||
return $true
|
||||
|
@ -140,10 +145,10 @@ function UploadVersionBadge($badgeFile)
|
|||
$fileName = "windows_$Configuration_$([System.IO.Path]::GetFileName($badgeFile))"
|
||||
|
||||
Write-Host "Uploading the version badge to Latest"
|
||||
UploadFile "dev/Binaries/Latest/$filename" $badgeFile
|
||||
UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile
|
||||
|
||||
Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION"
|
||||
UploadFile "dev/Binaries/$env:DOTNET_CLI_VERSION/$filename" $badgeFile
|
||||
UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -192,12 +192,12 @@ upload_installers_to_blob_storage(){
|
|||
|
||||
upload_version_badge(){
|
||||
local badgefile=$1
|
||||
local filename="$OSNAME_$CONFIGURATION_$(basename $badgefile)"
|
||||
local filename="${OSNAME}_${CONFIGURATION}_$(basename $badgefile)"
|
||||
echo "Uploading the version badge to Latest"
|
||||
upload_file_to_blob_storage_azure_cli "dev/Binaries/Latest/$filename" $badgefile
|
||||
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/Latest/$filename" $badgefile
|
||||
|
||||
echo "Uploading the version badge to $DOTNET_CLI_VERSION"
|
||||
upload_file_to_blob_storage_azure_cli "dev/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile
|
||||
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -51,12 +51,19 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
Console.ForegroundColor = (ConsoleColor)((int)Console.ForegroundColor ^ 0x08);
|
||||
}
|
||||
|
||||
|
||||
public void WriteLine(string message)
|
||||
{
|
||||
Write(message);
|
||||
Writer.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
public void Write(string message)
|
||||
{
|
||||
if (!_useConsoleColor)
|
||||
{
|
||||
Writer.WriteLine(message);
|
||||
Writer.Write(message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,7 +144,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
escapeScan = endIndex + 1;
|
||||
}
|
||||
}
|
||||
Writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
return this;
|
||||
}
|
||||
|
||||
public ICommand ForwardStdOut(TextWriter to = null, bool onlyIfVerbose = false)
|
||||
public ICommand ForwardStdOut(TextWriter to = null, bool onlyIfVerbose = false, bool ansiPassThrough = true)
|
||||
{
|
||||
ThrowIfRunning();
|
||||
if (!onlyIfVerbose || CommandContext.IsVerbose())
|
||||
|
@ -168,6 +168,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
if (to == null)
|
||||
{
|
||||
_stdOut.ForwardTo(writeLine: Reporter.Output.WriteLine);
|
||||
EnvironmentVariable(CommandContext.Variables.AnsiPassThru, ansiPassThrough.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -177,7 +178,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
return this;
|
||||
}
|
||||
|
||||
public ICommand ForwardStdErr(TextWriter to = null, bool onlyIfVerbose = false)
|
||||
public ICommand ForwardStdErr(TextWriter to = null, bool onlyIfVerbose = false, bool ansiPassThrough = true)
|
||||
{
|
||||
ThrowIfRunning();
|
||||
if (!onlyIfVerbose || CommandContext.IsVerbose())
|
||||
|
@ -185,6 +186,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
if (to == null)
|
||||
{
|
||||
_stdErr.ForwardTo(writeLine: Reporter.Error.WriteLine);
|
||||
EnvironmentVariable(CommandContext.Variables.AnsiPassThru, ansiPassThrough.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
public static readonly string DynamicLibSuffix = CurrentPlatform == Platform.Windows ? ".dll" :
|
||||
CurrentPlatform == Platform.Darwin ? ".dylib" : ".so";
|
||||
|
||||
public static readonly string LibCoreClrName = (CurrentPlatform == Platform.Windows ? "coreclr" : "libcoreclr") + DynamicLibSuffix;
|
||||
public static readonly string LibCoreClrFileName = (CurrentPlatform == Platform.Windows ? "coreclr" : "libcoreclr");
|
||||
public static readonly string LibCoreClrName = LibCoreClrFileName + DynamicLibSuffix;
|
||||
|
||||
public static readonly string RuntimeIdentifier = CurrentPlatform == Platform.Windows ? "win7-x64" :
|
||||
CurrentPlatform == Platform.Darwin ? "osx.10.10-x64" : "ubuntu.14.04-x64";
|
||||
|
|
|
@ -18,9 +18,9 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
ICommand CaptureStdErr();
|
||||
|
||||
ICommand ForwardStdOut(TextWriter to = null, bool onlyIfVerbose = false);
|
||||
ICommand ForwardStdOut(TextWriter to = null, bool onlyIfVerbose = false, bool ansiPassThrough = true);
|
||||
|
||||
ICommand ForwardStdErr(TextWriter to = null, bool onlyIfVerbose = false);
|
||||
ICommand ForwardStdErr(TextWriter to = null, bool onlyIfVerbose = false, bool ansiPassThrough = true);
|
||||
|
||||
ICommand OnOutputLine(Action<string> handler);
|
||||
|
||||
|
|
|
@ -55,7 +55,14 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_console?.Writer?.Write(message);
|
||||
if (CommandContext.ShouldPassAnsiCodesThrough())
|
||||
{
|
||||
_console?.Writer?.Write(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
_console?.Write(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"compilationOptions": {
|
||||
"keyFile": "../../tools/Key.snk",
|
||||
"warningsAsErrors": true
|
||||
"keyFile": "../../tools/Key.snk",
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"System.Reflection.Metadata": "1.2.0-rc2-23811",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
"net451": {
|
||||
"frameworkAssemblies": {
|
||||
"System.Runtime": {
|
||||
"type": "build"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811"
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +1,20 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"compilationOptions": {
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Reflection.Metadata": "1.2.0-rc3-23811",
|
||||
"System.CommandLine": "0.1.0-e160119-1",
|
||||
"Microsoft.CodeAnalysis.CSharp": "1.2.0-beta1-20160202-02",
|
||||
"Microsoft.CodeAnalysis.CSharp": "1.2.0-beta1-20160202-02",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.DotNet.Files": {"version": "1.0.0-*", "target": "project"}
|
||||
"Microsoft.DotNet.Files": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
"scripts": {}
|
||||
}
|
|
@ -1,31 +1,20 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"description": "Abstraction to interact with the file system and file paths.",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Linq.Expressions": "4.0.11-rc2-23811",
|
||||
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
|
||||
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
"description": "Abstraction to interact with the file system and file paths.",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Linq.Expressions": "4.0.11-rc2-23811",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
}
|
||||
},
|
||||
"scripts": {}
|
||||
}
|
|
@ -13,4 +13,4 @@
|
|||
"imports": "portable-net45+win8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Reflection.Metadata": "1.2.0-rc3-23811",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.2.0-beta1-20160202-02"
|
||||
|
@ -15,4 +14,4 @@
|
|||
"imports": "portable-net45+win8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -128,6 +128,18 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
/// </summary>
|
||||
private LibraryExport GetExport(LibraryDescription library)
|
||||
{
|
||||
if (!library.Resolved)
|
||||
{
|
||||
// For a unresolved project reference returns a export with empty asset.
|
||||
return new LibraryExport(library: library,
|
||||
compileAssemblies: Enumerable.Empty<LibraryAsset>(),
|
||||
sourceReferences: Enumerable.Empty<string>(),
|
||||
nativeLibraries: Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssets: Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssemblies: EmptyArray<LibraryAsset>.Value,
|
||||
analyzers: EmptyArray<AnalyzerReference>.Value);
|
||||
}
|
||||
|
||||
if (Equals(LibraryType.Package, library.Identity.Type))
|
||||
{
|
||||
return ExportPackage((PackageDescription)library);
|
||||
|
@ -167,18 +179,6 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
|
||||
private LibraryExport ExportProject(ProjectDescription project)
|
||||
{
|
||||
if (!project.Resolved)
|
||||
{
|
||||
// For a unresolved project reference returns a export with empty asset.
|
||||
return new LibraryExport(library: project,
|
||||
compileAssemblies: Enumerable.Empty<LibraryAsset>(),
|
||||
sourceReferences: Enumerable.Empty<string>(),
|
||||
nativeLibraries: Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssets: Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssemblies: EmptyArray<LibraryAsset>.Value,
|
||||
analyzers: EmptyArray<AnalyzerReference>.Value);
|
||||
}
|
||||
|
||||
var compileAssemblies = new List<LibraryAsset>();
|
||||
var runtimeAssets = new List<LibraryAsset>();
|
||||
var sourceReferences = new List<string>();
|
||||
|
|
|
@ -104,6 +104,48 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string ToLockFileDependencyGroupString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(Name);
|
||||
|
||||
if (VersionRange != null)
|
||||
{
|
||||
if (VersionRange.HasLowerBound)
|
||||
{
|
||||
sb.Append(" ");
|
||||
|
||||
if (VersionRange.IsMinInclusive)
|
||||
{
|
||||
sb.Append(">= ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("> ");
|
||||
}
|
||||
|
||||
if (VersionRange.IsFloating)
|
||||
{
|
||||
sb.Append(VersionRange.Float.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(VersionRange.MinVersion.ToNormalizedString());
|
||||
}
|
||||
}
|
||||
|
||||
if (VersionRange.HasUpperBound)
|
||||
{
|
||||
sb.Append(" ");
|
||||
|
||||
sb.Append(VersionRange.IsMaxInclusive ? "<= " : "< ");
|
||||
sb.Append(VersionRange.MaxVersion.ToNormalizedString());
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public bool HasFlag(LibraryDependencyTypeFlag flag)
|
||||
{
|
||||
return Type.HasFlag(flag);
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
if (group.FrameworkName == null)
|
||||
{
|
||||
actualDependencies = project.Dependencies
|
||||
.Select(RenderDependency)
|
||||
.Select(d => d.ToLockFileDependencyGroupString())
|
||||
.OrderBy(x => x, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
else
|
||||
|
@ -74,7 +74,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
}
|
||||
|
||||
actualDependencies = framework.Dependencies
|
||||
.Select(RenderDependency)
|
||||
.Select(d => d.ToLockFileDependencyGroupString())
|
||||
.OrderBy(x => x, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,5 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
message = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
private string RenderDependency(LibraryRange arg) => $"{arg.Name} {VersionUtility.RenderVersion(arg.VersionRange)}";
|
||||
}
|
||||
}
|
|
@ -175,7 +175,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
var libraries = new Dictionary<LibraryKey, LibraryDescription>();
|
||||
var projectResolver = new ProjectDependencyProvider(ProjectResolver);
|
||||
|
||||
var mainProject = projectResolver.GetDescription(TargetFramework, Project);
|
||||
var mainProject = projectResolver.GetDescription(TargetFramework, Project, targetLibrary: null);
|
||||
|
||||
// Add the main project
|
||||
libraries.Add(new LibraryKey(mainProject.Identity.Name), mainProject);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
|
|||
var project = _resolveProject(Path.GetDirectoryName(path));
|
||||
if (project != null)
|
||||
{
|
||||
return GetDescription(targetLibrary.TargetFramework, project);
|
||||
return GetDescription(targetLibrary.TargetFramework, project, targetLibrary);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -40,30 +40,40 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
|
|||
return GetDescription(name, path, targetLibrary, projectCacheResolver: null);
|
||||
}
|
||||
|
||||
public ProjectDescription GetDescription(NuGetFramework targetFramework, Project project)
|
||||
public ProjectDescription GetDescription(NuGetFramework targetFramework, Project project, LockFileTargetLibrary targetLibrary)
|
||||
{
|
||||
// This never returns null
|
||||
var targetFrameworkInfo = project.GetTargetFramework(targetFramework);
|
||||
var targetFrameworkDependencies = new List<LibraryRange>(targetFrameworkInfo.Dependencies);
|
||||
var dependencies = new List<LibraryRange>(targetFrameworkInfo.Dependencies);
|
||||
|
||||
if (targetFramework != null && targetFramework.IsDesktop())
|
||||
{
|
||||
targetFrameworkDependencies.Add(new LibraryRange("mscorlib", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
dependencies.Add(new LibraryRange("mscorlib", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
|
||||
targetFrameworkDependencies.Add(new LibraryRange("System", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
dependencies.Add(new LibraryRange("System", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
|
||||
if (targetFramework.Version >= new Version(3, 5))
|
||||
{
|
||||
targetFrameworkDependencies.Add(new LibraryRange("System.Core", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
dependencies.Add(new LibraryRange("System.Core", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
|
||||
if (targetFramework.Version >= new Version(4, 0))
|
||||
{
|
||||
targetFrameworkDependencies.Add(new LibraryRange("Microsoft.CSharp", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
dependencies.Add(new LibraryRange("Microsoft.CSharp", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var dependencies = project.Dependencies.Concat(targetFrameworkDependencies).ToList();
|
||||
// Add all of the project's dependencies
|
||||
dependencies.AddRange(project.Dependencies);
|
||||
|
||||
if (targetLibrary != null)
|
||||
{
|
||||
// The lock file entry might have a filtered set of dependencies
|
||||
var lockFileDependencies = targetLibrary.Dependencies.ToDictionary(d => d.Id);
|
||||
|
||||
// Remove all non-framework dependencies that don't appear in the lock file entry
|
||||
dependencies.RemoveAll(m => !lockFileDependencies.ContainsKey(m.Name) && m.Target != LibraryType.ReferenceAssembly);
|
||||
}
|
||||
|
||||
// Mark the library as unresolved if there were specified frameworks
|
||||
// and none of them resolved
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
},
|
||||
"description": "Types to model a .NET Project",
|
||||
"dependencies": {
|
||||
"System.Reflection.Metadata": "1.2.0-rc2-23811",
|
||||
|
||||
"NuGet.Packaging": "3.4.0-beta-583",
|
||||
"System.Reflection.Metadata": "1.2.0-rc3-23811",
|
||||
"NuGet.Packaging": "3.4.0-beta-625",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
|
||||
"Microsoft.Extensions.JsonParser.Sources": {
|
||||
"type": "build",
|
||||
|
@ -17,29 +16,32 @@
|
|||
"type": "build",
|
||||
"version": "1.0.0-rc2-16054"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyModel": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
"Microsoft.Extensions.DependencyModel": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {
|
||||
"frameworkAssemblies": {
|
||||
"System.IO": ""
|
||||
}
|
||||
},
|
||||
"net451": {
|
||||
"frameworkAssemblies": {
|
||||
"System.Runtime": {
|
||||
"type": "build"
|
||||
},
|
||||
"System.Collections": {
|
||||
"type": "build"
|
||||
},
|
||||
"System.IO": {
|
||||
"type": "build"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811",
|
||||
"System.Runtime.Loader": "4.0.0-rc2-23811",
|
||||
"System.Security.Cryptography.Algorithms": "4.0.0-rc2-23811",
|
||||
"Microsoft.CSharp": "4.0.1-rc2-23811",
|
||||
"System.Xml.XDocument": "4.0.11-rc2-23811"
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811",
|
||||
"System.Runtime.Loader": "4.0.0-rc2-23811",
|
||||
"System.Security.Cryptography.Algorithms": "4.0.0-rc2-23811",
|
||||
"Microsoft.CSharp": "4.0.1-rc2-23811",
|
||||
"System.Xml.XDocument": "4.0.11-rc2-23811"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,14 +3,12 @@
|
|||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library" : "1.0.0-rc2-23811"
|
||||
"NETStandard.Library": "1.0.0-rc2-23811"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +1,41 @@
|
|||
{
|
||||
"description": "Abstractions for reading `.deps` files.",
|
||||
"version": "1.0.0-*",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dotnet/cli"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
"dotnet5.4": {
|
||||
"imports": "portable-net451+win8",
|
||||
"dependencies": {
|
||||
"System.IO.FileSystem": "4.0.1-rc2-23811",
|
||||
"System.Linq": "4.0.1-rc2-23811",
|
||||
"System.Runtime": "4.0.21-rc2-23811",
|
||||
"System.Reflection": "4.1.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811"
|
||||
}
|
||||
"description": "Abstractions for reading `.deps` files.",
|
||||
"version": "1.0.0-*",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dotnet/cli"
|
||||
},
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23811",
|
||||
"System.IO.FileSystem": "4.0.1-rc2-23811",
|
||||
"System.Linq": "4.0.1-rc2-23811",
|
||||
"System.Runtime": "4.0.21-rc2-23811",
|
||||
"System.Reflection": "4.1.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {},
|
||||
"dotnet5.4": {
|
||||
"imports": "portable-net451+win8",
|
||||
"dependencies": {
|
||||
"System.IO.FileSystem": "4.0.1-rc2-23811",
|
||||
"System.Linq": "4.0.1-rc2-23811",
|
||||
"System.Runtime": "4.0.21-rc2-23811",
|
||||
"System.Reflection": "4.1.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811"
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23811",
|
||||
"System.IO.FileSystem": "4.0.1-rc2-23811",
|
||||
"System.Linq": "4.0.1-rc2-23811",
|
||||
"System.Runtime": "4.0.21-rc2-23811",
|
||||
"System.Reflection": "4.1.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {}
|
||||
}
|
|
@ -1,29 +1,29 @@
|
|||
{
|
||||
"description": "Abstractions for test runners to communicate to a tool, such as Visual Studio.",
|
||||
"version": "1.0.0-*",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dotnet/cli"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16040"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Resources.ResourceManager": "4.0.1-rc2-23811",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23811"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": { }
|
||||
"description": "Abstractions for test runners to communicate to a tool, such as Visual Studio.",
|
||||
"version": "1.0.0-*",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dotnet/cli"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16040"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {},
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Resources.ResourceManager": "4.0.1-rc2-23811",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23811"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {}
|
||||
}
|
|
@ -123,7 +123,7 @@ void add_mscorlib_to_tpa(const pal::string_t& clr_dir, std::set<pal::string_t>*
|
|||
pal::string_t mscorlib_path = clr_dir + DIR_SEPARATOR + _X("mscorlib.dll");
|
||||
if (pal::file_exists(mscorlib_path))
|
||||
{
|
||||
add_tpa_asset(_X("mscorlib"), mscorlib_ni_path, items, output);
|
||||
add_tpa_asset(_X("mscorlib"), mscorlib_path, items, output);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -346,6 +346,20 @@ bool deps_resolver_t::load()
|
|||
replace_char(&entry.relative_path, _X('\\'), _X('/'));
|
||||
|
||||
m_deps_entries.push_back(entry);
|
||||
|
||||
trace::verbose(_X("Added deps entry [%d] [%s, %s, %s]"), m_deps_entries.size() - 1, entry.library_name.c_str(), entry.library_version.c_str(), entry.relative_path.c_str());
|
||||
|
||||
static_assert(std::is_same<std::vector<deps_entry_t>, decltype(m_deps_entries)>::value, "decltype(m_deps_entries) not a vector, took index based on size.");
|
||||
if (entry.asset_type == _X("native") &&
|
||||
entry.asset_name == LIBCORECLR_FILENAME)
|
||||
{
|
||||
m_coreclr_index = m_deps_entries.size() - 1;
|
||||
trace::verbose(_X("Found coreclr from deps entry [%d] [%s, %s, %s]"),
|
||||
m_coreclr_index,
|
||||
entry.library_name.c_str(),
|
||||
entry.library_version.c_str(),
|
||||
entry.relative_path.c_str());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -379,9 +393,9 @@ void deps_resolver_t::get_local_assemblies(const pal::string_t& dir)
|
|||
std::vector<pal::string_t> files;
|
||||
pal::readdir(dir, &files);
|
||||
|
||||
for (const auto& file : files)
|
||||
for (const auto& ext : managed_ext)
|
||||
{
|
||||
for (const auto& ext : managed_ext)
|
||||
for (const auto& file : files)
|
||||
{
|
||||
// Nothing to do if file length is smaller than expected ext.
|
||||
if (file.length() <= ext.length())
|
||||
|
@ -414,6 +428,67 @@ void deps_resolver_t::get_local_assemblies(const pal::string_t& dir)
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Resolve coreclr directory from the deps file.
|
||||
//
|
||||
// Description:
|
||||
// Look for CoreCLR from the dependency list in the package cache and then
|
||||
// the packages directory.
|
||||
//
|
||||
pal::string_t deps_resolver_t::resolve_coreclr_dir(
|
||||
const pal::string_t& app_dir,
|
||||
const pal::string_t& package_dir,
|
||||
const pal::string_t& package_cache_dir)
|
||||
{
|
||||
// Runtime servicing
|
||||
trace::verbose(_X("Probing for CoreCLR in servicing dir=[%s]"), m_runtime_svc.c_str());
|
||||
if (!m_runtime_svc.empty())
|
||||
{
|
||||
pal::string_t svc_clr = m_runtime_svc;
|
||||
append_path(&svc_clr, _X("runtime"));
|
||||
append_path(&svc_clr, _X("coreclr"));
|
||||
|
||||
if (coreclr_exists_in_dir(svc_clr))
|
||||
{
|
||||
return svc_clr;
|
||||
}
|
||||
}
|
||||
|
||||
// Package cache.
|
||||
trace::verbose(_X("Probing for CoreCLR in package cache=[%s] deps index: [%d]"), package_cache_dir.c_str(), m_coreclr_index);
|
||||
pal::string_t coreclr_cache;
|
||||
if (m_coreclr_index >= 0 && !package_cache_dir.empty() &&
|
||||
m_deps_entries[m_coreclr_index].to_hash_matched_path(package_cache_dir, &coreclr_cache))
|
||||
{
|
||||
return get_directory(coreclr_cache);
|
||||
}
|
||||
|
||||
// App dir.
|
||||
trace::verbose(_X("Probing for CoreCLR in app directory=[%s]"), app_dir.c_str());
|
||||
if (coreclr_exists_in_dir(app_dir))
|
||||
{
|
||||
return app_dir;
|
||||
}
|
||||
|
||||
// Packages dir
|
||||
trace::verbose(_X("Probing for CoreCLR in packages=[%s] deps index: [%d]"), package_dir.c_str(), m_coreclr_index);
|
||||
pal::string_t coreclr_package;
|
||||
if (m_coreclr_index >= 0 && !package_dir.empty() &&
|
||||
m_deps_entries[m_coreclr_index].to_full_path(package_dir, &coreclr_package))
|
||||
{
|
||||
return get_directory(coreclr_package);
|
||||
}
|
||||
|
||||
// Use platform-specific search algorithm
|
||||
pal::string_t install_dir;
|
||||
if (pal::find_coreclr(&install_dir))
|
||||
{
|
||||
return install_dir;
|
||||
}
|
||||
|
||||
return pal::string_t();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Resolve the TPA list order.
|
||||
//
|
||||
|
@ -549,11 +624,14 @@ void deps_resolver_t::resolve_probe_dirs(
|
|||
pal::string_t candidate;
|
||||
|
||||
// Take care of the secondary cache path
|
||||
for (const deps_entry_t& entry : m_deps_entries)
|
||||
if (!package_cache_dir.empty())
|
||||
{
|
||||
if (entry.asset_type == asset_type && entry.to_hash_matched_path(package_cache_dir, &candidate))
|
||||
for (const deps_entry_t& entry : m_deps_entries)
|
||||
{
|
||||
add_unique_path(asset_type, action(candidate), &items, output);
|
||||
if (entry.asset_type == asset_type && entry.to_hash_matched_path(package_cache_dir, &candidate))
|
||||
{
|
||||
add_unique_path(asset_type, action(candidate), &items, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,11 +639,14 @@ void deps_resolver_t::resolve_probe_dirs(
|
|||
add_unique_path(asset_type, app_dir, &items, output);
|
||||
|
||||
// Take care of the package restore path
|
||||
for (const deps_entry_t& entry : m_deps_entries)
|
||||
if (!package_dir.empty())
|
||||
{
|
||||
if (entry.asset_type == asset_type && entry.to_full_path(package_dir, &candidate))
|
||||
for (const deps_entry_t& entry : m_deps_entries)
|
||||
{
|
||||
add_unique_path(asset_type, action(candidate), &items, output);
|
||||
if (entry.asset_type == asset_type && entry.to_full_path(package_dir, &candidate))
|
||||
{
|
||||
add_unique_path(asset_type, action(candidate), &items, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ class deps_resolver_t
|
|||
public:
|
||||
deps_resolver_t(const arguments_t& args)
|
||||
: m_svc(args.dotnet_servicing)
|
||||
, m_runtime_svc(args.dotnet_runtime_servicing)
|
||||
, m_coreclr_index(-1)
|
||||
{
|
||||
m_deps_valid = parse_deps_file(args);
|
||||
}
|
||||
|
@ -56,6 +58,11 @@ public:
|
|||
const pal::string_t& clr_dir,
|
||||
probe_paths_t* probe_paths);
|
||||
|
||||
pal::string_t resolve_coreclr_dir(
|
||||
const pal::string_t& app_dir,
|
||||
const pal::string_t& package_dir,
|
||||
const pal::string_t& package_cache_dir);
|
||||
|
||||
private:
|
||||
|
||||
bool load();
|
||||
|
@ -85,6 +92,9 @@ private:
|
|||
// Servicing index to resolve serviced assembly paths.
|
||||
servicing_index_t m_svc;
|
||||
|
||||
// Runtime servicing directory.
|
||||
pal::string_t m_runtime_svc;
|
||||
|
||||
// Map of simple name -> full path of local assemblies populated in priority
|
||||
// order of their extensions.
|
||||
std::unordered_map<pal::string_t, pal::string_t> m_local_assemblies;
|
||||
|
@ -92,6 +102,9 @@ private:
|
|||
// Entries in the dep file
|
||||
std::vector<deps_entry_t> m_deps_entries;
|
||||
|
||||
// Special entry for coreclr in the deps entries
|
||||
int m_coreclr_index;
|
||||
|
||||
// The dep file path
|
||||
pal::string_t m_deps_path;
|
||||
|
||||
|
|
|
@ -20,59 +20,7 @@ enum StatusCode
|
|||
ResolverResolveFailure = 0x87,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// resolve_clr_path: Resolve CLR Path in priority order
|
||||
//
|
||||
// Description:
|
||||
// Check if CoreCLR library exists in runtime servicing dir or app
|
||||
// local or DOTNET_HOME directory in that order of priority. If these
|
||||
// fail to locate CoreCLR, then check platform-specific search.
|
||||
//
|
||||
// Returns:
|
||||
// "true" if path to the CoreCLR dir can be resolved in "clr_path"
|
||||
// parameter. Else, returns "false" with "clr_path" unmodified.
|
||||
//
|
||||
bool resolve_clr_path(const arguments_t& args, pal::string_t* clr_path)
|
||||
{
|
||||
const pal::string_t* dirs[] = {
|
||||
&args.dotnet_runtime_servicing, // DOTNET_RUNTIME_SERVICING
|
||||
&args.app_dir, // APP LOCAL
|
||||
&args.dotnet_home // DOTNET_HOME
|
||||
};
|
||||
for (int i = 0; i < sizeof(dirs) / sizeof(dirs[0]); ++i)
|
||||
{
|
||||
if (dirs[i]->empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// App dir should contain coreclr, so skip appending path.
|
||||
pal::string_t cur_dir = *dirs[i];
|
||||
if (dirs[i] != &args.app_dir)
|
||||
{
|
||||
append_path(&cur_dir, _X("runtime"));
|
||||
append_path(&cur_dir, _X("coreclr"));
|
||||
}
|
||||
|
||||
// Found coreclr in priority order.
|
||||
if (coreclr_exists_in_dir(cur_dir))
|
||||
{
|
||||
clr_path->assign(cur_dir);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Use platform-specific search algorithm
|
||||
pal::string_t home_dir = args.dotnet_home;
|
||||
if (pal::find_coreclr(&home_dir))
|
||||
{
|
||||
clr_path->assign(home_dir);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int run(const arguments_t& args, const pal::string_t& clr_path)
|
||||
int run(const arguments_t& args)
|
||||
{
|
||||
// Load the deps resolver
|
||||
deps_resolver_t resolver(args);
|
||||
|
@ -90,6 +38,17 @@ int run(const arguments_t& args, const pal::string_t& clr_path)
|
|||
}
|
||||
trace::info(_X("Package directory: %s"), packages_dir.empty() ? _X("not specified") : packages_dir.c_str());
|
||||
|
||||
pal::string_t clr_path = resolver.resolve_coreclr_dir(args.app_dir, packages_dir, args.dotnet_packages_cache);
|
||||
if (clr_path.empty() || !pal::realpath(&clr_path))
|
||||
{
|
||||
trace::error(_X("Could not resolve coreclr path"));
|
||||
return StatusCode::CoreClrResolveFailure;
|
||||
}
|
||||
else
|
||||
{
|
||||
trace::info(_X("CoreCLR directory: %s"), clr_path.c_str());
|
||||
}
|
||||
|
||||
probe_paths_t probe_paths;
|
||||
if (!resolver.resolve_probe_paths(args.app_dir, packages_dir, args.dotnet_packages_cache, clr_path, &probe_paths))
|
||||
{
|
||||
|
@ -240,13 +199,5 @@ SHARED_API int corehost_main(const int argc, const pal::char_t* argv[])
|
|||
return StatusCode::InvalidArgFailure;
|
||||
}
|
||||
|
||||
// Resolve CLR path
|
||||
pal::string_t clr_path;
|
||||
if (!resolve_clr_path(args, &clr_path))
|
||||
{
|
||||
trace::error(_X("Could not resolve coreclr path"));
|
||||
return StatusCode::CoreClrResolveFailure;
|
||||
}
|
||||
pal::realpath(&clr_path);
|
||||
return run(args, clr_path);
|
||||
return run(args);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ if(WIN32)
|
|||
endif()
|
||||
add_compile_options($<$<CONFIG:Debug>:-DDEBUG>)
|
||||
add_compile_options($<$<CONFIG:Debug>:/Od>)
|
||||
add_compile_options($<$<CONFIG:Debug>:/Gm>)
|
||||
add_compile_options(/DEBUG)
|
||||
add_compile_options(/GS)
|
||||
add_compile_options(/W1)
|
||||
|
|
|
@ -48,14 +48,19 @@
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define LIB_PREFIX
|
||||
#define MAKE_LIBNAME(NAME) (_X(NAME) _X(".dll"))
|
||||
#elif defined(__APPLE__)
|
||||
#define MAKE_LIBNAME(NAME) (_X("lib") _X(NAME) _X(".dylib"))
|
||||
#define LIB_PREFIX _X("lib")
|
||||
#define MAKE_LIBNAME(NAME) (LIB_PREFIX _X(NAME) _X(".dylib"))
|
||||
#else
|
||||
#define MAKE_LIBNAME(NAME) (_X("lib") _X(NAME) _X(".so"))
|
||||
#define LIB_PREFIX _X("lib")
|
||||
#define MAKE_LIBNAME(NAME) (LIB_PREFIX _X(NAME) _X(".so"))
|
||||
#endif
|
||||
|
||||
#define LIBCORECLR_FILENAME (LIB_PREFIX _X("coreclr"))
|
||||
#define LIBCORECLR_NAME MAKE_LIBNAME("coreclr")
|
||||
|
||||
#if !defined(PATH_MAX) && !defined(_WIN32)
|
||||
|
@ -118,7 +123,7 @@ namespace pal
|
|||
inline pal::string_t to_palstring(const std::string& str) { return str; }
|
||||
inline std::string to_stdstring(const pal::string_t& str) { return str; }
|
||||
inline void to_palstring(const char* str, pal::string_t* out) { out->assign(str); }
|
||||
inline void to_stdstring(const pal::char_t* str, std::string* out) { out->assign(str); }
|
||||
inline void to_stdstring(const char_t* str, std::string* out) { out->assign(str); }
|
||||
#endif
|
||||
bool realpath(string_t* path);
|
||||
bool file_exists(const string_t& path);
|
||||
|
|
|
@ -8,7 +8,7 @@ bool coreclr_exists_in_dir(const pal::string_t& candidate)
|
|||
{
|
||||
pal::string_t test(candidate);
|
||||
append_path(&test, LIBCORECLR_NAME);
|
||||
trace::verbose(_X("checking for CoreCLR in default location: %s"), test.c_str());
|
||||
trace::verbose(_X("Checking if CoreCLR path exists=[%s]"), test.c_str());
|
||||
return pal::file_exists(test);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel.Server;
|
||||
using Microsoft.DotNet.Tools.Build;
|
||||
|
@ -12,6 +11,7 @@ using Microsoft.DotNet.Tools.Compiler;
|
|||
using Microsoft.DotNet.Tools.Compiler.Csc;
|
||||
using Microsoft.DotNet.Tools.Compiler.Fsc;
|
||||
using Microsoft.DotNet.Tools.Compiler.Native;
|
||||
using Microsoft.DotNet.Tools.Help;
|
||||
using Microsoft.DotNet.Tools.New;
|
||||
using Microsoft.DotNet.Tools.Publish;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
@ -26,32 +26,6 @@ namespace Microsoft.DotNet.Cli
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
private const string ProductLongName = ".NET Command Line Tools";
|
||||
private const string UsageText = @"Usage: dotnet [common-options] [command] [arguments]
|
||||
|
||||
Arguments:
|
||||
[command] The command to execute
|
||||
[arguments] Arguments to pass to the command
|
||||
|
||||
Common Options (passed before the command):
|
||||
-v|--verbose Enable verbose output
|
||||
--version Display .NET CLI Version Info
|
||||
|
||||
Common Commands:
|
||||
new Initialize a basic .NET project
|
||||
restore Restore dependencies specified in the .NET project
|
||||
build Builds a .NET project
|
||||
publish Publishes a .NET project for deployment (including the runtime)
|
||||
run Compiles and immediately executes a .NET project
|
||||
repl Launch an interactive session (read, eval, print, loop)
|
||||
pack Creates a NuGet package";
|
||||
private static readonly string ProductVersion = GetProductVersion();
|
||||
|
||||
private static string GetProductVersion()
|
||||
{
|
||||
var attr = typeof(Program).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
return attr?.InformationalVersion;
|
||||
}
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
|
@ -74,7 +48,7 @@ Common Commands:
|
|||
{
|
||||
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
|
||||
|
||||
var verbose = false;
|
||||
bool? verbose = null;
|
||||
var success = true;
|
||||
var command = string.Empty;
|
||||
var lastArg = 0;
|
||||
|
@ -91,7 +65,7 @@ Common Commands:
|
|||
}
|
||||
else if (IsArg(args[lastArg], "h", "help"))
|
||||
{
|
||||
PrintHelp();
|
||||
HelpCommand.PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
else if (args[lastArg].StartsWith("-"))
|
||||
|
@ -108,15 +82,20 @@ Common Commands:
|
|||
}
|
||||
if (!success)
|
||||
{
|
||||
PrintHelp();
|
||||
HelpCommand.PrintHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
|
||||
|
||||
if (string.IsNullOrEmpty(command) || command.Equals("help", StringComparison.OrdinalIgnoreCase))
|
||||
if (verbose.HasValue)
|
||||
{
|
||||
return RunHelpCommand(appArgs);
|
||||
Environment.SetEnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString());
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
command = "help";
|
||||
}
|
||||
|
||||
var builtIns = new Dictionary<string, Func<string[], int>>
|
||||
|
@ -126,6 +105,7 @@ Common Commands:
|
|||
["compile-csc"] = CompileCscCommand.Run,
|
||||
["compile-fsc"] = CompileFscCommand.Run,
|
||||
["compile-native"] = CompileNativeCommand.Run,
|
||||
["help"] = HelpCommand.Run,
|
||||
["new"] = NewCommand.Run,
|
||||
["pack"] = PackCommand.Run,
|
||||
["projectmodel-server"] = ProjectModelServerCommand.Run,
|
||||
|
@ -140,55 +120,19 @@ Common Commands:
|
|||
Func<string[], int> builtIn;
|
||||
if (builtIns.TryGetValue(command, out builtIn))
|
||||
{
|
||||
// mimic the env variable
|
||||
Environment.SetEnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString());
|
||||
Environment.SetEnvironmentVariable(CommandContext.Variables.AnsiPassThru, bool.TrueString);
|
||||
return builtIn(appArgs.ToArray());
|
||||
}
|
||||
|
||||
return Command.Create("dotnet-" + command, appArgs, FrameworkConstants.CommonFrameworks.DnxCore50)
|
||||
.EnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString())
|
||||
.EnvironmentVariable(CommandContext.Variables.AnsiPassThru, bool.TrueString)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute()
|
||||
.ExitCode;
|
||||
}
|
||||
|
||||
private static int RunHelpCommand(IEnumerable<string> appArgs)
|
||||
{
|
||||
if (appArgs.Any())
|
||||
{
|
||||
return Command.Create("dotnet-" + appArgs.First(), new string[] { "--help" })
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute()
|
||||
.ExitCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintHelp()
|
||||
{
|
||||
PrintVersionHeader();
|
||||
Reporter.Output.WriteLine(UsageText);
|
||||
}
|
||||
|
||||
private static void PrintVersionHeader()
|
||||
{
|
||||
var versionString = string.IsNullOrEmpty(ProductVersion) ?
|
||||
string.Empty :
|
||||
$" ({ProductVersion})";
|
||||
Reporter.Output.WriteLine(ProductLongName + versionString);
|
||||
}
|
||||
|
||||
private static void PrintVersionInfo()
|
||||
{
|
||||
PrintVersionHeader();
|
||||
HelpCommand.PrintVersionHeader();
|
||||
|
||||
var runtimeEnvironment = PlatformServices.Default.Runtime;
|
||||
Reporter.Output.WriteLine("Runtime Environment:");
|
||||
|
|
|
@ -339,10 +339,10 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
args.Add(_args.ArchValue);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_args.IlcArgsValue))
|
||||
foreach (var ilcArg in _args.IlcArgsValue)
|
||||
{
|
||||
args.Add("--ilcargs");
|
||||
args.Add(_args.IlcArgsValue);
|
||||
args.Add("--ilcarg");
|
||||
args.Add(ilcArg);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_args.IlcPathValue))
|
||||
|
@ -404,6 +404,33 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
var libraryExporter = _rootProject.CreateExporter(_args.ConfigValue, _args.BuildBasePathValue);
|
||||
var executable = new Executable(_rootProject, outputPaths, libraryExporter);
|
||||
executable.MakeCompilationOutputRunnable();
|
||||
|
||||
PatchMscorlibNextToCoreClr(_rootProject, _args.ConfigValue);
|
||||
}
|
||||
|
||||
// Workaround: CoreCLR packaging doesn't include side by side mscorlib, so copy it at build
|
||||
// time. See: https://github.com/dotnet/cli/issues/1374
|
||||
private static void PatchMscorlibNextToCoreClr(ProjectContext context, string config)
|
||||
{
|
||||
{
|
||||
foreach (var exp in context.CreateExporter(config).GetAllExports())
|
||||
{
|
||||
var coreclrLib = exp.NativeLibraries.FirstOrDefault(nLib =>
|
||||
string.Equals(Constants.LibCoreClrFileName, nLib.Name));
|
||||
if (string.IsNullOrEmpty(coreclrLib.ResolvedPath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var coreclrDir = Path.GetDirectoryName(coreclrLib.ResolvedPath);
|
||||
if (File.Exists(Path.Combine(coreclrDir, "mscorlib.dll")) ||
|
||||
File.Exists(Path.Combine(coreclrDir, "mscorlib.ni.dll")))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var mscorlibFile = exp.RuntimeAssemblies.FirstOrDefault(r => r.Name.Equals("mscorlib") || r.Name.Equals("mscorlib.ni")).ResolvedPath;
|
||||
File.Copy(mscorlibFile, Path.Combine(coreclrDir, Path.GetFileName(mscorlibFile)), overwrite: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ISet<ProjectDescription> Sort(Dictionary<string, ProjectDescription> projects)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
public ArchitectureMode Architecture { get; set; }
|
||||
public NativeIntermediateMode? NativeMode { get; set; }
|
||||
public IEnumerable<string> ReferencePaths { get; set; }
|
||||
public string IlcArgs { get; set; }
|
||||
public IEnumerable<string> IlcArgs { get; set; }
|
||||
public IEnumerable<string> LinkLibPaths { get; set; }
|
||||
public string AppDepSDKPath { get; set; }
|
||||
public string IlcPath { get; set; }
|
||||
|
@ -88,7 +88,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
config.LogPath = LogPath;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(IlcArgs))
|
||||
if (IlcArgs != null)
|
||||
{
|
||||
config.IlcArgs = IlcArgs;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.CommandLine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
|
@ -15,7 +16,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
BuildConfiguration? buildConfiguration = null;
|
||||
string mode = null;
|
||||
NativeIntermediateMode? nativeMode = null;
|
||||
string ilcArgs = null;
|
||||
IReadOnlyList<string> ilcArgs = Array.Empty<string>();
|
||||
IEnumerable<string> unquotIlcArgs = Array.Empty<string>();
|
||||
string ilcPath = null;
|
||||
string ilcSdkPath = null;
|
||||
string appDepSdk = null;
|
||||
|
@ -26,7 +28,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
string cppCompilerFlags = null;
|
||||
|
||||
IReadOnlyList<string> references = Array.Empty<string>();
|
||||
IReadOnlyList<string> linklib = Array.Empty<string>();
|
||||
IReadOnlyList<string> linklib = Array.Empty<string>();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -46,7 +48,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
"Use to specify Managed DLL references of the app.");
|
||||
|
||||
// Custom Extensibility Points to support CoreRT workflow TODO better descriptions
|
||||
syntax.DefineOption("ilcargs", ref ilcArgs, "Use to specify custom arguments for the IL Compiler.");
|
||||
syntax.DefineOptionList("ilcarg", ref ilcArgs, "Use to specify custom arguments for the IL Compiler.");
|
||||
syntax.DefineOption("ilcpath", ref ilcPath, "Use to specify a custom build of IL Compiler.");
|
||||
syntax.DefineOption("ilcsdkpath", ref ilcSdkPath, "Use to specify a custom build of IL Compiler SDK");
|
||||
|
||||
|
@ -67,7 +69,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
"The managed input assembly to compile to native.");
|
||||
|
||||
helpText = syntax.GetHelpText();
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(inputAssembly))
|
||||
{
|
||||
syntax.ReportError("Input Assembly is a required parameter.");
|
||||
|
@ -99,6 +101,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
help = true;
|
||||
}
|
||||
}
|
||||
|
||||
unquotIlcArgs = ilcArgs.Select(s =>
|
||||
{
|
||||
if (!s.StartsWith("\"") || !s.EndsWith("\""))
|
||||
{
|
||||
throw new ArgumentSyntaxException("--ilcarg must be specified in double quotes");
|
||||
}
|
||||
return s.Substring(1, s.Length - 2);
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (ArgumentSyntaxException exception)
|
||||
|
@ -130,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
BuildConfiguration = buildConfiguration,
|
||||
NativeMode = nativeMode,
|
||||
ReferencePaths = references,
|
||||
IlcArgs = ilcArgs,
|
||||
IlcArgs = unquotIlcArgs,
|
||||
IlcPath = ilcPath,
|
||||
IlcSdkPath = ilcSdkPath,
|
||||
LinkLibPaths = linklib,
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
public class ILCompilerInvoker
|
||||
{
|
||||
private readonly string ExecutableName = "corerun" + Constants.ExeSuffix;
|
||||
private readonly string ILCompiler = "ilc.exe";
|
||||
private static readonly string HostExeName = "corerun" + Constants.ExeSuffix;
|
||||
private static readonly string ILCompiler = "ilc.exe";
|
||||
|
||||
private IEnumerable<string> Args;
|
||||
private NativeCompileSettings config;
|
||||
|
||||
|
@ -27,14 +29,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
var argsList = new List<string>();
|
||||
|
||||
var managedPath = Path.Combine(config.IlcPath, ILCompiler);
|
||||
if (!File.Exists(managedPath))
|
||||
{
|
||||
throw new FileNotFoundException("Unable to find ILCompiler at " + managedPath);
|
||||
}
|
||||
|
||||
argsList.Add($"{managedPath}");
|
||||
|
||||
// Input File
|
||||
var inputFilePath = config.InputManagedAssemblyPath;
|
||||
argsList.Add($"{inputFilePath}");
|
||||
|
@ -43,32 +37,29 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var coreLibsPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var reference in Directory.EnumerateFiles(coreLibsPath, "*.dll"))
|
||||
{
|
||||
argsList.Add($"-r");
|
||||
argsList.Add($"{reference}");
|
||||
argsList.Add($"-r:{reference}");
|
||||
}
|
||||
|
||||
// AppDep References
|
||||
foreach (var reference in config.ReferencePaths)
|
||||
{
|
||||
argsList.Add($"-r");
|
||||
argsList.Add($"{reference}");
|
||||
argsList.Add($"-r:{reference}");
|
||||
}
|
||||
|
||||
// Set Output DetermineOutFile
|
||||
var outFile = DetermineOutputFile(config);
|
||||
argsList.Add($"-out");
|
||||
argsList.Add($"{outFile}");
|
||||
argsList.Add($"-o:{outFile}");
|
||||
|
||||
// Add Mode Flag TODO
|
||||
if (config.NativeMode == NativeIntermediateMode.cpp)
|
||||
{
|
||||
argsList.Add("-cpp");
|
||||
argsList.Add("--cpp");
|
||||
}
|
||||
|
||||
// Custom Ilc Args support
|
||||
if (! string.IsNullOrEmpty(config.IlcArgs))
|
||||
foreach (var ilcArg in config.IlcArgs)
|
||||
{
|
||||
argsList.Add(config.IlcArgs);
|
||||
argsList.Add(ilcArg);
|
||||
}
|
||||
|
||||
Args = argsList;
|
||||
|
@ -76,9 +67,20 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
public int Invoke()
|
||||
{
|
||||
var executablePath = Path.Combine(config.IlcPath, ExecutableName);
|
||||
|
||||
var result = Command.Create(executablePath, Args)
|
||||
// Check if ILCompiler is present
|
||||
var ilcExePath = Path.Combine(config.IlcPath, ILCompiler);
|
||||
if (!File.Exists(ilcExePath))
|
||||
{
|
||||
throw new FileNotFoundException("Unable to find ILCompiler at " + ilcExePath);
|
||||
}
|
||||
|
||||
// Write the response file
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
var rsp = Path.Combine(intermediateDirectory, "dotnet-compile-native-ilc.rsp");
|
||||
File.WriteAllLines(rsp, Args, Encoding.UTF8);
|
||||
|
||||
var hostPath = Path.Combine(config.IlcPath, HostExeName);
|
||||
var result = Command.Create(hostPath, new string[] { ilcExePath, "@" + $"{rsp}" })
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private readonly string[] _appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
"System.Native.a"
|
||||
};
|
||||
|
||||
public LinuxCppCompileStep(NativeCompileSettings config)
|
||||
|
@ -121,4 +121,4 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return outfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private readonly string[] _appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
"System.Native.a"
|
||||
};
|
||||
|
||||
public LinuxRyuJitCompileStep(NativeCompileSettings config)
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private readonly string[] _appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
"System.Native.a"
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private readonly string[] appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
"System.Native.a"
|
||||
};
|
||||
|
||||
public MacRyuJitCompileStep(NativeCompileSettings config)
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
private string _outputDirectory;
|
||||
private string _intermediateDirectory;
|
||||
private string _logPath;
|
||||
private string _ilcArgs;
|
||||
private readonly List<string> _referencePaths;
|
||||
private IEnumerable<string> _ilcArgs;
|
||||
private readonly Dictionary<string, string> _referencePaths;
|
||||
private readonly List<string> _linkLibPaths;
|
||||
private string _cppCompilerFlags;
|
||||
|
||||
|
@ -81,12 +81,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
get
|
||||
{
|
||||
return _referencePaths;
|
||||
return _referencePaths.Values;
|
||||
}
|
||||
}
|
||||
|
||||
// Optional Customization Points (Can be null)
|
||||
public string IlcArgs
|
||||
public IEnumerable<string> IlcArgs
|
||||
{
|
||||
get { return _ilcArgs; }
|
||||
set { _ilcArgs = value; }
|
||||
|
@ -168,8 +168,11 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
BuildType = DefaultBuiltType;
|
||||
NativeMode = DefaultNativeModel;
|
||||
AppDepSDKPath = Path.Combine(AppContext.BaseDirectory, "appdepsdk");
|
||||
|
||||
_referencePaths = new List<string>(Directory.EnumerateFiles(AppDepSDKPath, "*.dll"));
|
||||
_referencePaths = new Dictionary<string, string>();
|
||||
foreach (var file in Directory.EnumerateFiles(AppDepSDKPath, "*.dll"))
|
||||
{
|
||||
_referencePaths.Add(Path.GetFileName(file), file);
|
||||
}
|
||||
}
|
||||
|
||||
public static NativeCompileSettings Default
|
||||
|
@ -198,7 +201,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
public void AddReference(string reference)
|
||||
{
|
||||
_referencePaths.Add(Path.GetFullPath(reference));
|
||||
var path = Path.GetFullPath(reference);
|
||||
var simpleName = Path.GetFileName(path);
|
||||
if (!_referencePaths.ContainsKey(simpleName))
|
||||
{
|
||||
_referencePaths.Add(simpleName, path);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLinkLibPath(string linkLibPath)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"Microsoft.DotNet.AppDep":"1.0.5-prerelease-00001"
|
||||
"Microsoft.DotNet.AppDep":"1.0.6-prerelease-00001"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
public string ConfigValue { get; set; }
|
||||
public bool IsNativeValue { get; set; }
|
||||
public string ArchValue { get; set; }
|
||||
public string IlcArgsValue { get; set; }
|
||||
public IEnumerable<string> IlcArgsValue { get; set; }
|
||||
public string IlcPathValue { get; set; }
|
||||
public string IlcSdkPathValue { get; set; }
|
||||
public bool IsCppModeValue { get; set; }
|
||||
|
@ -83,7 +83,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
// Native Args
|
||||
_nativeOption = _app.Option("-n|--native", "Compiles source to native machine code.", CommandOptionType.NoValue);
|
||||
_archOption = _app.Option("-a|--arch <ARCH>", "The architecture for which to compile. x64 only currently supported.", CommandOptionType.SingleValue);
|
||||
_ilcArgsOption = _app.Option("--ilcargs <ARGS>", "Command line arguments to be passed directly to ILCompiler.", CommandOptionType.SingleValue);
|
||||
_ilcArgsOption = _app.Option("--ilcarg <ARG>", "Command line option to be passed directly to ILCompiler.", CommandOptionType.MultipleValue);
|
||||
_ilcPathOption = _app.Option("--ilcpath <PATH>", "Path to the folder containing custom built ILCompiler.", CommandOptionType.SingleValue);
|
||||
_ilcSdkPathOption = _app.Option("--ilcsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
|
||||
_appDepSdkPathOption = _app.Option("--appdepsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
|
||||
|
@ -109,7 +109,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
IsNativeValue = _nativeOption.HasValue();
|
||||
ArchValue = _archOption.Value();
|
||||
IlcArgsValue = _ilcArgsOption.Value();
|
||||
IlcArgsValue = _ilcArgsOption.HasValue() ? _ilcArgsOption.Values : Enumerable.Empty<string>();
|
||||
IlcPathValue = _ilcPathOption.Value();
|
||||
IlcSdkPathValue = _ilcSdkPathOption.Value();
|
||||
AppDepSdkPathValue = _appDepSdkPathOption.Value();
|
||||
|
@ -170,4 +170,4 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
return baseClassOptions.TryGetValue(optionTemplate, out option) && option.HasValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler
|
||||
|
@ -22,16 +23,37 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
var managedOutput = outputPaths.CompilationFiles.Assembly;
|
||||
|
||||
// Create the library exporter
|
||||
var exporter = context.CreateExporter(args.ConfigValue);
|
||||
|
||||
// Gather exports for the project
|
||||
var exports = exporter.GetAllExports();
|
||||
|
||||
// Runtime assemblies.
|
||||
// TODO: native assets/resources.
|
||||
var references = exports
|
||||
.SelectMany(export => export.RuntimeAssemblies)
|
||||
.Select(r => r.ResolvedPath)
|
||||
.ToList();
|
||||
|
||||
// Setup native args.
|
||||
var nativeArgs = new List<string>();
|
||||
|
||||
// Input Assembly
|
||||
nativeArgs.Add($"{managedOutput}");
|
||||
|
||||
// ILC Args
|
||||
if (!string.IsNullOrWhiteSpace(args.IlcArgsValue))
|
||||
// Add Resolved Assembly References
|
||||
foreach (var reference in references)
|
||||
{
|
||||
nativeArgs.Add("--ilcargs");
|
||||
nativeArgs.Add($"{args.IlcArgsValue}");
|
||||
nativeArgs.Add("--reference");
|
||||
nativeArgs.Add(reference);
|
||||
}
|
||||
|
||||
// ILC Args
|
||||
foreach (var ilcArg in args.IlcArgsValue)
|
||||
{
|
||||
nativeArgs.Add("--ilcarg");
|
||||
nativeArgs.Add($"\"{ilcArg}\"");
|
||||
}
|
||||
|
||||
// ILC Path
|
||||
|
|
65
src/dotnet/commands/dotnet-help/HelpCommand.cs
Normal file
65
src/dotnet/commands/dotnet-help/HelpCommand.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
// 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.Reflection;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Help
|
||||
{
|
||||
public class HelpCommand
|
||||
{
|
||||
private const string ProductLongName = ".NET Command Line Tools";
|
||||
private const string UsageText = @"Usage: dotnet [common-options] [command] [arguments]
|
||||
|
||||
Arguments:
|
||||
[command] The command to execute
|
||||
[arguments] Arguments to pass to the command
|
||||
|
||||
Common Options (passed before the command):
|
||||
-v|--verbose Enable verbose output
|
||||
--version Display .NET CLI Version Info
|
||||
|
||||
Common Commands:
|
||||
new Initialize a basic .NET project
|
||||
restore Restore dependencies specified in the .NET project
|
||||
build Builds a .NET project
|
||||
publish Publishes a .NET project for deployment (including the runtime)
|
||||
run Compiles and immediately executes a .NET project
|
||||
repl Launch an interactive session (read, eval, print, loop)
|
||||
pack Creates a NuGet package";
|
||||
private static readonly string ProductVersion = GetProductVersion();
|
||||
|
||||
private static string GetProductVersion()
|
||||
{
|
||||
var attr = typeof(HelpCommand).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
return attr?.InformationalVersion;
|
||||
}
|
||||
|
||||
public static int Run(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Cli.Program.Main(new[] { args[0], "--help" });
|
||||
}
|
||||
}
|
||||
|
||||
public static void PrintHelp()
|
||||
{
|
||||
PrintVersionHeader();
|
||||
Reporter.Output.WriteLine(UsageText);
|
||||
}
|
||||
|
||||
public static void PrintVersionHeader()
|
||||
{
|
||||
var versionString = string.IsNullOrEmpty(ProductVersion) ?
|
||||
string.Empty :
|
||||
$" ({ProductVersion})";
|
||||
Reporter.Output.WriteLine(ProductLongName + versionString);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,13 +24,13 @@
|
|||
"Microsoft.CodeAnalysis.CSharp": "1.2.0-beta1-20160202-02",
|
||||
"Microsoft.DiaSymReader.Native": "1.3.3",
|
||||
|
||||
"NuGet.CommandLine.XPlat": "3.4.0-beta-583",
|
||||
"NuGet.CommandLine.XPlat": "3.4.0-beta-625",
|
||||
"System.CommandLine": "0.1.0-e160119-1",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.DotNet.ILCompiler.SDK": "1.0.5-prerelease-00002",
|
||||
"Microsoft.DotNet.ILCompiler.SDK": "1.0.6-prerelease-00003",
|
||||
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-16040",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-16040",
|
||||
|
@ -47,14 +47,11 @@
|
|||
"version": "1.0.0-rc2-16453",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Extensions.Testing.Abstractions": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Extensions.Testing.Abstractions": "1.0.0-*",
|
||||
"Microsoft.NETCore.ConsoleHost": "1.0.0-rc2-23811",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23811",
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Reflection.Metadata": "1.2.0-rc3-23811",
|
||||
"System.Reflection.Metadata": "1.3.0-beta-23811",
|
||||
"System.Diagnostics.TextWriterTraceListener": "4.0.0-rc2-23811",
|
||||
"System.Diagnostics.TraceSource": "4.0.0-rc2-23811",
|
||||
"System.Linq.Expressions": "4.0.11-rc2-23811",
|
||||
|
|
|
@ -81,7 +81,6 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(712, PlatformID.Windows | PlatformID.OSX | PlatformID.Linux)]
|
||||
public void TestDotnetBuildNativeRyuJit()
|
||||
{
|
||||
if(IsCentOS())
|
||||
|
@ -170,6 +169,20 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
TestExecutable(OutputDirectory, publishCommand.GetOutputExecutable(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDotnetHelp()
|
||||
{
|
||||
var helpCommand = new HelpCommand();
|
||||
helpCommand.Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDotnetHelpBuild()
|
||||
{
|
||||
var helpCommand = new HelpCommand();
|
||||
helpCommand.Execute("build").Should().Pass();
|
||||
}
|
||||
|
||||
private void TestInstanceSetup()
|
||||
{
|
||||
var root = Temp.CreateDirectory();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
public sealed class HelpCommand : TestCommand
|
||||
{
|
||||
public HelpCommand()
|
||||
: base("dotnet")
|
||||
{
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string args = "")
|
||||
{
|
||||
args = $"help {args}";
|
||||
return base.Execute(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
"target": "project"
|
||||
},
|
||||
|
||||
"xunit": "2.1.0",
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
"target": "project"
|
||||
},
|
||||
|
||||
"xunit": "2.1.0",
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
"target": "project"
|
||||
},
|
||||
|
||||
"dotnet": { "target": "project" },
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
"Microsoft.DotNet.TestFramework": "1.0.0-*",
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
"target": "project"
|
||||
},
|
||||
|
||||
"xunit": "2.1.0",
|
||||
|
|
Loading…
Add table
Reference in a new issue