Merge rel/1.0.0 into feature/msbuild.

This commit is contained in:
Eric Erhardt 2016-07-18 14:44:06 -05:00
commit d2db776d87
34 changed files with 204 additions and 631 deletions

View file

@ -30,7 +30,7 @@ In order to build .NET Command Line Interface, you need the following installed
## Building/Running
1. Run `build.cmd` or `build.sh` from the root depending on your OS. If you don't want to execute tests, run `build.cmd -Targets Compile` or `./build.sh --targets Compile`.
1. Run `build.cmd` or `build.sh` from the root depending on your OS. If you don't want to execute tests, run `build.cmd -Targets Prepare,Compile` or `./build.sh --targets Prepare,Compile`.
2. Use `artifacts/{os}-{arch}/stage2/dotnet` to try out the `dotnet` command. You can also add `artifacts/{os}-{arch}/stage2` to the PATH if you want to run `dotnet` from anywhere.
## A simple test

View file

@ -36,7 +36,7 @@ The files are both JSON files stored in UTF-8 encoding. Below are sample files.
"framework": {
"name": "Microsoft.DotNetCore",
"version": "1.0.1"
}
},
"applyPatches": false
}

View file

@ -4,17 +4,12 @@
This repo contains the source code for cross-platform [.NET Core](http://github.com/dotnet/core) command line toolchain. It contains the implementation of each command, the native packages for various supported platforms as well as documentation.
RC2 and Preview 1 bits
RTM and Preview 2 bits
---------------------
To get the latest released bits (RC2 for .NET Core and Preview for tooling),
To get the latest released bits (RTM for .NET Core and Preview 2 for tooling),
check out our [Getting started page](http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409).
Also, don't forget to check out [the documentation](http://dotnet.github.io/docs/core-concepts/core-sdk/index.html).
Release schedule
----------------
There have been some changes in the schedule for .NET Core and .NET Core CLI tools. You can read more about them in the [.NET Core RC2 Improvements, Schedule, and Roadmap](https://blogs.msdn.microsoft.com/dotnet/2016/05/06/net-core-rc2-improvements-schedule-and-roadmap/) blog post.
Also, don't forget to check out [the documentation](https://aka.ms/dotnet-cli-docs).
Found an issue?
---------------
@ -41,7 +36,7 @@ You can download .NET Core as either an installer (MSI, PKG) or a zip (zip, gzip
- .NET Core SDK - .NET Core + CLI tools
> **Note:** please be aware that below installers are the **latest bits**. If you
> want to install the latest released versions, please check out the [section above](#rc2-and-preview-1-bits).)
> want to install the latest released versions, please check out the [section above](#rtm-and-preview-2-bits).)
| |Version |.NET Core Installer|.NET Core SDK Installer|.NET Core Binaries|.NET Core SDK Binaries|
|---------|:------:|:------:|:------:|:------:|:------:|
@ -98,7 +93,7 @@ Compiling to IL is done using:
This will drop an IL assembly in `./bin/[configuration]/[framework]/[binary name]`
that you can run using `dotnet bin/[configuration]/[framework]/[binaryname.dll]`.
For more details, please refer to the [documentation](http://dotnet.github.io/docs/core-concepts/core-sdk/index.html).
For more details, please refer to the [documentation](https://aka.ms/dotnet-cli-docs).
Building from source
--------------------
@ -115,5 +110,5 @@ For any and all feedback, please use the Issues on this repository.
License
--------------------
By downloading the .zip you are agreeing to the terms in the project [EULA](https://aka.ms/dotnet-cli-eula).
By downloading the .zip you are agreeing to the terms in the project [EULA](https://aka.ms/dotnet-core-eula).

View file

@ -20,11 +20,12 @@
"files": {
"includeFiles": "packfiles/pack1.txt",
"mappings": {
"newpath/": "packfiles/pack2.txt"
"newpath/": "packfiles/pack2.txt",
"anotherpath/": "packfiles/pack2.txt"
}
}
},
"publishOptions": "testpublishfile.txt",
"publishOptions": [ "testpublishfile.txt", "publishfiles" ],
"frameworks": {
"netcoreapp1.0": {}
},

View file

@ -3,5 +3,5 @@
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
powershell -NoProfile -NoLogo -Command "%~dp0run-build.ps1 %*; exit $LastExitCode;"
powershell -NoProfile -NoLogo -Command "& \"%~dp0run-build.ps1\" %*; exit $LastExitCode;"
if %errorlevel% neq 0 exit /b %errorlevel%

View file

@ -69,7 +69,7 @@ namespace Microsoft.DotNet.Cli.Build.Framework
{
foreach (var targetOverride in _overrides)
{
Reporter.Verbose.WriteLine($"Target {targetOverride.Name} from {targetOverride.OriginalSource} was overridden in {targetOverride.OverrideSource}".Black());
Reporter.Verbose.WriteLine($"Target {targetOverride.Name} from {targetOverride.OriginalSource} was overridden in {targetOverride.OverrideSource}");
}
}

View file

@ -1,30 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using Microsoft.DotNet.Cli.Build.Framework;
namespace Microsoft.DotNet.Scripts
{
public static class BuildContextProperties
{
public static List<DependencyInfo> GetDependencyInfos(this BuildTargetContext c)
{
const string propertyName = "DependencyInfos";
List<DependencyInfo> dependencyInfos;
object dependencyInfosObj;
if (c.BuildContext.Properties.TryGetValue(propertyName, out dependencyInfosObj))
{
dependencyInfos = (List<DependencyInfo>)dependencyInfosObj;
}
else
{
dependencyInfos = new List<DependencyInfo>();
c.BuildContext[propertyName] = dependencyInfos;
}
return dependencyInfos;
}
}
}

View file

@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using Microsoft.DotNet.Cli.Build.Framework;
namespace Microsoft.DotNet.Scripts
{
@ -18,10 +17,10 @@ namespace Microsoft.DotNet.Scripts
///
/// The following Environment Variables can optionally be specified:
///
/// COREFX_VERSION_URL - The Url to get the current CoreFx package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt")
/// CORECLR_VERSION_URL - The Url to get the current CoreCLR version. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0/Latest_Packages.txt")
/// ROSLYN_VERSION_URL - The Url to get the current Roslyn version. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0/Latest_Packages.txt")
/// CORESETUP_VERSION_URL - The Url to get the current dotnet/core-setup package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0/Latest_Packages.txt")
/// COREFX_VERSION_URL - The Url to get the current CoreFx package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0")
/// CORECLR_VERSION_URL - The Url to get the current CoreCLR version. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0")
/// ROSLYN_VERSION_URL - The Url to get the current Roslyn version. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0")
/// CORESETUP_VERSION_URL - The Url to get the current dotnet/core-setup package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0")
/// GITHUB_ORIGIN_OWNER - The owner of the GitHub fork to push the commit and create the PR from. (ex. "dotnet-bot")
/// GITHUB_UPSTREAM_OWNER - The owner of the GitHub base repo to create the PR to. (ex. "dotnet")
/// GITHUB_PROJECT - The repo name under the ORIGIN and UPSTREAM owners. (ex. "cli")
@ -36,11 +35,10 @@ namespace Microsoft.DotNet.Scripts
private Lazy<string> _email = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_EMAIL"));
private Lazy<string> _password = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PASSWORD"));
private Lazy<string> _coreFxVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt"));
private Lazy<string> _coreClrVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORECLR_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0/Latest_Packages.txt"));
private Lazy<string> _roslynVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("ROSLYN_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0/Latest_Packages.txt"));
private Lazy<string> _coreSetupVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0/Latest_Packages.txt"));
private Lazy<string> _gitHubOriginOwner;
private Lazy<string> _coreFxVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0"));
private Lazy<string> _coreClrVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORECLR_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0"));
private Lazy<string> _roslynVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("ROSLYN_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0"));
private Lazy<string> _coreSetupVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0"));
private Lazy<string> _gitHubUpstreamOwner = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet"));
private Lazy<string> _gitHubProject = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli"));
private Lazy<string> _gitHubUpstreamBranch = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", "rel/1.0.0"));
@ -50,7 +48,6 @@ namespace Microsoft.DotNet.Scripts
private Config()
{
_gitHubOriginOwner = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_ORIGIN_OWNER", UserName));
}
public string UserName => _userName.Value;
@ -60,7 +57,6 @@ namespace Microsoft.DotNet.Scripts
public string CoreClrVersionUrl => _coreClrVersionUrl.Value;
public string RoslynVersionUrl => _roslynVersionUrl.Value;
public string CoreSetupVersionUrl => _coreSetupVersionUrl.Value;
public string GitHubOriginOwner => _gitHubOriginOwner.Value;
public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value;
public string GitHubProject => _gitHubProject.Value;
public string GitHubUpstreamBranch => _gitHubUpstreamBranch.Value;
@ -76,7 +72,7 @@ namespace Microsoft.DotNet.Scripts
if (value == null)
{
throw new BuildFailureException($"Can't find environment variable '{name}'.");
throw new InvalidOperationException($"Can't find environment variable '{name}'.");
}
return value;

View file

@ -1,23 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using NuGet.Versioning;
namespace Microsoft.DotNet.Scripts
{
public class DependencyInfo
{
public string Name { get; set; }
public List<PackageInfo> NewVersions { get; set; }
public string NewReleaseVersion { get; set; }
public bool IsUpdated { get; set; }
}
public class PackageInfo
{
public string Id { get; set; }
public NuGetVersion Version { get; set; }
}
}

View file

@ -1,25 +1,97 @@
// 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.Build.Framework;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.VersionTools;
using Microsoft.DotNet.VersionTools.Automation;
using Microsoft.DotNet.VersionTools.Dependencies;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Microsoft.DotNet.Scripts
{
public class Program
{
public static int Main(string[] args)
private static readonly Config s_config = Config.Instance;
public static void Main(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
return BuildSetup.Create(".NET CLI Dependency Updater")
.UseTargets(new[]
{
new BuildTarget("Default", "Dependency Updater Goals", new [] { "UpdateFiles", "PushPR" }),
new BuildTarget("UpdateFiles", "Dependency Updater Goals"),
new BuildTarget("PushPR", "Dependency Updater Goals"),
})
.UseAllTargetsFromAssembly<Program>()
.Run(args);
List<BuildInfo> buildInfos = new List<BuildInfo>();
buildInfos.Add(BuildInfo.Get("CoreFx", s_config.CoreFxVersionUrl, fetchLatestReleaseFile: false));
buildInfos.Add(BuildInfo.Get("CoreClr", s_config.CoreClrVersionUrl, fetchLatestReleaseFile: false));
buildInfos.Add(BuildInfo.Get("Roslyn", s_config.RoslynVersionUrl, fetchLatestReleaseFile: false));
buildInfos.Add(BuildInfo.Get("CoreSetup", s_config.CoreSetupVersionUrl, fetchLatestReleaseFile: false));
IEnumerable<IDependencyUpdater> updaters = GetUpdaters();
GitHubAuth gitHubAuth = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
DependencyUpdater dependencyUpdater = new DependencyUpdater(
gitHubAuth,
s_config.GitHubProject,
s_config.GitHubUpstreamOwner,
s_config.GitHubUpstreamBranch,
s_config.UserName,
s_config.GitHubPullRequestNotifications);
if (args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase))
{
dependencyUpdater.Update(updaters, buildInfos);
}
else
{
dependencyUpdater.UpdateAndSubmitPullRequestAsync(updaters, buildInfos);
}
}
private static IEnumerable<IDependencyUpdater> GetUpdaters()
{
yield return CreateProjectJsonUpdater();
yield return CreateRegexUpdater(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR");
yield return CreateRegexUpdater(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", "JitVersion", "Microsoft.NETCore.Jit");
yield return CreateRegexUpdater(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", "SharedFrameworkVersion", "Microsoft.NETCore.App");
yield return CreateRegexUpdater(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", "HostFxrVersion", "Microsoft.NETCore.DotNetHostResolver");
yield return CreateRegexUpdater(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", "SharedHostVersion", "Microsoft.NETCore.DotNetHost");
}
private static IDependencyUpdater CreateProjectJsonUpdater()
{
IEnumerable<string> projectJsonFiles = GetProjectJsonsToUpdate();
return new ProjectJsonUpdater(projectJsonFiles)
{
SkipStableVersions = false
};
}
private static IEnumerable<string> GetProjectJsonsToUpdate()
{
const string noUpdateFileName = ".noautoupdate";
return Enumerable.Union(
Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories),
Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.template", SearchOption.AllDirectories))
.Where(p => !File.Exists(Path.Combine(Path.GetDirectoryName(p), noUpdateFileName)) &&
!Path.GetDirectoryName(p).EndsWith("CSharp_Web", StringComparison.Ordinal));
}
private static IDependencyUpdater CreateRegexUpdater(string repoRelativePath, string dependencyPropertyName, string packageId)
{
return new FileRegexPackageUpdater()
{
Path = Path.Combine(Dirs.RepoRoot, repoRelativePath),
PackageId = packageId,
Regex = new Regex($@"{dependencyPropertyName} = ""(?<version>.*)"";"),
VersionGroupName = "version"
};
}
}
}

View file

@ -1,162 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Linq;
using Microsoft.DotNet.Cli.Build.Framework;
using Octokit;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Scripts
{
/// <summary>
/// Creates a GitHub Pull Request for the current changes in the repo.
/// </summary>
public static class PushPRTargets
{
private static readonly Config s_config = Config.Instance;
[Target(nameof(CommitChanges), nameof(CreatePR))]
public static BuildTargetResult PushPR(BuildTargetContext c) => c.Success();
/// <summary>
/// Commits all the current changes in the repo and pushes the commit to a remote
/// so a PR can be created for it.
/// </summary>
[Target]
public static BuildTargetResult CommitChanges(BuildTargetContext c)
{
CommandResult statusResult = Cmd("git", "status", "--porcelain")
.CaptureStdOut()
.Execute();
statusResult.EnsureSuccessful();
bool hasModifiedFiles = !string.IsNullOrWhiteSpace(statusResult.StdOut);
bool hasUpdatedDependencies = c.GetDependencyInfos().Where(d => d.IsUpdated).Any();
if (hasModifiedFiles != hasUpdatedDependencies)
{
return c.Failed($"'git status' does not match DependencyInfo information. Git has modified files: {hasModifiedFiles}. DependencyInfo is updated: {hasUpdatedDependencies}.");
}
if (!hasUpdatedDependencies)
{
c.Warn("Dependencies are currently up to date");
return c.Success();
}
string userName = s_config.UserName;
string email = s_config.Email;
string commitMessage = GetCommitMessage(c);
Cmd("git", "commit", "-a", "-m", commitMessage, "--author", $"{userName} <{email}>")
.EnvironmentVariable("GIT_COMMITTER_NAME", userName)
.EnvironmentVariable("GIT_COMMITTER_EMAIL", email)
.Execute()
.EnsureSuccessful();
string remoteUrl = $"github.com/{s_config.GitHubOriginOwner}/{s_config.GitHubProject}.git";
string remoteBranchName = $"UpdateDependencies{DateTime.UtcNow.ToString("yyyyMMddhhmmss")}";
string refSpec = $"HEAD:refs/heads/{remoteBranchName}";
string logMessage = $"git push https://{remoteUrl} {refSpec}";
BuildReporter.BeginSection("EXEC", logMessage);
CommandResult pushResult =
Cmd("git", "push", $"https://{userName}:{s_config.Password}@{remoteUrl}", refSpec)
.QuietBuildReporter() // we don't want secrets showing up in our logs
.CaptureStdErr() // git push will write to StdErr upon success, disable that
.CaptureStdOut()
.Execute();
var message = logMessage + $" exited with {pushResult.ExitCode}";
if (pushResult.ExitCode == 0)
{
BuildReporter.EndSection("EXEC", message.Green(), success: true);
}
else
{
BuildReporter.EndSection("EXEC", message.Red().Bold(), success: false);
}
pushResult.EnsureSuccessful(suppressOutput: true);
c.SetRemoteBranchName(remoteBranchName);
return c.Success();
}
/// <summary>
/// Creates a GitHub PR for the remote branch created above.
/// </summary>
[Target]
public static BuildTargetResult CreatePR(BuildTargetContext c)
{
string remoteBranchName = c.GetRemoteBranchName();
string commitMessage = c.GetCommitMessage();
NewPullRequest prInfo = new NewPullRequest(
commitMessage,
s_config.GitHubOriginOwner + ":" + remoteBranchName,
s_config.GitHubUpstreamBranch);
string[] prNotifications = s_config.GitHubPullRequestNotifications;
if (prNotifications.Length > 0)
{
prInfo.Body = $"/cc @{string.Join(" @", prNotifications)}";
}
GitHubClient gitHub = new GitHubClient(new ProductHeaderValue("dotnetDependencyUpdater"));
gitHub.Credentials = new Credentials(s_config.Password);
PullRequest createdPR = gitHub.PullRequest.Create(s_config.GitHubUpstreamOwner, s_config.GitHubProject, prInfo).Result;
c.Info($"Created Pull Request: {createdPR.HtmlUrl}");
return c.Success();
}
private static string GetRemoteBranchName(this BuildTargetContext c)
{
return (string)c.BuildContext["RemoteBranchName"];
}
private static void SetRemoteBranchName(this BuildTargetContext c, string value)
{
c.BuildContext["RemoteBranchName"] = value;
}
private static string GetCommitMessage(this BuildTargetContext c)
{
const string commitMessagePropertyName = "CommitMessage";
string message;
object messageObject;
if (c.BuildContext.Properties.TryGetValue(commitMessagePropertyName, out messageObject))
{
message = (string)messageObject;
}
else
{
DependencyInfo[] updatedDependencies = c.GetDependencyInfos()
.Where(d => d.IsUpdated)
.ToArray();
string updatedDependencyNames = string.Join(", ", updatedDependencies.Select(d => d.Name));
string updatedDependencyVersions = string.Join(", ", updatedDependencies.Select(d => d.NewReleaseVersion));
message = $"Updating {updatedDependencyNames} to {updatedDependencyVersions}";
if (updatedDependencies.Count() > 1)
{
message += " respectively";
}
c.BuildContext[commitMessagePropertyName] = message;
}
return message;
}
}
}

View file

@ -1,283 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.DotNet.Cli.Build.Framework;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NuGet.Versioning;
namespace Microsoft.DotNet.Scripts
{
public static class UpdateFilesTargets
{
private static HttpClient s_client = new HttpClient();
[Target(nameof(GetDependencies), nameof(ReplaceVersions))]
public static BuildTargetResult UpdateFiles(BuildTargetContext c) => c.Success();
/// <summary>
/// Gets all the dependency information and puts it in the build properties.
/// </summary>
[Target]
public static BuildTargetResult GetDependencies(BuildTargetContext c)
{
List<DependencyInfo> dependencyInfos = c.GetDependencyInfos();
dependencyInfos.Add(CreateDependencyInfo("CoreFx", Config.Instance.CoreFxVersionUrl).Result);
dependencyInfos.Add(CreateDependencyInfo("CoreClr", Config.Instance.CoreClrVersionUrl).Result);
dependencyInfos.Add(CreateDependencyInfo("Roslyn", Config.Instance.RoslynVersionUrl).Result);
dependencyInfos.Add(CreateDependencyInfo("CoreSetup", Config.Instance.CoreSetupVersionUrl).Result);
return c.Success();
}
private static async Task<DependencyInfo> CreateDependencyInfo(string name, string packageVersionsUrl)
{
List<PackageInfo> newPackageVersions = new List<PackageInfo>();
using (Stream versionsStream = await s_client.GetStreamAsync(packageVersionsUrl))
using (StreamReader reader = new StreamReader(versionsStream))
{
string currentLine;
while ((currentLine = await reader.ReadLineAsync()) != null)
{
int spaceIndex = currentLine.IndexOf(' ');
newPackageVersions.Add(new PackageInfo()
{
Id = currentLine.Substring(0, spaceIndex),
Version = new NuGetVersion(currentLine.Substring(spaceIndex + 1))
});
}
}
string newReleaseVersion = newPackageVersions
.Where(p => p.Version.IsPrerelease)
.Select(p => p.Version.Release)
.FirstOrDefault()
??
// if there are no prerelease versions, just grab the first version
newPackageVersions
.Select(p => p.Version.ToNormalizedString())
.FirstOrDefault();
return new DependencyInfo()
{
Name = name,
NewVersions = newPackageVersions,
NewReleaseVersion = newReleaseVersion
};
}
[Target(nameof(ReplaceProjectJson), nameof(ReplaceDependencyVersions))]
public static BuildTargetResult ReplaceVersions(BuildTargetContext c) => c.Success();
/// <summary>
/// Replaces all the dependency versions in the project.json files.
/// </summary>
[Target]
public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c)
{
List<DependencyInfo> dependencyInfos = c.GetDependencyInfos();
const string noUpdateFileName = ".noautoupdate";
IEnumerable<string> projectJsonFiles = Enumerable.Union(
Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories),
Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.template", SearchOption.AllDirectories))
.Where(p => !File.Exists(Path.Combine(Path.GetDirectoryName(p), noUpdateFileName)) &&
!Path.GetDirectoryName(p).EndsWith("CSharp_Web", StringComparison.Ordinal));
JObject projectRoot;
foreach (string projectJsonFile in projectJsonFiles)
{
try
{
projectRoot = ReadProject(projectJsonFile);
}
catch (Exception e)
{
c.Warn($"Non-fatal exception occurred reading '{projectJsonFile}'. Skipping file. Exception: {e}. ");
continue;
}
if (projectRoot == null)
{
c.Warn($"A non valid JSON file was encountered '{projectJsonFile}'. Skipping file.");
continue;
}
bool changedAnyPackage = FindAllDependencyProperties(projectRoot)
.Select(dependencyProperty => ReplaceDependencyVersion(dependencyProperty, dependencyInfos))
.ToArray()
.Any(shouldWrite => shouldWrite);
if (changedAnyPackage)
{
c.Info($"Writing changes to {projectJsonFile}");
WriteProject(projectRoot, projectJsonFile);
}
}
return c.Success();
}
/// <summary>
/// Replaces the single dependency with the updated version, if it matches any of the dependencies that need to be updated.
/// </summary>
private static bool ReplaceDependencyVersion(JProperty dependencyProperty, List<DependencyInfo> dependencyInfos)
{
string id = dependencyProperty.Name;
foreach (DependencyInfo dependencyInfo in dependencyInfos)
{
foreach (PackageInfo packageInfo in dependencyInfo.NewVersions)
{
if (id == packageInfo.Id)
{
string oldVersion;
if (dependencyProperty.Value is JObject)
{
oldVersion = (string)dependencyProperty.Value["version"];
}
else
{
oldVersion = (string)dependencyProperty.Value;
}
string newVersion = packageInfo.Version.ToNormalizedString();
if (oldVersion != newVersion)
{
if (dependencyProperty.Value is JObject)
{
dependencyProperty.Value["version"] = newVersion;
}
else
{
dependencyProperty.Value = newVersion;
}
// mark the DependencyInfo as updated so we can tell which dependencies were updated
dependencyInfo.IsUpdated = true;
return true;
}
}
}
}
return false;
}
private static JObject ReadProject(string projectJsonPath)
{
using (TextReader projectFileReader = File.OpenText(projectJsonPath))
{
var projectJsonReader = new JsonTextReader(projectFileReader);
var serializer = new JsonSerializer();
return serializer.Deserialize<JObject>(projectJsonReader);
}
}
private static void WriteProject(JObject projectRoot, string projectJsonPath)
{
string projectJson = JsonConvert.SerializeObject(projectRoot, Formatting.Indented);
File.WriteAllText(projectJsonPath, projectJson + Environment.NewLine);
}
private static IEnumerable<JProperty> FindAllDependencyProperties(JObject projectJsonRoot)
{
return projectJsonRoot
.Descendants()
.OfType<JProperty>()
.Where(property => property.Name == "dependencies")
.Select(property => property.Value)
.SelectMany(o => o.Children<JProperty>());
}
/// <summary>
/// Replaces version numbers that are hard-coded in DependencyVersions.cs and CliDependencyVersions.cs.
/// </summary>
[Target]
public static BuildTargetResult ReplaceDependencyVersions(BuildTargetContext c)
{
ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", fileContents =>
{
fileContents = ReplaceDependencyVersion(c, fileContents, "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR");
fileContents = ReplaceDependencyVersion(c, fileContents, "JitVersion", "Microsoft.NETCore.Jit");
return fileContents;
});
ReplaceFileContents(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", fileContents =>
{
fileContents = ReplaceDependencyVersion(c, fileContents, "SharedFrameworkVersion", "Microsoft.NETCore.App");
fileContents = ReplaceDependencyVersion(c, fileContents, "HostFxrVersion", "Microsoft.NETCore.DotNetHostResolver");
fileContents = ReplaceDependencyVersion(c, fileContents, "SharedHostVersion", "Microsoft.NETCore.DotNetHost");
return fileContents;
});
return c.Success();
}
private static string ReplaceDependencyVersion(BuildTargetContext c, string fileContents, string dependencyPropertyName, string packageId)
{
Regex regex = new Regex($@"{dependencyPropertyName} = ""(?<version>.*)"";");
string newVersion = c.GetNewVersion(packageId);
return regex.ReplaceGroupValue(fileContents, "version", newVersion);
}
private static string GetNewVersion(this BuildTargetContext c, string packageId)
{
string newVersion = c.GetDependencyInfos()
.SelectMany(d => d.NewVersions)
.FirstOrDefault(p => p.Id == packageId)
?.Version
.ToNormalizedString();
if (string.IsNullOrEmpty(newVersion))
{
c.Error($"Could not find package version information for '{packageId}'");
return $"DEPENDENCY '{packageId}' NOT FOUND";
}
return newVersion;
}
private static void ReplaceFileContents(string repoRelativePath, Func<string, string> replacement)
{
string fullPath = Path.Combine(Dirs.RepoRoot, repoRelativePath);
string contents = File.ReadAllText(fullPath);
contents = replacement(contents);
File.WriteAllText(fullPath, contents, Encoding.UTF8);
}
private static string ReplaceGroupValue(this Regex regex, string input, string groupName, string newValue)
{
return regex.Replace(input, m =>
{
string replacedValue = m.Value;
Group group = m.Groups[groupName];
int startIndex = group.Index - m.Index;
replacedValue = replacedValue.Remove(startIndex, group.Length);
replacedValue = replacedValue.Insert(startIndex, newValue);
return replacedValue;
});
}
}
}

View file

@ -2,28 +2,17 @@
"version": "1.0.0-*",
"description": "Updates the repos dependencies",
"buildOptions": {
"emitEntryPoint": true
"emitEntryPoint": true,
"compile": [
"../../src/Microsoft.DotNet.Cli.Utils/DebugHelper.cs"
]
},
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.CSharp": "4.0.1",
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.2",
"System.Runtime.Serialization.Primitives": "4.1.1",
"Microsoft.DotNet.Cli.Build.Framework": {
"target": "project"
},
"NuGet.Versioning": "3.5.0-beta2-1484",
"Newtonsoft.Json": "9.0.1",
"Octokit": "0.18.0",
"Microsoft.Net.Http": "2.2.29"
"Microsoft.NETCore.App": "1.0.0",
"Microsoft.DotNet.VersionTools": "1.0.26-prerelease-00615-07"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win"
]
}
"netcoreapp1.0": {}
},
"runtimes": {
"win7-x64": {},

View file

@ -4,15 +4,13 @@
#
param(
[string[]]$Targets=@("Default"),
[switch]$Help)
if($Help)
{
Write-Host "Usage: .\update-dependencies.ps1 [-Targets <TARGETS...>]"
Write-Host "Usage: .\update-dependencies.ps1"
Write-Host ""
Write-Host "Options:"
Write-Host " -Targets <TARGETS...> Comma separated build targets to run (UpdateFiles, PushPR; Default is everything)"
Write-Host " -Help Display this help message"
exit 0
}
@ -36,9 +34,9 @@ if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
# Restore the build_projects
Write-Host "Restoring Build projects..."
pushd "$RepoRoot\build_projects"
# Restore the app
Write-Host "Restoring update-dependencies..."
pushd "$AppPath"
dotnet restore
if($LASTEXITCODE -ne 0) { throw "Failed to restore" }
popd
@ -51,5 +49,5 @@ if($LASTEXITCODE -ne 0) { throw "Failed to compile build scripts" }
# Run the app
Write-Host "Invoking App $AppPath..."
Write-Host " Configuration: $env:CONFIGURATION"
& "$AppPath\bin\update-dependencies.exe" @Targets
& "$AppPath\bin\update-dependencies.exe"
if($LASTEXITCODE -ne 0) { throw "Build failed" }

View file

@ -1,16 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="180" height="20">
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20">
<mask id="a">
<rect width="180" height="20" rx="0" fill="#fff" />
<rect width="200" height="20" rx="0" fill="#fff" />
</mask>
<g mask="url(#a)">
<path fill="#555" d="M0 0h52v20H0z" />
<path fill="#007ec6" d="M52 0h115v20H52z" />
<path fill="#007ec6" d="M52 0h148v20H52z" />
<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="110" y="15" fill="#010101" fill-opacity=".3">ver_number</text>
<text x="110" y="14">ver_number</text>
<text x="125" y="15" fill="#010101" fill-opacity=".3">ver_number</text>
<text x="125" y="14">ver_number</text>
</g>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 708 B

After

Width:  |  Height:  |  Size: 707 B

View file

@ -27,16 +27,16 @@ if [ -t 1 ]; then
# see if it supports colors
ncolors=$(tput colors)
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
bold="$(tput bold)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
bold="$(tput bold || echo)"
normal="$(tput sgr0 || echo)"
black="$(tput setaf 0 || echo)"
red="$(tput setaf 1 || echo)"
green="$(tput setaf 2 || echo)"
yellow="$(tput setaf 3 || echo)"
blue="$(tput setaf 4 || echo)"
magenta="$(tput setaf 5 || echo)"
cyan="$(tput setaf 6 || echo)"
white="$(tput setaf 7 || echo)"
fi
fi

View file

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -27,7 +28,9 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
foreach (var asset in assets)
{
File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)), overwrite: true);
var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath));
File.Copy(asset.ResolvedPath, file, overwrite: true);
RemoveFileAttribute(file, FileAttributes.ReadOnly);
}
}
@ -44,6 +47,19 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
var transformedFile = asset.GetTransformedFile(tempLocation);
File.Copy(transformedFile, targetName, overwrite: true);
RemoveFileAttribute(targetName, FileAttributes.ReadOnly);
}
}
private static void RemoveFileAttribute(String file, FileAttributes attribute)
{
if (File.Exists(file))
{
var fileAttributes = File.GetAttributes(file);
if ((fileAttributes & attribute) == attribute)
{
File.SetAttributes(file, fileAttributes & ~attribute);
}
}
}

View file

@ -40,7 +40,8 @@ namespace Microsoft.DotNet.ProjectModel.Files
var token = rawObject.Value<JToken>(option);
if (token.Type != JTokenType.Object)
{
IncludePatterns = new List<string>(ExtractValues(token));
IncludePatterns = CreateCollection(
sourceBasePath, option, ExtractValues(token), literalPath: false);
}
else
{

View file

@ -150,7 +150,7 @@ namespace Microsoft.DotNet.ProjectModel.Files
file.IsCustomTarget = true;
// Prefer named targets over default ones
includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath));
includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath) && !f.IsCustomTarget);
includeEntries.Add(file);
}
}

View file

@ -156,13 +156,10 @@ namespace Microsoft.DotNet.Cli
else
{
CommandResult result = Command.Create("dotnet-" + command, appArgs, FrameworkConstants.CommonFrameworks.NetStandardApp15)
.ForwardStdErr()
.ForwardStdOut()
.Execute();
exitCode = result.ExitCode;
}
return exitCode;
}

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="fsharp-daily" value="https://www.myget.org/F/fsharp-daily/api/v3/index.json" />
<!-- Location of dotnet-compile-fsc tool -->
<add key="dotnet-cli" value="https://dotnet.myget.org/F/dotnet-cli/api/v3/index.json" />
</packageSources>
</configuration>

View file

@ -5,5 +5,4 @@ open System
[<EntryPoint>]
let main argv =
printfn "Hello World!"
printfn "%A" argv
0 // return an integer exit code

View file

@ -1,6 +1,7 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"compilerName": "fsc",
"compile": {
@ -9,18 +10,8 @@
]
}
},
"dependencies": {
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160509"
},
"tools": {
"dotnet-compile-fsc": {
"version": "1.0.0-preview2-*",
"imports": [
"dnxcore50",
"portable-net45+win81",
"netstandard1.3"
]
}
"dotnet-compile-fsc":"1.0.0-preview2-*"
},
"frameworks": {
"netcoreapp1.0": {
@ -28,12 +19,9 @@
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": [
"portable-net45+win8",
"dnxcore50"
]
},
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
}
}
}
}
}

View file

@ -0,0 +1,5 @@
namespace Library
module Say =
let hello name =
printfn "Hello %s" name

View file

@ -0,0 +1,23 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
"compile": {
"includeFiles": [
"Library.fs"
]
}
},
"tools": {
"dotnet-compile-fsc":"1.0.0-preview2-*"
},
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library":"1.6.0",
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
}
}
}
}

View file

@ -100,7 +100,7 @@ namespace Microsoft.DotNet.Tools.New
app.HelpOption("-h|--help");
var csharp = new { Name = "C#", Alias = new[] { "c#", "cs", "csharp" }, TemplatePrefix = "CSharp", Templates = new[] { "Console", "Web", "Lib", "xunittest" } };
var fsharp = new { Name = "F#", Alias = new[] { "f#", "fs", "fsharp" }, TemplatePrefix = "FSharp", Templates = new[] { "Console" } };
var fsharp = new { Name = "F#", Alias = new[] { "f#", "fs", "fsharp" }, TemplatePrefix = "FSharp", Templates = new[] { "Console", "Lib" } };
var languages = new[] { csharp, fsharp };
@ -134,7 +134,7 @@ namespace Microsoft.DotNet.Tools.New
if (templateName == null)
{
Reporter.Error.WriteLine($"Unrecognized type: {typeValue}".Red());
Reporter.Error.WriteLine($"Avaiable types for {language.Name} :".Red());
Reporter.Error.WriteLine($"Available types for {language.Name} :".Red());
foreach (var t in language.Templates)
{
Reporter.Error.WriteLine($"- {t}".Red());

View file

@ -22,7 +22,7 @@ After this, the project is ready to be compiled and/or edited further.
`-l`, `--lang [C#|F#]`
Language of the project. Defaults to `C#`. `csharp` (`fsharp`) or `cs` (`fs`) are also valid options.
Language of the project. Defaults to `C#`. `csharp` ( or `cs` ) and `fsharp` ( or `fs` ) are also valid options.
`-t`, `--type`
@ -36,20 +36,21 @@ Type of the project. Valid values for C# are:
Valid values for F# are:
* `console`
* `lib`
## EXAMPLES
`dotnet new`
Drops a sample C## project in the current directory.
Drops a sample C# project in the current directory.
`dotnet new --lang f##`
`dotnet new --lang f#`
Drops a sample F## project in the current directory.
Drops a sample F# project in the current directory.
`dotnet new --lang c##`
`dotnet new --lang c#`
Drops a sample C## project in the current directory.
Drops a sample C# project in the current directory.
# SEE ALSO
dotnet-run(1)

View file

@ -24,7 +24,7 @@ Depending on the type of portable app, the resulting directory will contain the
dependency.
2. **Self-contained application** - same as above plus the entire runtime for the targeted platform.
The above types are covered in more details in the [types of portable applications](https://dotnet.github.io/docs/core-concepts/app-types.html) topic.
The above types are covered in more details in the [types of portable applications](https://docs.microsoft.com/en-us/dotnet/articles/core/app-types) topic.
## OPTIONS

View file

@ -30,7 +30,7 @@ The `dotnet run` command must be used in the context of projects, not built asse
`dotnet myapp.dll`
For more information about the `dotnet` driver, see the [.NET Core Command Line Tools (CLI)](https://dotnet.github.io/docs/core-concepts/core-sdk/cli/overview.html) topic.
For more information about the `dotnet` driver, see the [.NET Core Command Line Tools (CLI)](https://docs.microsoft.com/en-us/dotnet/articles/core/tools/index) topic.
## OPTIONS

View file

@ -24,8 +24,6 @@ namespace Microsoft.DotNet.Tools.Test
GetCommandArgs(projectContext, dotnetTestParams),
projectContext.TargetFramework,
dotnetTestParams.Config)
.ForwardStdErr()
.ForwardStdOut()
.Execute()
.ExitCode;
}

View file

@ -7,8 +7,9 @@
"commands/dotnet-new/CSharp_Console.zip",
"commands/dotnet-new/CSharp_Lib.zip",
"commands/dotnet-new/CSharp_xunittest.zip",
"commands/dotnet-new/CSharp_Web.zip",
"commands/dotnet-new/FSharp_Console.zip",
"commands/dotnet-new/CSharp_Web.zip"
"commands/dotnet-new/FSharp_Lib.zip"
]
},
"compile": {
@ -17,6 +18,7 @@
"commands/dotnet-new/FSharp_Console/**",
"commands/dotnet-new/CSharp_Web/**",
"commands/dotnet-new/CSharp_Lib/**",
"commands/dotnet-new/FSharp_Lib/**",
"commands/dotnet-new/CSharp_xunittest/**"
]
}

View file

@ -113,6 +113,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
zip.Entries.Should().Contain(e => e.FullName == "packfiles/pack1.txt");
zip.Entries.Should().Contain(e => e.FullName == "newpath/pack2.txt");
zip.Entries.Should().Contain(e => e.FullName == "anotherpath/pack2.txt");
}
[Fact]

View file

@ -128,6 +128,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
publishCommand.Execute().Should().Pass();
publishCommand.GetOutputDirectory().Should().HaveFile("testpublishfile.txt");
publishCommand.GetOutputDirectory().Should().HaveFile("publishfiles/anotherpublishfile.txt");
}
[Fact]