From c5d68ac0b01262d229d278905c260820fb208269 Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Fri, 24 Jun 2016 20:08:28 +0200 Subject: [PATCH 01/25] Don't use black color in the console (#3687) In the standard white text on black background console, text printed like this is invisible. --- .../Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs index 17847ccaa..20fa975f6 100644 --- a/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs +++ b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs @@ -64,7 +64,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}"); } } From f8110698980eec001a9aa1ac05aa8ae7ff69e19d Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Fri, 24 Jun 2016 20:10:58 +0200 Subject: [PATCH 02/25] Fixed OutputPath in Configurer xproj (#3685) This is required for building in VS. --- .../Microsoft.DotNet.Configurer.xproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Configurer/Microsoft.DotNet.Configurer.xproj b/src/Microsoft.DotNet.Configurer/Microsoft.DotNet.Configurer.xproj index f533d0dad..733d0d508 100644 --- a/src/Microsoft.DotNet.Configurer/Microsoft.DotNet.Configurer.xproj +++ b/src/Microsoft.DotNet.Configurer/Microsoft.DotNet.Configurer.xproj @@ -9,7 +9,7 @@ e5ed47ef-bf25-4da9-a7fe-290c642cbf0f Microsoft.DotNet.Configurer .\obj - .\bin\ + ..\..\artifacts\bin From f3a573beef1660eb71066b673017458ec530dfd4 Mon Sep 17 00:00:00 2001 From: Rich Lander Date: Mon, 27 Jun 2016 11:55:38 -0700 Subject: [PATCH 03/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77487238a..9a3798ec3 100644 --- a/README.md +++ b/README.md @@ -115,5 +115,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). From da57475105e776d2db26a528a2296c98998eeab5 Mon Sep 17 00:00:00 2001 From: Zlatko Knezevic Date: Mon, 27 Jun 2016 15:48:49 -0700 Subject: [PATCH 04/25] Update README.md (#3709) * Update README.md Fixing documentation links to point to actual (new) docs. --- README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9a3798ec3..6cf4f8630 100644 --- a/README.md +++ b/README.md @@ -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 -------------------- From d6849c2fa1c16e83cbbaa258cdacb80598f1ed58 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Tue, 28 Jun 2016 16:29:36 -0700 Subject: [PATCH 05/25] Piotrp msft/3628 rebase (#3694) * fix typo * doc --- src/dotnet/commands/dotnet-new/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dotnet/commands/dotnet-new/README.md b/src/dotnet/commands/dotnet-new/README.md index fa1f474b0..bdd871695 100644 --- a/src/dotnet/commands/dotnet-new/README.md +++ b/src/dotnet/commands/dotnet-new/README.md @@ -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` @@ -41,15 +41,15 @@ Valid values for F# are: `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) From 1706eb19f95b45b15c9d504508e5a2cc03e5c7dc Mon Sep 17 00:00:00 2001 From: kloun Date: Wed, 29 Jun 2016 23:54:31 +0300 Subject: [PATCH 06/25] del duplicate newline --- src/dotnet/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index 7164727c8..f1461d669 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -163,7 +163,6 @@ namespace Microsoft.DotNet.Cli exitCode = result.ExitCode; } - return exitCode; } From bfcf73cfcdf4c8ae65ed1079db79bdc06a3793dc Mon Sep 17 00:00:00 2001 From: "Michael Simons (VISUAL STUDIO)" Date: Thu, 30 Jun 2016 13:42:35 -0500 Subject: [PATCH 07/25] Updated the version badge so that it is readable with the current version numbers --- resources/images/version_badge.svg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/images/version_badge.svg b/resources/images/version_badge.svg index 22c125cbd..4e4577974 100644 --- a/resources/images/version_badge.svg +++ b/resources/images/version_badge.svg @@ -1,16 +1,16 @@ - + - + - + version version - ver_number - ver_number + ver_number + ver_number - + \ No newline at end of file From c6e42cfe7e7809ec15b0e65b65db3fd899b0b8ec Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Fri, 1 Jul 2016 19:33:36 +0200 Subject: [PATCH 08/25] fixed docs links in READMEs --- src/dotnet/commands/dotnet-publish/README.md | 2 +- src/dotnet/commands/dotnet-run/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dotnet/commands/dotnet-publish/README.md b/src/dotnet/commands/dotnet-publish/README.md index 8876f2adf..c61a8cb4b 100644 --- a/src/dotnet/commands/dotnet-publish/README.md +++ b/src/dotnet/commands/dotnet-publish/README.md @@ -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 diff --git a/src/dotnet/commands/dotnet-run/README.md b/src/dotnet/commands/dotnet-run/README.md index 39ccd744b..7e6583597 100644 --- a/src/dotnet/commands/dotnet-run/README.md +++ b/src/dotnet/commands/dotnet-run/README.md @@ -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 From 51e7ab465b30553487a9b0a238c93723d9939897 Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 5 Jul 2016 21:38:12 -0700 Subject: [PATCH 09/25] Update F# dotnet-new templates for Preview 2 (Enrico Sada rebase) This updates the F# templates for dotnet-new to be compatible with Preview 2. --- .../dotnet-new/FSharp_Console/NuGet.Config | 12 ---------- .../FSharp_Console/project.json.template | 24 +++++-------------- .../commands/dotnet-new/FSharp_Lib/Library.fs | 5 ++++ .../FSharp_Lib/project.json.template | 23 ++++++++++++++++++ src/dotnet/commands/dotnet-new/Program.cs | 2 +- src/dotnet/commands/dotnet-new/README.md | 1 + src/dotnet/project.json | 4 +++- 7 files changed, 39 insertions(+), 32 deletions(-) delete mode 100644 src/dotnet/commands/dotnet-new/FSharp_Console/NuGet.Config create mode 100644 src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs create mode 100644 src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/NuGet.Config b/src/dotnet/commands/dotnet-new/FSharp_Console/NuGet.Config deleted file mode 100644 index c9fe7428b..000000000 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/NuGet.Config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template b/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template index f2c366a2a..dcbeed714 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template +++ b/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template @@ -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" + } } } -} +} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs b/src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs new file mode 100644 index 000000000..ae53d091e --- /dev/null +++ b/src/dotnet/commands/dotnet-new/FSharp_Lib/Library.fs @@ -0,0 +1,5 @@ +namespace Library + +module Say = + let hello name = + printfn "Hello %s" name \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template b/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template new file mode 100644 index 000000000..52746e87e --- /dev/null +++ b/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template @@ -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" + } + } + } +} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-new/Program.cs b/src/dotnet/commands/dotnet-new/Program.cs index 627896f4f..1c9e75f8b 100644 --- a/src/dotnet/commands/dotnet-new/Program.cs +++ b/src/dotnet/commands/dotnet-new/Program.cs @@ -97,7 +97,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 }; diff --git a/src/dotnet/commands/dotnet-new/README.md b/src/dotnet/commands/dotnet-new/README.md index bdd871695..117edacb7 100644 --- a/src/dotnet/commands/dotnet-new/README.md +++ b/src/dotnet/commands/dotnet-new/README.md @@ -36,6 +36,7 @@ Type of the project. Valid values for C# are: Valid values for F# are: * `console` +* `lib` ## EXAMPLES diff --git a/src/dotnet/project.json b/src/dotnet/project.json index c029b55fb..b75006cb2 100644 --- a/src/dotnet/project.json +++ b/src/dotnet/project.json @@ -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/**" ] } From f769f9ea1c43cd4545b81e9d1079b359de289f4b Mon Sep 17 00:00:00 2001 From: Dennis Fricke Date: Wed, 6 Jul 2016 16:12:13 +0200 Subject: [PATCH 10/25] Update LibraryExporterExtensions.cs --- .../LibraryExporterExtensions.cs | 120 ++++++++++-------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index 7e3440c02..fb863bd49 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -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; @@ -9,62 +10,77 @@ using Microsoft.DotNet.ProjectModel.Graph; namespace Microsoft.DotNet.Cli.Compiler.Common { - public static class LibraryExporterExtensions - { - public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) - { - return - exporter.GetDependencies(LibraryType.Project) - .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); - } + public static class LibraryExporterExtensions + { + public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) + { + return + exporter.GetDependencies(LibraryType.Project) + .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); + } - public static void CopyTo(this IEnumerable assets, string destinationPath) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + public static void CopyTo(this IEnumerable assets, string destinationPath) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - foreach (var asset in assets) - { - File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)), overwrite: true); - } - } + foreach (var asset in assets) + { + var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + File.Copy(asset.ResolvedPath, file, overwrite: true); + RemoveFileAttribute(file, FileAttributes.ReadOnly); + } + } - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + 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); + } + } + } - foreach (var asset in assets) - { - var targetName = ResolveTargetName(destinationPath, asset); - var transformedFile = asset.GetTransformedFile(tempLocation); + public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - File.Copy(transformedFile, targetName, overwrite: true); - } - } + foreach (var asset in assets) + { + var targetName = ResolveTargetName(destinationPath, asset); + var transformedFile = asset.GetTransformedFile(tempLocation); - private static string ResolveTargetName(string destinationPath, LibraryAsset asset) - { - string targetName; - if (!string.IsNullOrEmpty(asset.RelativePath)) - { - targetName = Path.Combine(destinationPath, asset.RelativePath); - var destinationAssetPath = Path.GetDirectoryName(targetName); + File.Copy(transformedFile, targetName, overwrite: true); + RemoveFileAttribute(targetName, FileAttributes.ReadOnly); + } + } - if (!Directory.Exists(destinationAssetPath)) - { - Directory.CreateDirectory(destinationAssetPath); - } - } - else - { - targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - } - return targetName; - } - } + private static string ResolveTargetName(string destinationPath, LibraryAsset asset) + { + string targetName; + if (!string.IsNullOrEmpty(asset.RelativePath)) + { + targetName = Path.Combine(destinationPath, asset.RelativePath); + var destinationAssetPath = Path.GetDirectoryName(targetName); + + if (!Directory.Exists(destinationAssetPath)) + { + Directory.CreateDirectory(destinationAssetPath); + } + } + else + { + targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + } + return targetName; + } + } } From 2084a099b8323efdceaa3bd81fb9fb307b57eded Mon Sep 17 00:00:00 2001 From: Dennis Fricke Date: Wed, 6 Jul 2016 16:55:35 +0200 Subject: [PATCH 11/25] Update LibraryExporterExtensions.cs tabs -> spaces --- .../LibraryExporterExtensions.cs | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index fb863bd49..bde36f966 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -10,77 +10,77 @@ using Microsoft.DotNet.ProjectModel.Graph; namespace Microsoft.DotNet.Cli.Compiler.Common { - public static class LibraryExporterExtensions - { - public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) - { - return - exporter.GetDependencies(LibraryType.Project) - .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); - } + public static class LibraryExporterExtensions + { + public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) + { + return + exporter.GetDependencies(LibraryType.Project) + .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); + } + + public static void CopyTo(this IEnumerable assets, string destinationPath) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - public static void CopyTo(this IEnumerable assets, string destinationPath) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + foreach (var asset in assets) + { + var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + File.Copy(asset.ResolvedPath, file, overwrite: true); + RemoveFileAttribute(file, FileAttributes.ReadOnly); + } + } - foreach (var asset in assets) - { - var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - File.Copy(asset.ResolvedPath, file, overwrite: true); - RemoveFileAttribute(file, 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); + } + } + } - 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); - } - } - } + public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + foreach (var asset in assets) + { + var targetName = ResolveTargetName(destinationPath, asset); + var transformedFile = asset.GetTransformedFile(tempLocation); - foreach (var asset in assets) - { - var targetName = ResolveTargetName(destinationPath, asset); - var transformedFile = asset.GetTransformedFile(tempLocation); + File.Copy(transformedFile, targetName, overwrite: true); + RemoveFileAttribute(targetName, FileAttributes.ReadOnly); + } + } - File.Copy(transformedFile, targetName, overwrite: true); - RemoveFileAttribute(targetName, FileAttributes.ReadOnly); - } - } + private static string ResolveTargetName(string destinationPath, LibraryAsset asset) + { + string targetName; + if (!string.IsNullOrEmpty(asset.RelativePath)) + { + targetName = Path.Combine(destinationPath, asset.RelativePath); + var destinationAssetPath = Path.GetDirectoryName(targetName); - private static string ResolveTargetName(string destinationPath, LibraryAsset asset) - { - string targetName; - if (!string.IsNullOrEmpty(asset.RelativePath)) - { - targetName = Path.Combine(destinationPath, asset.RelativePath); - var destinationAssetPath = Path.GetDirectoryName(targetName); - - if (!Directory.Exists(destinationAssetPath)) - { - Directory.CreateDirectory(destinationAssetPath); - } - } - else - { - targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - } - return targetName; - } - } + if (!Directory.Exists(destinationAssetPath)) + { + Directory.CreateDirectory(destinationAssetPath); + } + } + else + { + targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + } + return targetName; + } + } } From 38f75fd5c50de784017df8a97068972b52fc12a5 Mon Sep 17 00:00:00 2001 From: Dennis Fricke Date: Thu, 7 Jul 2016 15:16:10 +0200 Subject: [PATCH 12/25] Update LibraryExporterExtensions.cs - removed space | moved method below StructuredCopyTo --- .../LibraryExporterExtensions.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index bde36f966..8c5cfc355 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -18,7 +18,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common exporter.GetDependencies(LibraryType.Project) .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); } - + public static void CopyTo(this IEnumerable assets, string destinationPath) { if (!Directory.Exists(destinationPath)) @@ -34,18 +34,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common } } - 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); - } - } - } - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) { if (!Directory.Exists(destinationPath)) @@ -62,6 +50,18 @@ namespace Microsoft.DotNet.Cli.Compiler.Common 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); + } + } + } private static string ResolveTargetName(string destinationPath, LibraryAsset asset) { From 6830c15b768207c8a863e68fa83cee0a233cc66e Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Thu, 7 Jul 2016 19:16:53 +0200 Subject: [PATCH 13/25] Fixed instructions to compile without tests --- Documentation/developer-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/developer-guide.md b/Documentation/developer-guide.md index 27075ccd8..18cb44890 100644 --- a/Documentation/developer-guide.md +++ b/Documentation/developer-guide.md @@ -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 From fd1da955226e832140922f2d2bf464e486d97cc3 Mon Sep 17 00:00:00 2001 From: cartermp Date: Thu, 7 Jul 2016 14:00:42 -0700 Subject: [PATCH 14/25] Don't print arguments in F# console app --- src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs b/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs index 7687e612f..d5fd26e80 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs +++ b/src/dotnet/commands/dotnet-new/FSharp_Console/Program.fs @@ -5,5 +5,4 @@ open System [] let main argv = printfn "Hello World!" - printfn "%A" argv 0 // return an integer exit code From 17ef19e78827d982335b129a83d746795ed9da78 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 7 Jul 2016 14:50:41 -0700 Subject: [PATCH 15/25] Removing ForwardStdOut and ForwardStdErr from the ConsoleTestRunner and from dotnet verbs that are not built-in. BuiltIn verbs were already not using it. --- src/dotnet/Program.cs | 2 -- src/dotnet/commands/dotnet-test/ConsoleTestRunner.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index f1461d669..89260a798 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -157,8 +157,6 @@ namespace Microsoft.DotNet.Cli else { CommandResult result = Command.Create("dotnet-" + command, appArgs, FrameworkConstants.CommonFrameworks.NetStandardApp15) - .ForwardStdErr() - .ForwardStdOut() .Execute(); exitCode = result.ExitCode; } diff --git a/src/dotnet/commands/dotnet-test/ConsoleTestRunner.cs b/src/dotnet/commands/dotnet-test/ConsoleTestRunner.cs index 55de7ff1b..9277afe18 100644 --- a/src/dotnet/commands/dotnet-test/ConsoleTestRunner.cs +++ b/src/dotnet/commands/dotnet-test/ConsoleTestRunner.cs @@ -24,8 +24,6 @@ namespace Microsoft.DotNet.Tools.Test GetCommandArgs(projectContext, dotnetTestParams), projectContext.TargetFramework, dotnetTestParams.Config) - .ForwardStdErr() - .ForwardStdOut() .Execute() .ExitCode; } From 2cba2c7688d0878be80801e73d02163d4c327ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=83=C2=B8nigsen?= Date: Fri, 8 Jul 2016 10:01:42 +0200 Subject: [PATCH 16/25] Handle missing terminal capabilities. When probing for terminal capabilities, tput will return exit-code 1 when the attribute is not valid for the current terminal. If we don't handle that exit-code, the shell-script too will exit with failure. This patch simply ignores errors for attributes we cannot use, resulting in the same result as if we never probed for it in the first place. --- scripts/obtain/dotnet-install.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/obtain/dotnet-install.sh b/scripts/obtain/dotnet-install.sh index 2ac19e6ee..f639c1d2b 100755 --- a/scripts/obtain/dotnet-install.sh +++ b/scripts/obtain/dotnet-install.sh @@ -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 From 6df15c341a08c27c8b7c8a12a94cbfecf29e1c67 Mon Sep 17 00:00:00 2001 From: Mark Clearwater Date: Sat, 9 Jul 2016 19:10:54 +0100 Subject: [PATCH 17/25] Fix typo in `Avaiable` * Should be Available --- src/dotnet/commands/dotnet-new/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-new/Program.cs b/src/dotnet/commands/dotnet-new/Program.cs index 627896f4f..4b970fe6e 100644 --- a/src/dotnet/commands/dotnet-new/Program.cs +++ b/src/dotnet/commands/dotnet-new/Program.cs @@ -131,7 +131,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()); From 600da0a8acbbbd62ed68fa693baa2eb55b14a478 Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Mon, 11 Jul 2016 23:36:54 +0100 Subject: [PATCH 18/25] Fix building from build.cmd on a path containing spaces Add additional quoting when passing the initial command to powershell. --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index bd617d268..ffc201f93 100644 --- a/build.cmd +++ b/build.cmd @@ -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 "%~dp0build_projects\dotnet-cli-build\build.ps1 %*; exit $LastExitCode;" +powershell -NoProfile -NoLogo -Command "& \"%~dp0build_projects\dotnet-cli-build\build.ps1\" %*; exit $LastExitCode;" if %errorlevel% neq 0 exit /b %errorlevel% From e1be430f597fbc4455732f70f7b9589401b67061 Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 12 Jul 2016 15:33:18 -0700 Subject: [PATCH 19/25] Add missing comma to F# lib project.json --- src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template b/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template index 52746e87e..7e88b72f9 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template +++ b/src/dotnet/commands/dotnet-new/FSharp_Lib/project.json.template @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "buildOptions": { - "debugType": "portable" + "debugType": "portable", "compilerName": "fsc", "compile": { "includeFiles": [ From c748c81a4a312751e363ecc58de77acbbdfa63b3 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 13 Jul 2016 14:56:22 -0700 Subject: [PATCH 20/25] [Fixes #3856] Allow mapping of the same file to multiple target paths --- TestAssets/TestProjects/EndToEndTestApp/project.json | 3 ++- .../Files/IncludeFilesResolver.cs | 2 +- test/dotnet-pack.Tests/PackTests.cs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TestAssets/TestProjects/EndToEndTestApp/project.json b/TestAssets/TestProjects/EndToEndTestApp/project.json index a83d47689..dc84f6625 100644 --- a/TestAssets/TestProjects/EndToEndTestApp/project.json +++ b/TestAssets/TestProjects/EndToEndTestApp/project.json @@ -20,7 +20,8 @@ "files": { "includeFiles": "packfiles/pack1.txt", "mappings": { - "newpath/": "packfiles/pack2.txt" + "newpath/": "packfiles/pack2.txt", + "anotherpath/": "packfiles/pack2.txt" } } }, diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs index 15ff88670..a52ffb620 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs +++ b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs @@ -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 == false); includeEntries.Add(file); } } diff --git a/test/dotnet-pack.Tests/PackTests.cs b/test/dotnet-pack.Tests/PackTests.cs index 5091e7fd7..1d9f7500a 100644 --- a/test/dotnet-pack.Tests/PackTests.cs +++ b/test/dotnet-pack.Tests/PackTests.cs @@ -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] From dbf7435c3ca7f1e97652c6291ac0cc5770a3b307 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 13 Jul 2016 15:09:22 -0700 Subject: [PATCH 21/25] [Fixes #3502] Fix: publishOptions: [...] not respected --- TestAssets/TestProjects/EndToEndTestApp/project.json | 2 +- .../EndToEndTestApp/publishfiles/anotherpublishfile.txt | 0 src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs | 3 ++- test/dotnet-publish.Tests/PublishTests.cs | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 TestAssets/TestProjects/EndToEndTestApp/publishfiles/anotherpublishfile.txt diff --git a/TestAssets/TestProjects/EndToEndTestApp/project.json b/TestAssets/TestProjects/EndToEndTestApp/project.json index dc84f6625..10ae17942 100644 --- a/TestAssets/TestProjects/EndToEndTestApp/project.json +++ b/TestAssets/TestProjects/EndToEndTestApp/project.json @@ -25,7 +25,7 @@ } } }, - "publishOptions": "testpublishfile.txt", + "publishOptions": [ "testpublishfile.txt", "publishfiles" ], "frameworks": { "netcoreapp1.0": {} }, diff --git a/TestAssets/TestProjects/EndToEndTestApp/publishfiles/anotherpublishfile.txt b/TestAssets/TestProjects/EndToEndTestApp/publishfiles/anotherpublishfile.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs b/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs index 39661bf1d..ebedcdad3 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs +++ b/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs @@ -40,7 +40,8 @@ namespace Microsoft.DotNet.ProjectModel.Files var token = rawObject.Value(option); if (token.Type != JTokenType.Object) { - IncludePatterns = new List(ExtractValues(token)); + IncludePatterns = CreateCollection( + sourceBasePath, option, ExtractValues(token), literalPath: false); } else { diff --git a/test/dotnet-publish.Tests/PublishTests.cs b/test/dotnet-publish.Tests/PublishTests.cs index 924bad75b..19084e855 100644 --- a/test/dotnet-publish.Tests/PublishTests.cs +++ b/test/dotnet-publish.Tests/PublishTests.cs @@ -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] From 01021a0a6d4701ca12e831fda823fda8cacc9bf3 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 13 Jul 2016 15:52:23 -0700 Subject: [PATCH 22/25] Addressed feedback --- src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs index a52ffb620..f1baeb70f 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs +++ b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs @@ -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) && f.IsCustomTarget == false); + includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath) && !f.IsCustomTarget); includeEntries.Add(file); } } From 1f52591d9e95ef8a5bf78e4fb099d6388cd97ef8 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Fri, 15 Jul 2016 17:52:09 +0200 Subject: [PATCH 23/25] Fix invalid json in runtimeconfig (#3871) The json in [appname].runtimeconfig.json example is invalid, this adds the missing `,` --- Documentation/specs/runtime-configuration-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/specs/runtime-configuration-file.md b/Documentation/specs/runtime-configuration-file.md index 0acb469d3..fbf6e2c4c 100644 --- a/Documentation/specs/runtime-configuration-file.md +++ b/Documentation/specs/runtime-configuration-file.md @@ -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 } From a27d02eb66d17975519a8627226d1a65aeda26f7 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Fri, 15 Jul 2016 19:09:38 -0500 Subject: [PATCH 24/25] Move to buildtools' VersionTools for update-dependencies. --- .../BuildContextProperties.cs | 30 -- build_projects/update-dependencies/Config.cs | 22 +- .../update-dependencies/DependencyInfo.cs | 23 -- build_projects/update-dependencies/Program.cs | 89 +++++- .../update-dependencies/PushPRTargets.cs | 162 ---------- .../update-dependencies/UpdateFilesTargets.cs | 283 ------------------ .../update-dependencies/project.json | 25 +- .../update-dependencies.ps1 | 6 +- 8 files changed, 96 insertions(+), 544 deletions(-) delete mode 100644 build_projects/update-dependencies/BuildContextProperties.cs delete mode 100644 build_projects/update-dependencies/DependencyInfo.cs delete mode 100644 build_projects/update-dependencies/PushPRTargets.cs delete mode 100644 build_projects/update-dependencies/UpdateFilesTargets.cs diff --git a/build_projects/update-dependencies/BuildContextProperties.cs b/build_projects/update-dependencies/BuildContextProperties.cs deleted file mode 100644 index 6cd488398..000000000 --- a/build_projects/update-dependencies/BuildContextProperties.cs +++ /dev/null @@ -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 GetDependencyInfos(this BuildTargetContext c) - { - const string propertyName = "DependencyInfos"; - - List dependencyInfos; - object dependencyInfosObj; - if (c.BuildContext.Properties.TryGetValue(propertyName, out dependencyInfosObj)) - { - dependencyInfos = (List)dependencyInfosObj; - } - else - { - dependencyInfos = new List(); - c.BuildContext[propertyName] = dependencyInfos; - } - - return dependencyInfos; - } - } -} diff --git a/build_projects/update-dependencies/Config.cs b/build_projects/update-dependencies/Config.cs index 1221d2d00..c88680802 100644 --- a/build_projects/update-dependencies/Config.cs +++ b/build_projects/update-dependencies/Config.cs @@ -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 _email = new Lazy(() => GetEnvironmentVariable("GITHUB_EMAIL")); private Lazy _password = new Lazy(() => GetEnvironmentVariable("GITHUB_PASSWORD")); - private Lazy _coreFxVersionUrl = new Lazy(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt")); - private Lazy _coreClrVersionUrl = new Lazy(() => GetEnvironmentVariable("CORECLR_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0/Latest_Packages.txt")); - private Lazy _roslynVersionUrl = new Lazy(() => GetEnvironmentVariable("ROSLYN_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0/Latest_Packages.txt")); - private Lazy _coreSetupVersionUrl = new Lazy(() => 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 _gitHubOriginOwner; + private Lazy _coreFxVersionUrl = new Lazy(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0")); + private Lazy _coreClrVersionUrl = new Lazy(() => GetEnvironmentVariable("CORECLR_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0")); + private Lazy _roslynVersionUrl = new Lazy(() => GetEnvironmentVariable("ROSLYN_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0")); + private Lazy _coreSetupVersionUrl = new Lazy(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0")); private Lazy _gitHubUpstreamOwner = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet")); private Lazy _gitHubProject = new Lazy(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli")); private Lazy _gitHubUpstreamBranch = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", "rel/1.0.0")); @@ -50,7 +48,6 @@ namespace Microsoft.DotNet.Scripts private Config() { - _gitHubOriginOwner = new Lazy(() => 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; diff --git a/build_projects/update-dependencies/DependencyInfo.cs b/build_projects/update-dependencies/DependencyInfo.cs deleted file mode 100644 index 48b4d8f8e..000000000 --- a/build_projects/update-dependencies/DependencyInfo.cs +++ /dev/null @@ -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 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; } - } -} diff --git a/build_projects/update-dependencies/Program.cs b/build_projects/update-dependencies/Program.cs index f0fc8f8d1..6374b610f 100644 --- a/build_projects/update-dependencies/Program.cs +++ b/build_projects/update-dependencies/Program.cs @@ -1,25 +1,92 @@ // 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() - .Run(args); + List buildInfos = new List(); + + 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 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 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() + { + const string noUpdateFileName = ".noautoupdate"; + + IEnumerable 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)); + + return new ProjectJsonUpdater(projectJsonFiles) + { + SkipStableVersions = false + }; + } + + 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} = ""(?.*)"";"), + VersionGroupName = "version" + }; } } } diff --git a/build_projects/update-dependencies/PushPRTargets.cs b/build_projects/update-dependencies/PushPRTargets.cs deleted file mode 100644 index 2d989a79e..000000000 --- a/build_projects/update-dependencies/PushPRTargets.cs +++ /dev/null @@ -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 -{ - /// - /// Creates a GitHub Pull Request for the current changes in the repo. - /// - 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(); - - /// - /// Commits all the current changes in the repo and pushes the commit to a remote - /// so a PR can be created for it. - /// - [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(); - } - - /// - /// Creates a GitHub PR for the remote branch created above. - /// - [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; - } - } -} diff --git a/build_projects/update-dependencies/UpdateFilesTargets.cs b/build_projects/update-dependencies/UpdateFilesTargets.cs deleted file mode 100644 index 9a0c3053c..000000000 --- a/build_projects/update-dependencies/UpdateFilesTargets.cs +++ /dev/null @@ -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(); - - /// - /// Gets all the dependency information and puts it in the build properties. - /// - [Target] - public static BuildTargetResult GetDependencies(BuildTargetContext c) - { - List 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 CreateDependencyInfo(string name, string packageVersionsUrl) - { - List newPackageVersions = new List(); - - 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(); - - /// - /// Replaces all the dependency versions in the project.json files. - /// - [Target] - public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c) - { - List dependencyInfos = c.GetDependencyInfos(); - - const string noUpdateFileName = ".noautoupdate"; - - IEnumerable 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(); - } - - /// - /// Replaces the single dependency with the updated version, if it matches any of the dependencies that need to be updated. - /// - private static bool ReplaceDependencyVersion(JProperty dependencyProperty, List 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(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 FindAllDependencyProperties(JObject projectJsonRoot) - { - return projectJsonRoot - .Descendants() - .OfType() - .Where(property => property.Name == "dependencies") - .Select(property => property.Value) - .SelectMany(o => o.Children()); - } - - /// - /// Replaces version numbers that are hard-coded in DependencyVersions.cs and CliDependencyVersions.cs. - /// - [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} = ""(?.*)"";"); - 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 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; - }); - } - } -} diff --git a/build_projects/update-dependencies/project.json b/build_projects/update-dependencies/project.json index 9c9d79edf..9ca036302 100644 --- a/build_projects/update-dependencies/project.json +++ b/build_projects/update-dependencies/project.json @@ -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": {}, diff --git a/build_projects/update-dependencies/update-dependencies.ps1 b/build_projects/update-dependencies/update-dependencies.ps1 index 4ecef6840..4ce5ea223 100644 --- a/build_projects/update-dependencies/update-dependencies.ps1 +++ b/build_projects/update-dependencies/update-dependencies.ps1 @@ -4,15 +4,13 @@ # param( - [string[]]$Targets=@("Default"), [switch]$Help) if($Help) { - Write-Host "Usage: .\update-dependencies.ps1 [-Targets ]" + Write-Host "Usage: .\update-dependencies.ps1" Write-Host "" Write-Host "Options:" - Write-Host " -Targets Comma separated build targets to run (UpdateFiles, PushPR; Default is everything)" Write-Host " -Help Display this help message" exit 0 } @@ -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" } From eada6913c4f8896ff9dfaf52f4797c936c2b1d29 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Fri, 15 Jul 2016 19:52:20 -0500 Subject: [PATCH 25/25] PR feedback --- build_projects/update-dependencies/Program.cs | 19 ++++++++++++------- .../update-dependencies.ps1 | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/build_projects/update-dependencies/Program.cs b/build_projects/update-dependencies/Program.cs index 6374b610f..62dcd0ed5 100644 --- a/build_projects/update-dependencies/Program.cs +++ b/build_projects/update-dependencies/Program.cs @@ -64,13 +64,7 @@ namespace Microsoft.DotNet.Scripts private static IDependencyUpdater CreateProjectJsonUpdater() { - const string noUpdateFileName = ".noautoupdate"; - - IEnumerable 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)); + IEnumerable projectJsonFiles = GetProjectJsonsToUpdate(); return new ProjectJsonUpdater(projectJsonFiles) { @@ -78,6 +72,17 @@ namespace Microsoft.DotNet.Scripts }; } + private static IEnumerable 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() diff --git a/build_projects/update-dependencies/update-dependencies.ps1 b/build_projects/update-dependencies/update-dependencies.ps1 index 4ce5ea223..04b890b34 100644 --- a/build_projects/update-dependencies/update-dependencies.ps1 +++ b/build_projects/update-dependencies/update-dependencies.ps1 @@ -34,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