From e717011d9cf29968097f868065636adf9d05374a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 18 Aug 2015 16:32:58 -0700 Subject: [PATCH 01/25] Fixup feeds used for branching. --- makefile.shade | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/makefile.shade b/makefile.shade index e35158aabe..c5d23dbc39 100644 --- a/makefile.shade +++ b/makefile.shade @@ -163,7 +163,9 @@ var buildTarget = "compile" if (File.Exists(nugetConfigPath)) { var original = File.ReadAllText(nugetConfigPath); - var modified = original.Replace("https://www.myget.org/F/aspnetvnext", "https://www.myget.org/F/aspnetrelease"); + var modified = original + .Replace("https://www.myget.org/F/aspnetlitedev", "https://www.myget.org/F/aspnetliterelease") + .Replace("https://www.myget.org/F/azureadwebstacknightly", "https://www.myget.org/F/azureadwebstackrelease"); if (!string.Equals(original, modified, StringComparison.Ordinal)) { From edd17c020e8c7502563ec47623a76c75df07b2ad Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 1 Sep 2015 15:00:32 -0700 Subject: [PATCH 02/25] Enable MusicStore tests to be run --- makefile.shade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makefile.shade b/makefile.shade index c5d23dbc39..5b09d2b599 100644 --- a/makefile.shade +++ b/makefile.shade @@ -153,11 +153,11 @@ var buildTarget = "compile" } Log.Info("No conflicts in repos, continuing with creating release branch."); - + foreach (var repo in GetAllRepos()) { GitCommand(repo, "checkout origin/dev -B release"); - + // Update NuGet.Config var nugetConfigPath = Path.Combine(repo, "NuGet.config"); if (File.Exists(nugetConfigPath)) @@ -565,7 +565,6 @@ functions var nonDefaultRepos = new[] { "DNX", - "MusicStore", "Coherence", "Coherence-Signed", "dnvm", @@ -733,6 +732,7 @@ functions "SignalR-SQLServer", "SignalR-Redis", "Entropy", + "MusicStore" }; var repositoryInclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_INCLUDE"); From 1b6d027fc1c540446fea54865905da728c322ba0 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 1 Sep 2015 15:03:47 -0700 Subject: [PATCH 03/25] Using Json parsing code from DNX Fixes #141 --- build/Json.shade | 883 ++++++++++++++++++++++++++++++++++++++++++++ build/_k-test.shade | 33 +- 2 files changed, 899 insertions(+), 17 deletions(-) create mode 100644 build/Json.shade diff --git a/build/Json.shade b/build/Json.shade new file mode 100644 index 0000000000..c16cbacd17 --- /dev/null +++ b/build/Json.shade @@ -0,0 +1,883 @@ +use namespace='System' +use namespace='System.Collections.Generic' +use namespace='System.Globalization' +use namespace='System.IO' +use namespace='System.Text' + +functions @{ + public class JsonArray : JsonValue + { + private readonly JsonValue[] _array; + + public JsonArray(JsonValue[] array, int line, int column) + : base(line, column) + { + if (array == null) + { + throw new ArgumentNullException("array"); + } + + _array = array; + } + + public int Length { get { return _array.Length; } } + public IEnumerable Values { get { return _array; }} + public JsonValue this[int index] { get { return _array[index]; }} + } + + public class JsonBoolean : JsonValue + { + public JsonBoolean(JsonToken token) + : base(token.Line, token.Column) + { + if (token.Type == JsonTokenType.True) + { + Value = true; + } + else if (token.Type == JsonTokenType.False) + { + Value = false; + } + else + { + throw new ArgumentException("Token value should be either True or False.", "token"); + } + } + + public bool Value { get; private set; } + + public static implicit operator bool (JsonBoolean jsonBoolean) + { + return jsonBoolean.Value; + } + } + + public class JsonString : JsonValue + { + private readonly string _value; + + public JsonString(string value, int line, int column) + : base(line, column) + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + + _value = value; + } + + public string Value + { + get { return _value; } + } + + public override string ToString() + { + return _value; + } + + public static implicit operator string (JsonString instance) + { + if (instance == null) + { + return null; + } + else + { + return instance.Value; + } + } + } + + public class JsonNull : JsonValue + { + public JsonNull(int line, int column) + : base(line, column) + { + } + } + + public class JsonValue + { + public JsonValue(int line, int column) + { + Line = line; + Column = column; + } + + public int Line { get; private set; } + + public int Column { get; private set; } + } + + public class JsonObject : JsonValue + { + private readonly IDictionary _data; + + public JsonObject(IDictionary data, int line, int column) + : base(line, column) + { + if (data == null) + { + throw new ArgumentNullException("data"); + } + + _data = data; + } + + public ICollection Keys + { + get { return _data.Keys; } + } + + public JsonValue Value(string key) + { + JsonValue result; + if (!_data.TryGetValue(key, out result)) + { + result = null; + } + + return result; + } + + public JsonObject ValueAsJsonObject(string key) + { + return Value(key) as JsonObject; + } + + public JsonString ValueAsString(string key) + { + return Value(key) as JsonString; + } + + public int ValueAsInt(string key) + { + var number = Value(key) as JsonNumber; + if (number == null) + { + throw new FormatException(); + } + return Convert.ToInt32(number.Raw); + } + + public bool ValueAsBoolean(string key, bool defaultValue = false) + { + var boolVal = Value(key) as JsonBoolean; + if (boolVal != null) + { + return boolVal.Value; + } + + return defaultValue; + } + + public bool? ValueAsNullableBoolean(string key) + { + var boolVal = Value(key) as JsonBoolean; + if (boolVal != null) + { + return boolVal.Value; + } + + return null; + } + + public string[] ValueAsStringArray(string key) + { + var list = Value(key) as JsonArray; + if (list == null) + { + return null; + } + + var result = new string[list.Length]; + + for (int i = 0; i < list.Length; ++i) + { + var jsonString = list[i] as JsonString; + if (jsonString != null) + { + result[i] = jsonString.ToString(); + } + } + + return result; + } + + internal object ValueAsJsonObject(object packIncludePropertyName) + { + throw new NotImplementedException(); + } + } + + public class JsonNumber : JsonValue + { + private readonly string _raw; + private readonly double _double; + + public JsonNumber(JsonToken token) + : base(token.Line, token.Column) + { + try + { + _raw = token.Value; + _double = double.Parse(_raw, NumberStyles.Float); + } + catch (FormatException ex) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidFloatNumberFormat(_raw), + ex, + token.Line, + token.Column); + } + catch (OverflowException ex) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_FloatNumberOverflow(_raw), + ex, + token.Line, + token.Column); + } + } + + public double Double + { + get { return _double; } + } + + public string Raw + { + get { return _raw; } + } + } + + public static class Json + { + public static JsonValue Deserialize(string content) + { + using (var reader = new StringReader(content)) + { + return Deserialize(reader); + } + } + + public static JsonValue Deserialize(TextReader reader) + { + if (reader == null) + { + throw new ArgumentNullException("reader"); + } + + var buffer = new JsonBuffer(reader); + + var result = DeserializeInternal(buffer.Read(), buffer); + + // There are still unprocessed char. The parsing is not finished. Error happened. + var nextToken = buffer.Read(); + if (nextToken.Type != JsonTokenType.EOF) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_UnfinishedJSON(nextToken.Value), + nextToken); + } + + return result; + } + + private static JsonValue DeserializeInternal(JsonToken next, JsonBuffer buffer) + { + if (next.Type == JsonTokenType.EOF) + { + return null; + } + + if (next.Type == JsonTokenType.LeftSquareBracket) + { + return DeserializeArray(next, buffer); + } + + if (next.Type == JsonTokenType.LeftCurlyBracket) + { + return DeserializeObject(next, buffer); + } + + if (next.Type == JsonTokenType.String) + { + return new JsonString(next.Value, next.Line, next.Column); + } + + if (next.Type == JsonTokenType.True || next.Type == JsonTokenType.False) + { + return new JsonBoolean(next); + } + + if (next.Type == JsonTokenType.Null) + { + return new JsonNull(next.Line, next.Column); + } + + if (next.Type == JsonTokenType.Number) + { + return new JsonNumber(next); + } + + throw new JsonDeserializerException(JsonDeserializerResource.Format_InvalidTokenExpectation( + next.Value, "'{', (char)'[', true, false, null, JSON string, JSON number, or the end of the file"), + next); + } + + private static JsonArray DeserializeArray(JsonToken head, JsonBuffer buffer) + { + var list = new List(); + while (true) + { + var next = buffer.Read(); + if (next.Type == JsonTokenType.RightSquareBracket) + { + break; + } + + list.Add(DeserializeInternal(next, buffer)); + + next = buffer.Read(); + if (next.Type == JsonTokenType.EOF) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxExpectation("JSON array", (char)']', (char)','), + next); + } + else if (next.Type == JsonTokenType.RightSquareBracket) + { + break; + } + else if (next.Type != JsonTokenType.Comma) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxExpectation("JSON array", (char)','), + next); + } + } + + return new JsonArray(list.ToArray(), head.Line, head.Column); + } + + private static JsonObject DeserializeObject(JsonToken head, JsonBuffer buffer) + { + var dictionary = new Dictionary(); + + // Loop through each JSON entry in the input object + while (true) + { + var next = buffer.Read(); + if (next.Type == JsonTokenType.EOF) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxExpectation("JSON object", (char)'}'), + next); + } + + if (next.Type == JsonTokenType.Colon) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxNotExpected("JSON object", (char)':'), + next); + } + else if (next.Type == JsonTokenType.RightCurlyBracket) + { + break; + } + else + { + if (next.Type != JsonTokenType.String) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxExpectation("JSON object member name", "JSON string"), + next); + } + + var memberName = next.Value; + if (dictionary.ContainsKey(memberName)) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_DuplicateObjectMemberName(memberName), + next); + } + + next = buffer.Read(); + if (next.Type != JsonTokenType.Colon) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxExpectation("JSON object", (char)':'), + next); + } + + dictionary[memberName] = DeserializeInternal(buffer.Read(), buffer); + + next = buffer.Read(); + if (next.Type == JsonTokenType.RightCurlyBracket) + { + break; + } + else if (next.Type != JsonTokenType.Comma) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxExpectation("JSON object", (char)',', (char)'}'), + next); + } + } + } + + return new JsonObject(dictionary, head.Line, head.Column); + } + } + + internal class JsonBuffer + { + public const string ValueNull = "null"; + public const string ValueTrue = "true"; + public const string ValueFalse = "false"; + + private readonly StringBuilder _buffer = new StringBuilder(); + private readonly StringBuilder _codePointBuffer = new StringBuilder(4); + private readonly TextReader _reader; + private JsonToken _token; + private int _line; + private int _column; + + public JsonBuffer(TextReader reader) + { + _reader = reader; + _line = 1; + } + + public JsonToken Read() + { + int first; + while (true) + { + first = ReadNextChar(); + + if (first == -1) + { + _token.Type = JsonTokenType.EOF; + return _token; + } + else if (!IsWhitespace(first)) + { + break; + } + } + + _token.Value = ((char)first).ToString(); + _token.Line = _line; + _token.Column = _column; + + if (first == (char)'{') + { + _token.Type = JsonTokenType.LeftCurlyBracket; + } + else if (first == (char)'}') + { + _token.Type = JsonTokenType.RightCurlyBracket; + } + else if (first == (char)'[') + { + _token.Type = JsonTokenType.LeftSquareBracket; + } + else if (first == (char)']') + { + _token.Type = JsonTokenType.RightSquareBracket; + } + else if (first == (char)':') + { + _token.Type = JsonTokenType.Colon; + } + else if (first == (char)',') + { + _token.Type = JsonTokenType.Comma; + } + else if (first == (char)'"') + { + _token.Type = JsonTokenType.String; + _token.Value = ReadString(); + } + else if (first == (char)'t') + { + ReadLiteral(ValueTrue); + _token.Type = JsonTokenType.True; + } + else if (first == (char)'f') + { + ReadLiteral(ValueFalse); + _token.Type = JsonTokenType.False; + } + else if (first == (char)'n') + { + ReadLiteral(ValueNull); + _token.Type = JsonTokenType.Null; + } + else if ((first >= (char)'0' && first <= (char)'9') || first == (char)'-') + { + _token.Type = JsonTokenType.Number; + _token.Value = ReadNumber(first); + } + else + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_IllegalCharacter(first), + _token); + } + + // JsonToken is a value type + return _token; + } + + private int ReadNextChar() + { + while (true) + { + var value = _reader.Read(); + _column++; + + if (value == -1) + { + // This is the end of file + return -1; + } + else if (value == (char)'\n') + { + // This is a new line. Let the next loop read the first charactor of the following line. + // Set position ahead of next line + _column = 0; + _line++; + + continue; + } + else if (value == (char)'\r') + { + // Skip the carriage return. + // Let the next loop read the following char + } + else + { + // Returns the normal value + return value; + } + } + } + + private string ReadNumber(int firstRead) + { + _buffer.Clear(); + _buffer.Append((char)firstRead); + + while (true) + { + var next = _reader.Peek(); + + if ((next >= (char)'0' && next <= (char)'9') || + next == (char)'.' || + next == (char)'e' || + next == (char)'E') + { + _buffer.Append((char)ReadNextChar()); + } + else + { + break; + } + } + + return _buffer.ToString(); + } + + private void ReadLiteral(string literal) + { + for (int i = 1; i < literal.Length; ++i) + { + var next = _reader.Peek(); + if (next != literal[i]) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_UnrecognizedLiteral(literal), + _line, _column); + } + else + { + ReadNextChar(); + } + } + + var tail = _reader.Peek(); + if (tail != (char)'}' && + tail != (char)']' && + tail != (char)',' && + tail != (char)'\n' && + tail != -1 && + !IsWhitespace(tail)) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_IllegalTrailingCharacterAfterLiteral(tail, literal), + _line, _column); + } + } + + private string ReadString() + { + _buffer.Clear(); + var escaped = false; + + while (true) + { + var next = ReadNextChar(); + + if (next == -1 || next == (char)'\n') + { + throw new JsonDeserializerException( + JsonDeserializerResource.JSON_OpenString, + _line, _column); + } + else if (escaped) + { + if ((next == (char)'"') || (next == (char)'\\') || (next == (char)'/')) + { + _buffer.Append((char)next); + } + else if (next == (char)'b') + { + // (char)'\b' backspace + _buffer.Append('\b'); + } + else if (next == (char)'f') + { + // (char)'\f' form feed + _buffer.Append('\f'); + } + else if (next == (char)'n') + { + // (char)'\n' line feed + _buffer.Append('\n'); + } + else if (next == (char)'r') + { + // (char)'\r' carriage return + _buffer.Append('\r'); + } + else if (next == (char)'t') + { + // (char)'\t' tab + _buffer.Append('\t'); + } + else if (next == (char)'u') + { + // (char)'\uXXXX' unicode + var unicodeLine = _line; + var unicodeColumn = _column; + + _codePointBuffer.Clear(); + for (int i = 0; i < 4; ++i) + { + next = ReadNextChar(); + if (next == -1) + { + throw new JsonDeserializerException( + JsonDeserializerResource.JSON_InvalidEnd, + unicodeLine, + unicodeColumn); + } + else + { + _codePointBuffer[i] = (char)next; + } + } + + try + { + var unicodeValue = int.Parse(_codePointBuffer.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + _buffer.Append((char)unicodeValue); + } + catch (FormatException ex) + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidUnicode(_codePointBuffer.ToString()), + ex, + unicodeLine, + unicodeColumn); + } + } + else + { + throw new JsonDeserializerException( + JsonDeserializerResource.Format_InvalidSyntaxNotExpected("charactor escape", "\\" + next), + _line, + _column); + } + + escaped = false; + } + else if (next == (char)'\\') + { + escaped = true; + } + else if (next == (char)'"') + { + break; + } + else + { + _buffer.Append((char)next); + } + } + + return _buffer.ToString(); + } + + private static bool IsWhitespace(int value) + { + return value == (char)' ' || value == (char)'\t' || value == (char)'\r'; + } + } + + public enum JsonTokenType + { + LeftCurlyBracket, // [ + LeftSquareBracket, // { + RightCurlyBracket, // ] + RightSquareBracket, // } + Colon, // : + Comma, // , + Null, + True, + False, + Number, + String, + EOF + } + + public struct JsonToken + { + public JsonTokenType Type; + public string Value; + public int Line; + public int Column; + } + + public class JsonDeserializerException : Exception + { + public JsonDeserializerException(string message, Exception innerException, int line, int column) + : base(message, innerException) + { + Line = line; + Column = column; + } + + public JsonDeserializerException(string message, int line, int column) + : base(message) + { + Line = line; + Column = column; + } + + public JsonDeserializerException(string message, JsonToken nextToken) + : base(message) + { + Line = nextToken.Line; + Column = nextToken.Column; + } + + public int Line { get; private set; } + + public int Column { get; private set; } + } + + internal class JsonDeserializerResource + { + internal static string Format_IllegalCharacter(int value) + { + return string.Format("Illegal character (char)'{0}' (Unicode hexadecimal {0:X4}).", value); + } + + internal static string Format_IllegalTrailingCharacterAfterLiteral(int value, string literal) + { + return string.Format("Illegal character(char)'{0}'(Unicode hexadecimal { 0:X4}) after the literal name (char)'{1}'.", value, literal); + } + + internal static string Format_UnrecognizedLiteral(string literal) + { + return string.Format("Invalid JSON literal.Expected literal(char)'{0}'.", literal); + } + + internal static string Format_DuplicateObjectMemberName(string memberName) + { + return Format_InvalidSyntax("JSON object", string.Format("Duplicate member name(char)'{0}'", memberName)); + } + + internal static string Format_InvalidFloatNumberFormat(string raw) + { + return string.Format("Invalid float number format: {0}", raw); + } + + internal static string Format_FloatNumberOverflow(string raw) + { + return string.Format("Float number overflow: {0}", raw); + } + + internal static string Format_InvalidSyntax(string syntaxName, string issue) + { + return string.Format("Invalid {0}syntax. {1}.", syntaxName, issue); + } + + internal static string Format_InvalidSyntaxNotExpected(string syntaxName, char unexpected) + { + return string.Format("Invalid {0} syntax.Unexpected(char)'{1}'.", syntaxName, unexpected); + } + + internal static string Format_InvalidSyntaxNotExpected(string syntaxName, string unexpected) + { + return string.Format("Invalid {0} syntax.Unexpected { 1}.", syntaxName, unexpected); + } + + internal static string Format_InvalidSyntaxExpectation(string syntaxName, char expectation) + { + return string.Format("Invalid {0} syntax.Expected(char)'{1}'.", syntaxName, expectation); + } + + internal static string Format_InvalidSyntaxExpectation(string syntaxName, string expectation) + { + return string.Format("Invalid {0} syntax.Expected {1}.", syntaxName, expectation); + } + + internal static string Format_InvalidSyntaxExpectation(string syntaxName, char expectation1, char expectation2) + { + return string.Format("Invalid {0} syntax.Expected(char)'{1}' or(char)'{2}'.", syntaxName, expectation1, expectation2); + } + + internal static string Format_InvalidTokenExpectation(string tokenValue, string expectation) + { + return string.Format("Unexpected token(char)'{0}'.Expected {1}.", tokenValue, expectation); + } + + internal static string Format_InvalidUnicode(string unicode) + { + return string.Format("Invalid Unicode[{0}]", unicode); + } + + internal static string Format_UnfinishedJSON(string nextTokenValue) + { + return string.Format("Invalid JSON end.Unprocessed token {0}.", nextTokenValue); + } + + internal static string JSON_OpenString + { + get { return Format_InvalidSyntaxExpectation("JSON string", (char)'\"'); } + } + + internal static string JSON_InvalidEnd + { + get { return "Invalid JSON. Unexpected end of file."; } + } + } +} \ No newline at end of file diff --git a/build/_k-test.shade b/build/_k-test.shade index 431bf4a817..765dd13d02 100644 --- a/build/_k-test.shade +++ b/build/_k-test.shade @@ -1,5 +1,4 @@ -use namespace='System.Web.Script.Serialization' -use assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" +use import="Json" use import="Environment" default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}' @@ -15,16 +14,12 @@ projectFile='' */} @{ - var serializer = new JavaScriptSerializer(); var projectText = File.ReadAllText(projectFile); - var project = (Dictionary)serializer.DeserializeObject(projectText); + var project = (JsonObject)Json.Deserialize(projectText); - object commandsObject; - var commands = project.TryGetValue("commands", out commandsObject) - ? (Dictionary)commandsObject - : new Dictionary(); + var commands = project.ValueAsJsonObject("commands"); - if (commands.Keys.Contains("test")) + if (commands != null && commands.Keys.Contains("test")) { var projectFolder = Path.GetDirectoryName(projectFile); var projectName = Path.GetFileName(projectFolder); @@ -35,16 +30,20 @@ projectFile='' noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)',')); } - object configsObject; - var configs = project.TryGetValue("frameworks", out configsObject) - ? (Dictionary)configsObject - : new Dictionary - { - { "dnx451", new Dictionary() } // Assume dnx451 only if none specified - }; + var configs = project.ValueAsJsonObject("frameworks"); + IEnumerable targetFrameworks; + if (configs == null) + { + // Assume dnx451 only if none specified + targetFrameworks = new[] { "dnx451" }; + } + else + { + targetFrameworks = configs.Keys; + } // Currently only dnx* targets are supported. See aspnet/Universe#53 - var targetFrameworks = configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase)); + targetFrameworks = targetFrameworks.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase)); foreach (var framework in targetFrameworks) { From 7e2b09c249830bea47c8fd01c05d481286fd4f87 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 2 Sep 2015 20:38:51 -0700 Subject: [PATCH 04/25] Update dnvm.ps1 to use aspnetlitedev feed. --- build/dnvm.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dnvm.ps1 b/build/dnvm.ps1 index 9d6bc1b931..bda1a96dd4 100644 --- a/build/dnvm.ps1 +++ b/build/dnvm.ps1 @@ -84,8 +84,8 @@ Set-Variable -Option Constant "CommandFriendlyName" ".NET Version Manager" Set-Variable -Option Constant "DefaultUserDirectoryName" ".dnx" Set-Variable -Option Constant "OldUserDirectoryNames" @(".kre", ".k") Set-Variable -Option Constant "RuntimePackageName" "dnx" -Set-Variable -Option Constant "DefaultFeed" "https://www.myget.org/F/aspnetvnext/api/v2" -Set-Variable -Option Constant "DefaultUnstableFeed" "https://www.myget.org/F/aspnetvnext/api/v2" +Set-Variable -Option Constant "DefaultFeed" "https://www.myget.org/F/aspnetlitedev/api/v2" +Set-Variable -Option Constant "DefaultUnstableFeed" "https://www.myget.org/F/aspnetlitedev/api/v2" Set-Variable -Option Constant "CrossGenCommand" "dnx-crossgen" Set-Variable -Option Constant "OldCrossGenCommand" "k-crossgen" Set-Variable -Option Constant "CommandPrefix" "dnvm-" From a24c7093448bcaaa41324474a532200e83072632 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 2 Sep 2015 22:15:17 -0700 Subject: [PATCH 05/25] Update dnvm.sh to use aspnetlitedev feed. --- build/dnvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dnvm.sh b/build/dnvm.sh index 1eaa13063b..0cda5f19e1 100644 --- a/build/dnvm.sh +++ b/build/dnvm.sh @@ -11,8 +11,8 @@ _DNVM_RUNTIME_FOLDER_NAME=".dnx" _DNVM_COMMAND_NAME="dnvm" _DNVM_PACKAGE_MANAGER_NAME="dnu" _DNVM_VERSION_MANAGER_NAME=".NET Version Manager" -_DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetvnext/api/v2" -_DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetvnext/api/v2" +_DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetlitedev/api/v2" +_DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetlitedev/api/v2" _DNVM_UPDATE_LOCATION="https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh" _DNVM_HOME_VAR_NAME="DNX_HOME" From c6db2c06f51db8a0369434b93adca105c32db4f0 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 4 Sep 2015 11:51:41 -0700 Subject: [PATCH 06/25] Add BasicMiddleware and Proxy repos to the build list --- makefile.shade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/makefile.shade b/makefile.shade index 5b09d2b599..e922c13f6e 100644 --- a/makefile.shade +++ b/makefile.shade @@ -725,6 +725,8 @@ functions "WebSockets", "Localization", "Session", + "BasicMiddleware", + "Proxy", "Mvc", "Identity", "Scaffolding", From cddcb3b45705038e02e91dc0f0df9430358957ae Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 19 Aug 2015 15:05:30 -0700 Subject: [PATCH 07/25] Add BrowserLink --- makefile.shade | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile.shade b/makefile.shade index e922c13f6e..b0e492e57a 100644 --- a/makefile.shade +++ b/makefile.shade @@ -733,6 +733,7 @@ functions "SignalR-Server", "SignalR-SQLServer", "SignalR-Redis", + "BrowserLink", "Entropy", "MusicStore" }; From 53a8ee36f3c707c1ae4de5a04b6fc4f1a47fbfc2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 1 Sep 2015 15:06:08 -0700 Subject: [PATCH 08/25] Stop building Universe in Travis and AppVeyor --- .travis.yml | 4 ---- appveyor.yml | 7 ------- 2 files changed, 11 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 947bf868ee..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: csharp -sudo: false -script: - - ./build.sh --quiet verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 636a7618d3..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,7 +0,0 @@ -init: - - git config --global core.autocrlf true -build_script: - - build.cmd --quiet verify -clone_depth: 1 -test: off -deploy: off \ No newline at end of file From 864cc39ce21fdd06437043e40a2f3a0945b3c89d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Sep 2015 11:19:24 -0700 Subject: [PATCH 09/25] Updating to Sake 0.2.2 --- build.cmd | 4 ++-- build/BuildEnv.shade | 7 ------- build/_k-standard-goals.shade | 1 + makefile.shade | 1 + 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/build.cmd b/build.cmd index dbec262472..1875618091 100644 --- a/build.cmd +++ b/build.cmd @@ -15,5 +15,5 @@ md .nuget copy %CACHED_NUGET% .nuget\nuget.exe > nul :build -.nuget\nuget.exe install Sake -version 0.2 -o packages -packages\Sake.0.2\tools\Sake.exe -I build -f makefile.shade %* +.nuget\nuget.exe install Sake -version 0.2.2 -o packages -ExcludeVersion +packages\Sake\tools\Sake.exe -I build -f makefile.shade %* diff --git a/build/BuildEnv.shade b/build/BuildEnv.shade index 0c29b03f52..81d7d716c5 100644 --- a/build/BuildEnv.shade +++ b/build/BuildEnv.shade @@ -26,13 +26,6 @@ functions return "t" + DateTime.UtcNow.ToString("yyMMddHHmmss"); } } - bool IsTeamCity - { - get - { - return Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; - } - } bool IsBuildV2 { diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index c727e6e38a..2572ad7667 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -6,6 +6,7 @@ use namespace="System.Linq" use import="Files" use import="BuildEnv" use import="Environment" +use-teamcity default BASE_DIR='${Directory.GetCurrentDirectory()}' default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}' diff --git a/makefile.shade b/makefile.shade index b0e492e57a..c8fda39f4f 100644 --- a/makefile.shade +++ b/makefile.shade @@ -2,6 +2,7 @@ var PROJECT='AspNet' var VERSION='0.2.1' +use-teamcity use namespace='System' use namespace='System.IO' use namespace='System.Collections.Generic' From a0d51b9c2fd023cba14564cd378adbedb37fb785 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 9 Sep 2015 11:51:16 -0700 Subject: [PATCH 10/25] Added Nuget feed and renamed packagelist json --- build/_k-standard-goals.shade | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index 2572ad7667..d196df09bb 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -14,8 +14,9 @@ default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}' default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' default Configuration='${E("Configuration")}' default Quiet='${ false }' -default PACKAGELIST_JSON_FILENAME = 'packages.json' +default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json' default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2' +default NUGET_FEED = 'https://api.nuget.org/v3/index.json' @{ if (string.IsNullOrEmpty(E("DNX_BUILD_VERSION"))) @@ -216,7 +217,7 @@ default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2' #nuget-verify target='test' if='File.Exists(PACKAGELIST_JSON_FILENAME) && ShouldVerifyNupkgs' description='Verify if all the packages are generated properly' var commandsDirectory = '${Path.Combine(BASE_DIR, "commands")}' - exec program='cmd' commandline='/C dnu commands install --source ${DNX_TOOLS_FEED} NuGetPackageVerifier --packages "${commandsDirectory}"' + exec program='cmd' commandline='/C dnu commands install --source ${DNX_TOOLS_FEED} --source ${NUGET_FEED} NuGetPackageVerifier --packages "${commandsDirectory}"' exec program='cmd' commandline='/C ${Path.Combine(commandsDirectory, "nugetverify")} "${BUILD_DIR}" "${Path.Combine(BASE_DIR, PACKAGELIST_JSON_FILENAME)}"' @{ if (Directory.Exists(commandsDirectory)) From 15521ffc2b495e67fc8aaf12e175295a198eec75 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 9 Sep 2015 15:08:09 -0700 Subject: [PATCH 11/25] Updating Sake to 0.2.2 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 203b034a33..74e557877c 100755 --- a/build.sh +++ b/build.sh @@ -24,7 +24,7 @@ fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion + mono .nuget/nuget.exe install Sake -version 0.2.2 -o packages -ExcludeVersion fi if ! type dnvm > /dev/null 2>&1; then From a7bebaae83b0540a6e6b37b9be2a20d912eac39a Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 9 Sep 2015 15:18:10 -0700 Subject: [PATCH 12/25] Updating Sake to always use latest version --- build.cmd | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index 1875618091..7d5b16e8dc 100644 --- a/build.cmd +++ b/build.cmd @@ -15,5 +15,5 @@ md .nuget copy %CACHED_NUGET% .nuget\nuget.exe > nul :build -.nuget\nuget.exe install Sake -version 0.2.2 -o packages -ExcludeVersion +.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages packages\Sake\tools\Sake.exe -I build -f makefile.shade %* diff --git a/build.sh b/build.sh index 74e557877c..fd756bc44b 100755 --- a/build.sh +++ b/build.sh @@ -24,7 +24,7 @@ fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -version 0.2.2 -o packages -ExcludeVersion + mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages fi if ! type dnvm > /dev/null 2>&1; then From d59fa774a8ae219d3af1aae2dd256d8bc9c799ce Mon Sep 17 00:00:00 2001 From: moozzyk Date: Thu, 25 Jun 2015 15:43:53 -0700 Subject: [PATCH 13/25] Updating licenses --- KoreBuild.nuspec | 4 ++-- build-template/makefile.shade | 2 +- build/dnvm.ps1 | 2 +- build/dnvm.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/KoreBuild.nuspec b/KoreBuild.nuspec index eb6212bfc9..e06cc5b03b 100644 --- a/KoreBuild.nuspec +++ b/KoreBuild.nuspec @@ -4,8 +4,8 @@ KoreBuild The ProjectK build tools 0.0 - Microsoft Open Technologies, Inc. - Microsoft Open Technologies, Inc. + .NET Foundation + .NET Foundation ProjectK build tooling en-US diff --git a/build-template/makefile.shade b/build-template/makefile.shade index 562494d144..4131e6502e 100644 --- a/build-template/makefile.shade +++ b/build-template/makefile.shade @@ -1,7 +1,7 @@ var VERSION='0.1' var FULL_VERSION='0.1' -var AUTHORS='Microsoft Open Technologies, Inc.' +var AUTHORS='.NET Foundation' use-standard-lifecycle k-standard-goals diff --git a/build/dnvm.ps1 b/build/dnvm.ps1 index bda1a96dd4..35284defad 100644 --- a/build/dnvm.ps1 +++ b/build/dnvm.ps1 @@ -68,7 +68,7 @@ function _WriteOut { ### Constants $ProductVersion="1.0.0" $BuildVersion="beta6-10394" -$Authors="Microsoft Open Technologies, Inc." +$Authors=".NET Foundation" # If the Version hasn't been replaced... # We can't compare directly with the build version token diff --git a/build/dnvm.sh b/build/dnvm.sh index 0cda5f19e1..ad7b5fa17a 100644 --- a/build/dnvm.sh +++ b/build/dnvm.sh @@ -3,7 +3,7 @@ # "Constants" _DNVM_BUILDNUMBER="beta6-10394" -_DNVM_AUTHORS="Microsoft Open Technologies, Inc." +_DNVM_AUTHORS=".NET Foundation" _DNVM_RUNTIME_PACKAGE_NAME="dnx" _DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment" _DNVM_RUNTIME_SHORT_NAME="DNX" From 22952e1806c92a31cf13b7c3bfdfd3bcd92eda65 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Mon, 1 Jun 2015 14:57:48 -0700 Subject: [PATCH 14/25] Add `restoreDir` parameter in `_k-restore.shade` - enables use of this command where it's currently overridden - in turn, this means `--quiet` would be honoured in those `makefile.shade` files For example can use this hook to shut DNX build up a bit - `makefile.shade` there calls `dnu restore` directly and ignores `--quiet` --- build/_k-restore.shade | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/build/_k-restore.shade b/build/_k-restore.shade index a082afb5eb..de5d385de1 100644 --- a/build/_k-restore.shade +++ b/build/_k-restore.shade @@ -1,10 +1,16 @@ @{/* k-restore - Restores nuget packages required for k projects. Downloads and executes k sdk tools. + Restores nuget packages required for DNX projects. Downloads and executes DNX sdk tools. + +restoreDir='' + Optional. The directory in which to execute the dnu restore command. */} -default restore_options='${E("NUGET3_restore_options")}' +default currentDir = '${ Directory.GetCurrentDirectory() }' +default restoreDir = '${ currentDir }' -exec program='cmd' commandline='/C dnu restore --parallel ${restore_options}' if='!IsMono' -exec program='dnu' commandline='restore${restore_options}' if='IsMono' \ No newline at end of file +default restore_options='${ E("NUGET3_restore_options") }' + +exec program='cmd' commandline='/C dnu restore --parallel ${ restore_options }' workingdir='${ restoreDir }' if='!IsMono' +exec program='dnu' commandline='restore ${ restore_options }' workingdir='${ restoreDir }' if='IsMono' \ No newline at end of file From 5008e2743d1d0992af86d98a321ac88bd979fafd Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 15 Sep 2015 11:45:32 -0700 Subject: [PATCH 15/25] Removed style cop related shade files --- build/_stylecop-run.shade | 11 ----------- build/_stylecop-setup.shade | 24 ------------------------ 2 files changed, 35 deletions(-) delete mode 100644 build/_stylecop-run.shade delete mode 100644 build/_stylecop-setup.shade diff --git a/build/_stylecop-run.shade b/build/_stylecop-run.shade deleted file mode 100644 index 0b729e651f..0000000000 --- a/build/_stylecop-run.shade +++ /dev/null @@ -1,11 +0,0 @@ -@{/* - -stylecop-run - Run StyleCop for your project. - -projectFile='' - Required. Path to the test project.json to use. - -*/} - -exec program='bin\_stylecop\bin\StyleCop.KRunner.exe' commandline='${projectFile}' \ No newline at end of file diff --git a/build/_stylecop-setup.shade b/build/_stylecop-setup.shade deleted file mode 100644 index 7c8e6369e7..0000000000 --- a/build/_stylecop-setup.shade +++ /dev/null @@ -1,24 +0,0 @@ -@{/* - -stylecop-setup - Downloads packages to prepare for running stylecop - -*/} - var packagesDirectory = 'bin\_stylecop' - var binariesDirectory = 'bin\_stylecop\bin' - - nuget-install package='StyleCop.KRunner' outputDir='${packagesDirectory}' extra='-pre -ExcludeVersion' - nuget-install package='StyleCop.KRules' outputDir='${packagesDirectory}' extra='-pre -ExcludeVersion' - -@{ - var binaries = - Files.Include(Path.Combine(packagesDirectory, "*", "*net45*", "*.*")) - .Concat(Files.Include(Path.Combine(packagesDirectory, "*lib*", "*.dll"))); - - Directory.CreateDirectory(binariesDirectory); - - foreach(var file in binaries) - { - File.Copy(file, Path.Combine(binariesDirectory, Path.GetFileName(file)), true); - } -} \ No newline at end of file From c2db08e3a758042f0e586ca63065f86867ab32ef Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 16 Sep 2015 16:35:48 -0700 Subject: [PATCH 16/25] Update build-template --- build-template/NuGet.Config | 4 ++-- build-template/NuGet.master.config | 3 +-- build-template/NuGet.release.config | 8 -------- build-template/build.cmd | 18 ++++++++++-------- build-template/build.sh | 2 +- build-template/makefile.shade | 2 +- 6 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 build-template/NuGet.release.config diff --git a/build-template/NuGet.Config b/build-template/NuGet.Config index 46c3b3e36c..b20b7336fc 100644 --- a/build-template/NuGet.Config +++ b/build-template/NuGet.Config @@ -1,7 +1,7 @@  - - + + diff --git a/build-template/NuGet.master.config b/build-template/NuGet.master.config index 4f7d6eca7f..b004e5cc74 100644 --- a/build-template/NuGet.master.config +++ b/build-template/NuGet.master.config @@ -2,7 +2,6 @@ - - + \ No newline at end of file diff --git a/build-template/NuGet.release.config b/build-template/NuGet.release.config deleted file mode 100644 index 0e74a4912d..0000000000 --- a/build-template/NuGet.release.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/build-template/build.cmd b/build-template/build.cmd index 5a69c96e86..b54d91cf74 100644 --- a/build-template/build.cmd +++ b/build-template/build.cmd @@ -3,6 +3,8 @@ cd %~dp0 SETLOCAL SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe +SET BUILDCMD_KOREBUILD_VERSION="" +SET BUILDCMD_DNX_VERSION="" IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... @@ -16,21 +18,21 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\KoreBuild goto run -IF DEFINED BUILDCMD_RELEASE ( - .nuget\NuGet.exe install KoreBuild -version 0.2.1-%BUILDCMD_RELEASE% -ExcludeVersion -o packages -nocache -pre -) ELSE ( +IF %BUILDCMD_KOREBUILD_VERSION%=="" ( .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +) ELSE ( + .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion +.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages IF "%SKIP_DNX_INSTALL%"=="1" goto run -IF DEFINED BUILDCMD_RELEASE ( - CALL packages\KoreBuild\build\dnvm install 1.0.0-%BUILDCMD_RELEASE% -runtime CLR -arch x86 -a default +IF %BUILDCMD_DNX_VERSION%=="" ( + CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 ) ELSE ( - CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -a default ) CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 :run CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* \ No newline at end of file diff --git a/build-template/build.sh b/build-template/build.sh index 203b034a33..fd756bc44b 100644 --- a/build-template/build.sh +++ b/build-template/build.sh @@ -24,7 +24,7 @@ fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion + mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages fi if ! type dnvm > /dev/null 2>&1; then diff --git a/build-template/makefile.shade b/build-template/makefile.shade index 4131e6502e..562494d144 100644 --- a/build-template/makefile.shade +++ b/build-template/makefile.shade @@ -1,7 +1,7 @@ var VERSION='0.1' var FULL_VERSION='0.1' -var AUTHORS='.NET Foundation' +var AUTHORS='Microsoft Open Technologies, Inc.' use-standard-lifecycle k-standard-goals From a10610c0cc2634a7c0dcbca82f658b48543e8ad3 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 17 Sep 2015 20:54:49 -0700 Subject: [PATCH 17/25] Update dnvm.ps1 and dnvm.sh DNX feed names to `aspnetcidev`. --- build/dnvm.ps1 | 4 ++-- build/dnvm.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/dnvm.ps1 b/build/dnvm.ps1 index 35284defad..8c04032325 100644 --- a/build/dnvm.ps1 +++ b/build/dnvm.ps1 @@ -84,8 +84,8 @@ Set-Variable -Option Constant "CommandFriendlyName" ".NET Version Manager" Set-Variable -Option Constant "DefaultUserDirectoryName" ".dnx" Set-Variable -Option Constant "OldUserDirectoryNames" @(".kre", ".k") Set-Variable -Option Constant "RuntimePackageName" "dnx" -Set-Variable -Option Constant "DefaultFeed" "https://www.myget.org/F/aspnetlitedev/api/v2" -Set-Variable -Option Constant "DefaultUnstableFeed" "https://www.myget.org/F/aspnetlitedev/api/v2" +Set-Variable -Option Constant "DefaultFeed" "https://www.myget.org/F/aspnetcidev/api/v2" +Set-Variable -Option Constant "DefaultUnstableFeed" "https://www.myget.org/F/aspnetcidev/api/v2" Set-Variable -Option Constant "CrossGenCommand" "dnx-crossgen" Set-Variable -Option Constant "OldCrossGenCommand" "k-crossgen" Set-Variable -Option Constant "CommandPrefix" "dnvm-" diff --git a/build/dnvm.sh b/build/dnvm.sh index ad7b5fa17a..140cfb6c32 100644 --- a/build/dnvm.sh +++ b/build/dnvm.sh @@ -11,8 +11,8 @@ _DNVM_RUNTIME_FOLDER_NAME=".dnx" _DNVM_COMMAND_NAME="dnvm" _DNVM_PACKAGE_MANAGER_NAME="dnu" _DNVM_VERSION_MANAGER_NAME=".NET Version Manager" -_DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetlitedev/api/v2" -_DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetlitedev/api/v2" +_DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetcidev/api/v2" +_DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetcidev/api/v2" _DNVM_UPDATE_LOCATION="https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh" _DNVM_HOME_VAR_NAME="DNX_HOME" From a3d943197a9adadcdcb0e689709d8abc870f5481 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Fri, 18 Sep 2015 12:07:48 -0700 Subject: [PATCH 18/25] Moving nuget-verify to run before test --- build/_k-standard-goals.shade | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index d196df09bb..a154daf561 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -15,7 +15,7 @@ default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' default Configuration='${E("Configuration")}' default Quiet='${ false }' default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json' -default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2' +default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v3/index.json' default NUGET_FEED = 'https://api.nuget.org/v3/index.json' @{ @@ -184,6 +184,16 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json' copy sourceDir='${Path.GetDirectoryName(project)}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR, Path.GetFileNameWithoutExtension(project))}' overwrite='${true}' each='var project in nativeProjects' +#nuget-verify target='package' if='File.Exists(PACKAGELIST_JSON_FILENAME) && ShouldVerifyNupkgs' description='Verify if all the packages are generated properly' + var commandsDirectory = '${Path.Combine(BASE_DIR, "commands")}' + exec program='cmd' commandline='/C dnu commands install --source ${DNX_TOOLS_FEED} --source ${NUGET_FEED} NuGetPackageVerifier --packages "${commandsDirectory}"' + exec program='cmd' commandline='/C ${Path.Combine(commandsDirectory, "nugetverify")} "${BUILD_DIR}" "${Path.Combine(BASE_DIR, PACKAGELIST_JSON_FILENAME)}"' + @{ + if (Directory.Exists(commandsDirectory)) + { + Directory.Delete(commandsDirectory, recursive: true); + } + } #nuget-install target='install' description='Install NuGet packages to local repo' kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}' @@ -215,17 +225,6 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json' } } -#nuget-verify target='test' if='File.Exists(PACKAGELIST_JSON_FILENAME) && ShouldVerifyNupkgs' description='Verify if all the packages are generated properly' - var commandsDirectory = '${Path.Combine(BASE_DIR, "commands")}' - exec program='cmd' commandline='/C dnu commands install --source ${DNX_TOOLS_FEED} --source ${NUGET_FEED} NuGetPackageVerifier --packages "${commandsDirectory}"' - exec program='cmd' commandline='/C ${Path.Combine(commandsDirectory, "nugetverify")} "${BUILD_DIR}" "${Path.Combine(BASE_DIR, PACKAGELIST_JSON_FILENAME)}"' - @{ - if (Directory.Exists(commandsDirectory)) - { - Directory.Delete(commandsDirectory, recursive: true); - } - } - #make-roslyn-fast ngen-roslyn From cb3dea63a32a228cdadc0eda9e7100a0e76b0469 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Fri, 18 Sep 2015 13:08:32 -0700 Subject: [PATCH 19/25] Avoid path too long errors when performing BuildV2 builds in MVC repo - do not glob to the ends of the earth when looking for `project.json` files nits: - remove unused variable in `_kpm-build.shade` - remove incorrect comment in `_kpm-pack.shade` - clean up some trailing whitespace --- build/_k-standard-goals.shade | 35 +++++++++++++++++++++-------------- build/_kpm-build.shade | 20 +++++++++----------- build/_kpm-pack.shade | 27 +++++++++++++-------------- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index a154daf561..ca2de8a781 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -36,7 +36,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json' Configuration = "Debug"; E("Configuration", Configuration); } - + Log.Info("Build v2: " + IsBuildV2); } @@ -105,7 +105,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json' { projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration)); } - + foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg"))) { File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true); @@ -115,31 +115,38 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json' #build-compile target='compile' if='IsBuildV2' @{ // If the src folder, build and create the packages - if (Directory.Exists("src")) + if (Directory.Exists("src")) { - DnuPack("src/**", BUILD_DIR, Configuration); - + // Handle projects 1 to 3 levels down from src/, avoiding path too long errors. + DnuPack("src/*;src/*/*;src/*/*/*", BUILD_DIR, Configuration); + foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg"))) { File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true); } } - + // For test and samples only check if they compile var projectsToBuild = new List(); - if (Directory.Exists("test")) + if (Directory.Exists("test")) { - projectsToBuild.Add("test/**"); + // Handle projects 1 to 3 levels down from test/, avoiding path too long errors. + projectsToBuild.Add("test/*"); + projectsToBuild.Add("test/*/*"); + projectsToBuild.Add("test/*/*/*"); } - if (Directory.Exists("samples")) + if (Directory.Exists("samples")) { - projectsToBuild.Add("samples/**"); + // Handle projects 1 to 3 levels down from samples/, avoiding path too long errors. + projectsToBuild.Add("samples/*"); + projectsToBuild.Add("samples/*/*"); + projectsToBuild.Add("samples/*/*/*"); } - - if (projectsToBuild.Any()) + + if (projectsToBuild.Any()) { DnuBuild( - string.Join(";", projectsToBuild), + string.Join(";", projectsToBuild), Configuration); } } @@ -352,7 +359,7 @@ macro name="DnuBuild" projectFile='string' configuration='string' macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string' kpm-pack - + macro name="DeleteFolder" delete='string' directory diff --git a/build/_kpm-build.shade b/build/_kpm-build.shade index b56bdc89ff..a0130af8e2 100644 --- a/build/_kpm-build.shade +++ b/build/_kpm-build.shade @@ -17,10 +17,9 @@ default build_options='${E("NUGET3_build_options")}' if (IsBuildV2) { var projectsToPack = new List(); - foreach(var arg in projectFile.Split((char)';')) { - if (!arg.Contains("*")) + if (!arg.Contains("*")) { projectsToPack.Add(Path.GetDirectoryName(arg)); } @@ -30,15 +29,15 @@ default build_options='${E("NUGET3_build_options")}' projectsToPack.AddRange(projectFolders); } } - - foreach(var projFolder in projectsToPack) - { + + foreach(var projFolder in projectsToPack) + { DeleteFolder(Path.Combine(projFolder, "bin", configuration)); } - + var projectsArg=projectFile.Replace(";", " "); var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectsArg, configuration); - if (!IsMono) + if (!IsMono) { Exec("cmd", "/C dnu " + dnuArgs); } @@ -50,13 +49,12 @@ default build_options='${E("NUGET3_build_options")}' else { var projectFolder=Path.GetDirectoryName(projectFile); - var projectName=Path.GetFileName(projectFolder); var projectBin=Path.Combine(projectFolder, "bin", configuration); - + DeleteFolder(projectBin); - + var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration); - if (!IsMono) + if (!IsMono) { Exec("cmd", "/C dnu " + dnuArgs); } diff --git a/build/_kpm-pack.shade b/build/_kpm-pack.shade index 465c3f5cca..0a438cdbef 100644 --- a/build/_kpm-pack.shade +++ b/build/_kpm-pack.shade @@ -1,7 +1,7 @@ @{/* kpm-pack - Builds package from project. Downloads and executes k sdk tools. + Builds package from project. projectFile='' Required. Path to the project.json to build. @@ -20,10 +20,9 @@ default pack_options='${E("NUGET3_pack_options")}' if (IsBuildV2) { var projectsToPack = new List(); - foreach(var arg in projectFile.Split((char)';')) { - if (!arg.Contains("*")) + if (!arg.Contains("*")) { projectsToPack.Add(Path.GetDirectoryName(arg)); } @@ -34,14 +33,14 @@ default pack_options='${E("NUGET3_pack_options")}' } } - foreach(var projFolder in projectsToPack) - { + foreach(var projFolder in projectsToPack) + { DeleteFolder(Path.Combine(projFolder, "bin", configuration)); } - + var projectsArg=projectFile.Replace(";", " "); var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectsArg, configuration); - if (!IsMono) + if (!IsMono) { Exec("cmd", "/C dnu " + dnuArgs); } @@ -49,11 +48,11 @@ default pack_options='${E("NUGET3_pack_options")}' { Exec("dnu", dnuArgs); } - - foreach(var projFolder in projectsToPack) - { + + foreach(var projFolder in projectsToPack) + { CopyFolder( - Path.Combine(projFolder, "bin", configuration), + Path.Combine(projFolder, "bin", configuration), Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)), true); } @@ -63,11 +62,11 @@ default pack_options='${E("NUGET3_pack_options")}' var projectFolder=Path.GetDirectoryName(projectFile); var projectName=Path.GetFileName(projectFolder); var projectBin=Path.Combine(projectFolder, "bin", configuration); - + DeleteFolder(projectBin); - + var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration); - if (!IsMono) + if (!IsMono) { Exec("cmd", "/C dnu " + dnuArgs); } From 7c39334783145831c6efe199f61aaec442cc377d Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 21 Sep 2015 14:55:42 -0700 Subject: [PATCH 20/25] Remove Helios --- makefile.shade | 1 - 1 file changed, 1 deletion(-) diff --git a/makefile.shade b/makefile.shade index c8fda39f4f..e6d807e1a6 100644 --- a/makefile.shade +++ b/makefile.shade @@ -713,7 +713,6 @@ functions "RazorTooling", "Hosting", "EntityFramework", - "Helios", "WebListener", "KestrelHttpServer", "ServerTests", From 345c59826c229e81778b2d1dd97dded6c42f1137 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 24 Sep 2015 15:29:59 -0700 Subject: [PATCH 21/25] Update to latest `dnvm` - beta6-10394 to beta8-15518 - grabbed from aspnet/Home but left default feed URIs alone - includes important fixes such as `dnvm use alias -r coreclr` support --- build/dnvm.ps1 | 721 +++++++++++++++++++++++++++++++++++-------------- build/dnvm.sh | 481 +++++++++++++++++++++++++-------- 2 files changed, 896 insertions(+), 306 deletions(-) diff --git a/build/dnvm.ps1 b/build/dnvm.ps1 index 8c04032325..79a303b722 100644 --- a/build/dnvm.ps1 +++ b/build/dnvm.ps1 @@ -67,8 +67,8 @@ function _WriteOut { ### Constants $ProductVersion="1.0.0" -$BuildVersion="beta6-10394" -$Authors=".NET Foundation" +$BuildVersion="beta8-15518" +$Authors="Microsoft Open Technologies, Inc." # If the Version hasn't been replaced... # We can't compare directly with the build version token @@ -82,16 +82,20 @@ $FullVersion="$ProductVersion-$BuildVersion" Set-Variable -Option Constant "CommandName" ([IO.Path]::GetFileNameWithoutExtension($ScriptPath)) Set-Variable -Option Constant "CommandFriendlyName" ".NET Version Manager" Set-Variable -Option Constant "DefaultUserDirectoryName" ".dnx" +Set-Variable -Option Constant "DefaultGlobalDirectoryName" "Microsoft DNX" Set-Variable -Option Constant "OldUserDirectoryNames" @(".kre", ".k") Set-Variable -Option Constant "RuntimePackageName" "dnx" Set-Variable -Option Constant "DefaultFeed" "https://www.myget.org/F/aspnetcidev/api/v2" +Set-Variable -Option Constant "DefaultFeedKey" "DNX_FEED" Set-Variable -Option Constant "DefaultUnstableFeed" "https://www.myget.org/F/aspnetcidev/api/v2" +Set-Variable -Option Constant "DefaultUnstableFeedKey" "DNX_UNSTABLE_FEED" Set-Variable -Option Constant "CrossGenCommand" "dnx-crossgen" Set-Variable -Option Constant "OldCrossGenCommand" "k-crossgen" Set-Variable -Option Constant "CommandPrefix" "dnvm-" Set-Variable -Option Constant "DefaultArchitecture" "x86" Set-Variable -Option Constant "DefaultRuntime" "clr" Set-Variable -Option Constant "AliasExtension" ".txt" +Set-Variable -Option Constant "DefaultOperatingSystem" "win" # These are intentionally using "%" syntax. The environment variables are expanded whenever the value is used. Set-Variable -Option Constant "OldUserHomes" @("%USERPROFILE%\.kre", "%USERPROFILE%\.k") @@ -105,8 +109,8 @@ Set-Variable -Option Constant "DNVMUpgradeUrl" "https://raw.githubusercontent.co Set-Variable -Option Constant "AsciiArt" @" ___ _ ___ ____ ___ / _ \/ |/ / | / / |/ / - / // / /| |/ / /|_/ / -/____/_/|_/ |___/_/ /_/ + / // / /| |/ / /|_/ / +/____/_/|_/ |___/_/ /_/ "@ $ExitCodes = @{ @@ -132,6 +136,8 @@ if(!$ColorScheme) { "Help_Executable"=[ConsoleColor]::DarkYellow "Feed_Name"=[ConsoleColor]::Cyan "Warning" = [ConsoleColor]::Yellow + "Error" = [ConsoleColor]::Red + "ActiveRuntime" = [ConsoleColor]::Cyan } } @@ -148,10 +154,11 @@ if($__TeeTo) { $DeprecatedCommands = @("unalias") # Load Environment variables -$RuntimeHomes = $env:DNX_HOME +$RuntimeHomes = $(if (Test-Path "env:\$HomeEnvVar") {Get-Content "env:\$HomeEnvVar"}) $UserHome = $env:DNX_USER_HOME -$ActiveFeed = $env:DNX_FEED -$ActiveUnstableFeed = $env:DNX_UNSTABLE_FEED +$GlobalHome = $env:DNX_GLOBAL_HOME +$ActiveFeed = $(if (Test-Path "env:\$DefaultFeedKey") {Get-Content "env:\$DefaultFeedKey"}) +$ActiveUnstableFeed = $(if (Test-Path "env:\$DefaultUnstableFeedKey") {Get-Content "env:\$DefaultUnstableFeedKey"}) # Default Exit Code $Script:ExitCode = $ExitCodes.Success @@ -174,10 +181,53 @@ if($CmdPathFile) { _WriteDebug "Using CMD PATH file: $CmdPathFile" } +# Determine the default installation directory (UserHome) +if(!$UserHome) { + if ($RuntimeHomes) { + _WriteDebug "Detecting User Home..." + $pf = $env:ProgramFiles + if(Test-Path "env:\ProgramFiles(x86)") { + $pf32 = Get-Content "env:\ProgramFiles(x86)" + } + + # Canonicalize so we can do StartsWith tests + if(!$pf.EndsWith("\")) { $pf += "\" } + if($pf32 -and !$pf32.EndsWith("\")) { $pf32 += "\" } + + $UserHome = $RuntimeHomes.Split(";") | Where-Object { + # Take the first path that isn't under program files + !($_.StartsWith($pf) -or $_.StartsWith($pf32)) + } | Select-Object -First 1 + + _WriteDebug "Found: $UserHome" + } + + if(!$UserHome) { + $UserHome = "$DefaultUserHome" + } +} +$UserHome = [Environment]::ExpandEnvironmentVariables($UserHome) + +# Determine the default global installation directory (GlobalHome) +if(!$GlobalHome) { + if($env:ProgramData) { + $GlobalHome = "$env:ProgramData\$DefaultGlobalDirectoryName" + } else { + $GlobalHome = "$env:AllUsersProfile\$DefaultGlobalDirectoryName" + } +} +$GlobalHome = [Environment]::ExpandEnvironmentVariables($GlobalHome) + # Determine where runtimes can exist (RuntimeHomes) if(!$RuntimeHomes) { # Set up a default value for the runtime home - $UnencodedHomes = "%USERPROFILE%\$DefaultUserDirectoryName" + $UnencodedHomes = "$UserHome;$GlobalHome" +} elseif ($RuntimeHomes.StartsWith(';')) { + _WriteOut "Ignoring invalid $HomeEnvVar; value was '$RuntimeHomes'" -ForegroundColor $ColorScheme.Warning + Clean-HomeEnv($true) + + # Use default instead. + $UnencodedHomes = "$UserHome;$GlobalHome" } else { $UnencodedHomes = $RuntimeHomes } @@ -186,51 +236,44 @@ $UnencodedHomes = $UnencodedHomes.Split(";") $RuntimeHomes = $UnencodedHomes | ForEach-Object { [Environment]::ExpandEnvironmentVariables($_) } $RuntimeDirs = $RuntimeHomes | ForEach-Object { Join-Path $_ "runtimes" } -# Determine the default installation directory (UserHome) -if(!$UserHome) { - _WriteDebug "Detecting User Home..." - $pf = $env:ProgramFiles - if(Test-Path "env:\ProgramFiles(x86)") { - $pf32 = Get-Content "env:\ProgramFiles(x86)" - } - - # Canonicalize so we can do StartsWith tests - if(!$pf.EndsWith("\")) { $pf += "\" } - if($pf32 -and !$pf32.EndsWith("\")) { $pf32 += "\" } - - $UserHome = $RuntimeHomes | Where-Object { - # Take the first path that isn't under program files - !($_.StartsWith($pf) -or $_.StartsWith($pf32)) - } | Select-Object -First 1 - - _WriteDebug "Found: $UserHome" - - if(!$UserHome) { - $UserHome = "$env:USERPROFILE\$DefaultUserDirectoryName" - } -} - _WriteDebug "" _WriteDebug "=== Running $CommandName ===" _WriteDebug "Runtime Homes: $RuntimeHomes" _WriteDebug "User Home: $UserHome" $AliasesDir = Join-Path $UserHome "alias" $RuntimesDir = Join-Path $UserHome "runtimes" +$GlobalRuntimesDir = Join-Path $GlobalHome "runtimes" $Aliases = $null ### Helper Functions +# Remove $HomeEnv from process and user environment. +# Called when current value is invalid or after installing files to default location. +function Clean-HomeEnv { + param([switch]$SkipUserEnvironment) + + if (Test-Path "env:\$HomeEnvVar") { + _WriteOut "Removing Process $HomeEnvVar" + Set-Content "env:\$HomeEnvVar" $null + } + + if (!$SkipUserEnvironment -and [Environment]::GetEnvironmentVariable($HomeEnvVar, "User")) { + _WriteOut "Removing User $HomeEnvVar" + [Environment]::SetEnvironmentVariable($HomeEnvVar, $null, "User") + } +} + # Checks if a specified file exists in the destination folder and if not, copies the file -# to the destination folder. +# to the destination folder. function Safe-Filecopy { param( - [Parameter(Mandatory=$true, Position=0)] $Filename, + [Parameter(Mandatory=$true, Position=0)] $Filename, [Parameter(Mandatory=$true, Position=1)] $SourceFolder, [Parameter(Mandatory=$true, Position=2)] $DestinationFolder) # Make sure the destination folder is created if it doesn't already exist. if(!(Test-Path $DestinationFolder)) { _WriteOut "Creating destination folder '$DestinationFolder' ... " - + New-Item -Type Directory $Destination | Out-Null } @@ -248,26 +291,66 @@ function Safe-Filecopy { } } else { - _WriteOut "WARNING: Unable to install: Could not find '$Filename' in '$SourceFolder'. " + _WriteOut "WARNING: Unable to install: Could not find '$Filename' in '$SourceFolder'. " } } -function GetArch($Architecture, $FallBackArch = $DefaultArchitecture) { - if(![String]::IsNullOrEmpty($Architecture)) { - $Architecture - } elseif($CompatArch) { - $CompatArch - } else { - $FallBackArch - } +$OSRuntimeDefaults = @{ + "win"="clr"; + "linux"="mono"; + "darwin"="mono"; } -function GetRuntime($Runtime) { - if(![String]::IsNullOrEmpty($Runtime)) { - $Runtime - } else { - $DefaultRuntime +$RuntimeBitnessDefaults = @{ + "clr"="x86"; + "coreclr"="x64"; +} + +function GetRuntimeInfo($Architecture, $Runtime, $OS, $Version) { + $runtimeInfo = @{ + "Architecture"="$Architecture"; + "Runtime"="$Runtime"; + "OS"="$OS"; + "Version"="$Version"; } + + if([String]::IsNullOrEmpty($runtimeInfo.OS)) { + if($runtimeInfo.Runtime -eq "mono"){ + #If OS is empty and you are asking for mono, i.e `dnvm install latest -os mono` then we don't know what OS to pick. It could be Linux or Darwin. + #we could just arbitrarily pick one but it will probably be wrong as often as not. + #If Mono can run on Windows then this error doesn't make sense anymore. + throw "Unable to determine an operating system for a $($runtimeInfo.Runtime) runtime. You must specify which OS to use with the OS parameter." + } + $runtimeInfo.OS = $DefaultOperatingSystem + } + + if($runtimeInfo.OS -eq "osx") { + $runtimeInfo.OS = "darwin" + } + + if([String]::IsNullOrEmpty($runtimeInfo.Runtime)) { + $runtimeInfo.Runtime = $OSRuntimeDefaults.Get_Item($runtimeInfo.OS) + } + + if([String]::IsNullOrEmpty($runtimeInfo.Architecture)) { + $runtimeInfo.Architecture = $RuntimeBitnessDefaults.Get_Item($RuntimeInfo.Runtime) + } + + $runtimeObject = New-Object PSObject -Property $runtimeInfo + + $runtimeObject | Add-Member -MemberType ScriptProperty -Name RuntimeId -Value { + if($this.Runtime -eq "mono") { + "$RuntimePackageName-$($this.Runtime)".ToLowerInvariant() + } else { + "$RuntimePackageName-$($this.Runtime)-$($this.OS)-$($this.Architecture)".ToLowerInvariant() + } + } + + $runtimeObject | Add-Member -MemberType ScriptProperty -Name RuntimeName -Value { + "$($this.RuntimeId).$($this.Version)" + } + + $runtimeObject } function Write-Usage { @@ -301,14 +384,20 @@ function Write-Feeds { } else { _WriteOut "" } - + _WriteOut + _WriteOut -NoNewline " To use override feeds, set " + _WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Executable "$DefaultFeedKey" + _WriteOut -NoNewline " and " + _WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Executable "$DefaultUnstableFeedKey" + _WriteOut -NoNewline " environment keys respectively" + _WriteOut } function Get-RuntimeAlias { if($Aliases -eq $null) { _WriteDebug "Scanning for aliases in $AliasesDir" if(Test-Path $AliasesDir) { - $Aliases = @(Get-ChildItem ($UserHome + "\alias\") | Select-Object @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }}) + $Aliases = @(Get-ChildItem ($UserHome + "\alias\") | Select-Object @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }}, @{label='Orphan';expression={-Not (Test-Path ($RuntimesDir + "\" + (Get-Content $_.FullName)))}}) } else { $Aliases = @() } @@ -322,62 +411,80 @@ function IsOnPath { $env:Path.Split(';') -icontains $dir } -function Get-RuntimeId( - [Parameter()][string]$Architecture, - [Parameter()][string]$Runtime) { - - $Architecture = GetArch $Architecture - $Runtime = GetRuntime $Runtime - - "$RuntimePackageName-$Runtime-win-$Architecture".ToLowerInvariant() -} - -function Get-RuntimeName( +function Get-RuntimeAliasOrRuntimeInfo( [Parameter(Mandatory=$true)][string]$Version, [Parameter()][string]$Architecture, - [Parameter()][string]$Runtime) { + [Parameter()][string]$Runtime, + [Parameter()][string]$OS) { $aliasPath = Join-Path $AliasesDir "$Version$AliasExtension" if(Test-Path $aliasPath) { $BaseName = Get-Content $aliasPath - $Architecture = GetArch $Architecture (Get-PackageArch $BaseName) - $Runtime = GetRuntime $Runtime (Get-PackageArch $BaseName) + if(!$Architecture) { + $Architecture = Get-PackageArch $BaseName + } + if(!$Runtime) { + $Runtime = Get-PackageRuntime $BaseName + } $Version = Get-PackageVersion $BaseName + $OS = Get-PackageOS $BaseName } - - "$(Get-RuntimeId $Architecture $Runtime).$Version" + + GetRuntimeInfo $Architecture $Runtime $OS $Version } filter List-Parts { - param($aliases) + param($aliases, $items) - $binDir = Join-Path $_.FullName "bin" - if (!(Test-Path $binDir)) { - return + $location = "" + + $binDir = Join-Path $_.FullName "bin" + if ((Test-Path $binDir)) { + $location = $_.Parent.FullName } - $active = IsOnPath $binDir - + $active = IsOnPath $binDir + $fullAlias="" $delim="" foreach($alias in $aliases) { if($_.Name.Split('\', 2) -contains $alias.Name) { - $fullAlias += $delim + $alias.Alias + $fullAlias += $delim + $alias.Alias + (&{if($alias.Orphan){" (missing)"}}) $delim = ", " } } $parts1 = $_.Name.Split('.', 2) $parts2 = $parts1[0].Split('-', 4) + + if($parts1[0] -eq "$RuntimePackageName-mono") { + $parts2 += "linux/osx" + $parts2 += "x86/x64" + } + + $aliasUsed = "" + if($items) { + $aliasUsed = $items | ForEach-Object { + if($_.Architecture -eq $parts2[3] -and $_.Runtime -eq $parts2[1] -and $_.OperatingSystem -eq $parts2[2] -and $_.Version -eq $parts1[1]) { + return $true; + } + return $false; + } + } + + if($aliasUsed -eq $true) { + $fullAlias = "" + } + return New-Object PSObject -Property @{ Active = $active Version = $parts1[1] Runtime = $parts2[1] OperatingSystem = $parts2[2] Architecture = $parts2[3] - Location = $_.Parent.FullName + Location = $location Alias = $fullAlias } } @@ -403,23 +510,25 @@ function Write-Alias { [Parameter(Mandatory=$true)][string]$Name, [Parameter(Mandatory=$true)][string]$Version, [Parameter(Mandatory=$false)][string]$Architecture, - [Parameter(Mandatory=$false)][string]$Runtime) + [Parameter(Mandatory=$false)][string]$Runtime, + [Parameter(Mandatory=$false)][string]$OS) # If the first character is non-numeric, it's a full runtime name if(![Char]::IsDigit($Version[0])) { - $runtimeFullName = $Version + $runtimeInfo = GetRuntimeInfo $(Get-PackageArch $Version) $(Get-PackageRuntime $Version) $(Get-PackageOS $Version) $(Get-PackageVersion $Version) } else { - $runtimeFullName = Get-RuntimeName $Version $Architecture $Runtime + $runtimeInfo = GetRuntimeInfo $Architecture $Runtime $OS $Version } + $aliasFilePath = Join-Path $AliasesDir "$Name.txt" $action = if (Test-Path $aliasFilePath) { "Updating" } else { "Setting" } - + if(!(Test-Path $AliasesDir)) { _WriteDebug "Creating alias directory: $AliasesDir" New-Item -Type Directory $AliasesDir | Out-Null } - _WriteOut "$action alias '$Name' to '$runtimeFullName'" - $runtimeFullName | Out-File $aliasFilePath ascii + _WriteOut "$action alias '$Name' to '$($runtimeInfo.RuntimeName)'" + $runtimeInfo.RuntimeName | Out-File $aliasFilePath ascii } function Delete-Alias { @@ -458,36 +567,54 @@ param( } } +function Find-Package { + param( + $runtimeInfo, + [string]$Feed, + [string]$Proxy + ) + $url = "$Feed/Packages()?`$filter=Id eq '$($runtimeInfo.RuntimeId)' and Version eq '$($runtimeInfo.Version)'" + Invoke-NuGetWebRequest $runtimeInfo.RuntimeId $url $Proxy +} + function Find-Latest { param( - [string]$runtime = "", - [string]$architecture = "", + $runtimeInfo, [Parameter(Mandatory=$true)] [string]$Feed, [string]$Proxy ) _WriteOut "Determining latest version" - - $RuntimeId = Get-RuntimeId -Architecture:"$architecture" -Runtime:"$runtime" + $RuntimeId = $runtimeInfo.RuntimeId + _WriteDebug "Latest RuntimeId: $RuntimeId" $url = "$Feed/GetUpdates()?packageIds=%27$RuntimeId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false" + Invoke-NuGetWebRequest $RuntimeId $url $Proxy +} + +function Invoke-NuGetWebRequest { + param ( + [string]$RuntimeId, + [string]$Url, + [string]$Proxy + ) # NOTE: DO NOT use Invoke-WebRequest. It requires PowerShell 4.0! $wc = New-Object System.Net.WebClient Apply-Proxy $wc -Proxy:$Proxy - _WriteDebug "Downloading $url ..." + _WriteDebug "Downloading $Url ..." try { - [xml]$xml = $wc.DownloadString($url) + [xml]$xml = $wc.DownloadString($Url) } catch { $Script:ExitCode = $ExitCodes.NoRuntimesOnFeed throw "Unable to find any runtime packages on the feed!" } $version = Select-Xml "//d:Version" -Namespace @{d='http://schemas.microsoft.com/ado/2007/08/dataservices'} $xml - if($version) { - _WriteDebug "Found latest version: $version" - $version + $downloadUrl = (Select-Xml "//d:content/@src" -Namespace @{d='http://www.w3.org/2005/Atom'} $xml).Node.value + _WriteDebug "Found $version at $downloadUrl" + @{ Version = $version; DownloadUrl = $downloadUrl } } else { throw "There are no runtimes matching the name $RuntimeId on feed $feed." } @@ -514,22 +641,29 @@ function Get-PackageArch() { return $runtimeFullName -replace "$RuntimePackageName-[^-]*-[^-]*-([^.]*).*", '$1' } -function Download-Package( - [string]$Version, - [string]$Architecture, - [string]$Runtime, - [string]$DestinationFile, - [Parameter(Mandatory=$true)] - [string]$Feed, - [string]$Proxy) { +function Get-PackageOS() { + param( + [string] $runtimeFullName + ) + $runtimeFullName -replace "$RuntimePackageName-[^-]*-([^-]*)-[^.]*.*", '$1' +} - $url = "$Feed/package/" + (Get-RuntimeId $Architecture $Runtime) + "/" + $Version - - _WriteOut "Downloading $runtimeFullName from $feed" +function Download-Package() { + param( + $runtimeInfo, + [Parameter(Mandatory=$true)] + [string]$DownloadUrl, + [string]$DestinationFile, + [Parameter(Mandatory=$true)] + [string]$Feed, + [string]$Proxy + ) + + _WriteOut "Downloading $($runtimeInfo.RuntimeName) from $feed" $wc = New-Object System.Net.WebClient try { - Apply-Proxy $wc -Proxy:$Proxy - _WriteDebug "Downloading $url ..." + Apply-Proxy $wc -Proxy:$Proxy + _WriteDebug "Downloading $DownloadUrl ..." Register-ObjectEvent $wc DownloadProgressChanged -SourceIdentifier WebClient.ProgressChanged -action { $Global:downloadData = $eventArgs @@ -540,14 +674,14 @@ function Download-Package( $Global:downloadCompleted = $true } | Out-Null - $wc.DownloadFileAsync($url, $DestinationFile) + $wc.DownloadFileAsync($DownloadUrl, $DestinationFile) while(-not $Global:downloadCompleted){ $percent = $Global:downloadData.ProgressPercentage $totalBytes = $Global:downloadData.TotalBytesToReceive $receivedBytes = $Global:downloadData.BytesReceived If ($percent -ne $null) { - Write-Progress -Activity ("Downloading $RuntimeShortFriendlyName from $url") ` + Write-Progress -Activity ("Downloading $RuntimeShortFriendlyName from $DownloadUrl") ` -Status ("Downloaded $($Global:downloadData.BytesReceived) of $($Global:downloadData.TotalBytesToReceive) bytes") ` -PercentComplete $percent -Id 2 -ParentId 1 } @@ -561,7 +695,7 @@ function Download-Package( } } - Write-Progress -Status "Done" -Activity ("Downloading $RuntimeShortFriendlyName from $url") -Id 2 -ParentId 1 -Completed + Write-Progress -Status "Done" -Activity ("Downloading $RuntimeShortFriendlyName from $DownloadUrl") -Id 2 -ParentId 1 -Completed } finally { Remove-Variable downloadData -Scope "Global" @@ -594,7 +728,7 @@ function Unpack-Package([string]$DownloadFile, [string]$UnpackFolder) { } } else { [System.IO.Compression.ZipFile]::ExtractToDirectory($DownloadFile, $UnpackFolder) - + # Clean up the package file itself. Remove-Item $DownloadFile -Force } @@ -615,7 +749,7 @@ function Get-RuntimePath($runtimeFullName) { foreach($RuntimeHome in $RuntimeHomes) { $runtimeBin = "$RuntimeHome\runtimes\$runtimeFullName\bin" _WriteDebug " Candidate $runtimeBin" - if (Test-Path "$runtimeBin") { + if (Test-Path $runtimeBin) { _WriteDebug " Found in $runtimeBin" return $runtimeBin } @@ -630,7 +764,7 @@ function Change-Path() { [string[]] $removePaths ) _WriteDebug "Updating value to prepend '$prependPath' and remove '$removePaths'" - + $newPath = $prependPath foreach($portion in $existingPaths.Split(';')) { if(![string]::IsNullOrEmpty($portion)) { @@ -722,14 +856,25 @@ function Is-Elevated() { #> function dnvm-update-self { param( - [Parameter(Mandatory=$false)] + [Parameter(Mandatory=$false)] [string]$Proxy) _WriteOut "Updating $CommandName from $DNVMUpgradeUrl" $wc = New-Object System.Net.WebClient Apply-Proxy $wc -Proxy:$Proxy + $dnvmFile = Join-Path $PSScriptRoot "dnvm.ps1" - $wc.DownloadFile($DNVMUpgradeUrl, $dnvmFile) + $tempDnvmFile = Join-Path $PSScriptRoot "temp" + $backupFilePath = Join-Path $PSSCriptRoot "dnvm.ps1.bak" + + $wc.DownloadFile($DNVMUpgradeUrl, $tempDnvmFile) + + if(Test-Path $backupFilePath) { + Remove-Item $backupFilePath -Force + } + + Rename-Item $dnvmFile $backupFilePath + Rename-Item $tempDnvmFile $dnvmFile } <# @@ -776,7 +921,7 @@ function dnvm-help { } _WriteOut -NoNewLine " " - + if($_.required -ne "true") { _WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Optional "[" } @@ -786,7 +931,7 @@ function dnvm-help { } if($_.parameterValue) { if($_.position -eq "Named") { - _WriteOut -NoNewLine " " + _WriteOut -NoNewLine " " } _WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Argument "<$($_.name)>" } @@ -808,9 +953,9 @@ function dnvm-help { if($cmdParam.Aliases.Length -gt 0) { $name = $cmdParam.Aliases | Sort-Object | Select-Object -First 1 } - + _WriteOut -NoNewLine " " - + if($_.position -eq "Named") { _WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Switch "-$name".PadRight($OptionPadding) } else { @@ -823,7 +968,7 @@ function dnvm-help { if($help.description) { _WriteOut _WriteOut -ForegroundColor $ColorScheme.Help_Header "remarks:" - $help.description.Text.Split(@("`r", "`n"), "RemoveEmptyEntries") | + $help.description.Text.Split(@("`r", "`n"), "RemoveEmptyEntries") | ForEach-Object { _WriteOut " $_" } } @@ -836,9 +981,9 @@ function dnvm-help { Write-Feeds _WriteOut _WriteOut -ForegroundColor $ColorScheme.Help_Header "commands: " - Get-Command "$CommandPrefix*" | + Get-Command "$CommandPrefix*" | ForEach-Object { - if($Host.Version.MajorVersion -lt 3) { + if($Host.Version.Major -lt 3) { $h = Get-Help $_.Name } else { $h = Get-Help $_.Name -ShowWindow:$false @@ -853,31 +998,73 @@ function dnvm-help { } } +filter ColorActive { + param([string] $color) + $lines = $_.Split("`n") + foreach($line in $lines) { + if($line.Contains("*")){ + _WriteOut -ForegroundColor $ColorScheme.ActiveRuntime $line + } else { + _WriteOut $line + } + } +} + +<# +.SYNOPSIS + Displays the DNVM version. +#> +function dnvm-version { + _WriteOut "$FullVersion" +} + <# .SYNOPSIS Lists available runtimes +.PARAMETER Detailed + Display more detailed information on each runtime .PARAMETER PassThru Set this switch to return unformatted powershell objects for use in scripting #> function dnvm-list { param( - [Parameter(Mandatory=$false)][switch]$PassThru) + [Parameter(Mandatory=$false)][switch]$PassThru, + [Parameter(Mandatory=$false)][switch]$Detailed) $aliases = Get-RuntimeAlias + if(-not $PassThru) { + Check-Runtimes + } + $items = @() $RuntimeHomes | ForEach-Object { _WriteDebug "Scanning $_ for runtimes..." if (Test-Path "$_\runtimes") { - $items += Get-ChildItem "$_\runtimes\$RuntimePackageName-*" | List-Parts $aliases + $items += Get-ChildItem "$_\runtimes\$RuntimePackageName-*" | List-Parts $aliases $items } } + $aliases | Where-Object {$_.Orphan} | ForEach-Object { + $items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases + } + if($PassThru) { $items } else { - $items | - Sort-Object Version, Runtime, Architecture, Alias | - Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "Location", "Alias" + if($items) { + #TODO: Probably a better way to do this. + if($Detailed) { + $items | + Sort-Object Version, Runtime, Architecture, OperatingSystem, Alias | + Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "OperatingSystem", "Alias", "Location" | Out-String| ColorActive + } else { + $items | + Sort-Object Version, Runtime, Architecture, OperatingSystem, Alias | + Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "OperatingSystem", "Alias" | Out-String | ColorActive + } + } else { + _WriteOut "No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime." + } } } @@ -892,6 +1079,8 @@ function dnvm-list { The architecture of the runtime to assign to this alias .PARAMETER Runtime The flavor of the runtime to assign to this alias +.PARAMETER OS + The operating system that the runtime targets .PARAMETER Delete Set this switch to delete the alias with the specified name .DESCRIPTION @@ -901,14 +1090,20 @@ function dnvm-list { (defaults to 'x86') and (defaults to 'clr'). Finally, if the '-d' switch is provided, the alias is deleted, if it exists. + + NOTE: You cannot create an alias for a non-windows runtime. The intended use case for + an alias to help make it easier to switch the runtime, and you cannot use a non-windows + runtime on a windows machine. #> function dnvm-alias { param( [Alias("d")] [switch]$Delete, + [Parameter(Position=0)] [string]$Name, + [Parameter(Position=1)] [string]$Version, [Alias("arch")] @@ -916,11 +1111,23 @@ function dnvm-alias { [string]$Architecture = "", [Alias("r")] - [ValidateSet("", "clr", "coreclr")] - [string]$Runtime = "") + [ValidateSet("", "clr","coreclr", "mono")] + [Parameter(ParameterSetName="Write")] + [string]$Runtime = "", + + [ValidateSet("win", "osx", "darwin", "linux")] + [Parameter(Mandatory=$false,ParameterSetName="Write")] + [string]$OS = "") + + if($Name -like "help" -or $Name -like "/?") { + #It is unlikely that the user is trying to read an alias called help, so lets just help them out by displaying help text. + #If people need an alias called help or one that contains a `?` then we can change this to a prompt. + dnvm help alias + return + } if($Version) { - Write-Alias $Name $Version -Architecture $Architecture -Runtime $Runtime + Write-Alias $Name $Version -Architecture $Architecture -Runtime $Runtime -OS:$OS } elseif ($Delete) { Delete-Alias $Name } else { @@ -950,6 +1157,8 @@ function dnvm-unalias { The processor architecture of the runtime to install (default: x86) .PARAMETER Runtime The runtime flavor to install (default: clr) +.PARAMETER OS + The operating system that the runtime targets (default: win) .PARAMETER Force Overwrite an existing runtime if it already exists .PARAMETER Proxy @@ -959,7 +1168,9 @@ function dnvm-unalias { .PARAMETER Ngen For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch. .PARAMETER Unstable - Upgrade from our unstable dev feed. This will give you the latest development version of the runtime. + Upgrade from the unstable dev feed. This will give you the latest development version of the runtime. +.PARAMETER Global + Installs to configured global dnx file location (default: C:\ProgramData) #> function dnvm-upgrade { param( @@ -977,6 +1188,10 @@ function dnvm-upgrade { [Parameter(Mandatory=$false)] [string]$Runtime = "", + [ValidateSet("", "win", "osx", "darwin", "linux")] + [Parameter(Mandatory=$false)] + [string]$OS = "", + [Alias("f")] [Parameter(Mandatory=$false)] [switch]$Force, @@ -991,9 +1206,20 @@ function dnvm-upgrade { [switch]$Ngen, [Parameter(Mandatory=$false)] - [switch]$Unstable) + [switch]$Unstable, - dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Unstable:$Unstable -Persistent:$true + [Parameter(Mandatory=$false)] + [switch]$Global) + + if($OS -ne "win" -and ![String]::IsNullOrEmpty($OS)) { + #We could remove OS as an option from upgrade, but I want to take this opporunty to educate users about the difference between install and upgrade + #It's possible we should just do install here instead. + _WriteOut -ForegroundColor $ColorScheme.Error "You cannot upgrade to a non-windows runtime. Upgrade will download the latest version of the $RuntimeShortFriendlyName and also set it as your machines default. You cannot set the default $RuntimeShortFriendlyName to a non-windows version because you cannot use it to run an application. If you want to install a non-windows $RuntimeShortFriendlyName to package with your application then use 'dnvm install latest -OS:$OS' instead. Install will download the package but not set it as your default." + $Script:ExitCode = $ExitCodes.OtherError + return + } + + dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Unstable:$Unstable -Persistent:$true -Global:$Global } <# @@ -1007,6 +1233,8 @@ function dnvm-upgrade { The processor architecture of the runtime to install (default: x86) .PARAMETER Runtime The runtime flavor to install (default: clr) +.PARAMETER OS + The operating system that the runtime targets (default: win) .PARAMETER Alias Set alias to the installed runtime .PARAMETER Force @@ -1020,7 +1248,9 @@ function dnvm-upgrade { .PARAMETER Persistent Make the installed runtime useable across all processes run by the current user .PARAMETER Unstable - Upgrade from our unstable dev feed. This will give you the latest development version of the runtime. + Upgrade from the unstable dev feed. This will give you the latest development version of the runtime. +.PARAMETER Global + Installs to configured global dnx file location (default: C:\ProgramData) .DESCRIPTION A proxy can also be specified by using the 'http_proxy' environment variable #> @@ -1035,10 +1265,14 @@ function dnvm-install { [string]$Architecture = "", [Alias("r")] - [ValidateSet("", "clr", "coreclr")] + [ValidateSet("", "clr","coreclr","mono")] [Parameter(Mandatory=$false)] [string]$Runtime = "", + [ValidateSet("", "win", "osx", "darwin", "linux")] + [Parameter(Mandatory=$false)] + [string]$OS = "", + [Alias("a")] [Parameter(Mandatory=$false)] [string]$Alias, @@ -1060,7 +1294,10 @@ function dnvm-install { [switch]$Persistent, [Parameter(Mandatory=$false)] - [switch]$Unstable) + [switch]$Unstable, + + [Parameter(Mandatory=$false)] + [switch]$Global) $selectedFeed = "" @@ -1069,16 +1306,16 @@ function dnvm-install { if(!$selectedFeed) { $selectedFeed = $DefaultUnstableFeed } else { - _WriteOut -ForegroundColor $ColorScheme.Warning "Default unstable feed ($DefaultUnstableFeed) is being overridden by the value of the DNX_UNSTABLE_FEED environment variable ($ActiveUnstableFeed)" + _WriteOut -ForegroundColor $ColorScheme.Warning "Default unstable feed ($DefaultUnstableFeed) is being overridden by the value of the $DefaultUnstableFeedKey environment variable ($ActiveUnstableFeed)" } } else { $selectedFeed = $ActiveFeed if(!$selectedFeed) { $selectedFeed = $DefaultFeed } else { - _WriteOut -ForegroundColor $ColorScheme.Warning "Default stable feed ($DefaultFeed) is being overridden by the value of the DNX_FEED environment variable ($ActiveFeed)" - } - } + _WriteOut -ForegroundColor $ColorScheme.Warning "Default stable feed ($DefaultFeed) is being overridden by the value of the $DefaultFeedKey environment variable ($ActiveFeed)" + } + } if(!$VersionNuPkgOrAlias) { _WriteOut "A version, nupkg path, or the string 'latest' must be provided." @@ -1087,11 +1324,6 @@ function dnvm-install { return } - if ($VersionNuPkgOrAlias -eq "latest") { - Write-Progress -Status "Determining Latest Runtime" -Activity "Installing runtime" -Id 1 - $VersionNuPkgOrAlias = Find-Latest $Runtime $Architecture -Feed:$selectedFeed - } - $IsNuPkg = $VersionNuPkgOrAlias.EndsWith(".nupkg") if ($IsNuPkg) { @@ -1102,18 +1334,68 @@ function dnvm-install { $runtimeFullName = [System.IO.Path]::GetFileNameWithoutExtension($VersionNuPkgOrAlias) $Architecture = Get-PackageArch $runtimeFullName $Runtime = Get-PackageRuntime $runtimeFullName + $OS = Get-PackageOS $runtimeFullName + $Version = Get-PackageVersion $runtimeFullName } else { - $runtimeFullName = Get-RuntimeName $VersionNuPkgOrAlias -Architecture:$Architecture -Runtime:$Runtime + $aliasPath = Join-Path $AliasesDir "$VersionNuPkgOrAlias$AliasExtension" + if(Test-Path $aliasPath) { + $BaseName = Get-Content $aliasPath + #Check empty checks let us override a given alias property when installing the same again. e.g. `dnvm install default -x64` + if([String]::IsNullOrEmpty($Architecture)) { + $Architecture = Get-PackageArch $BaseName + } + + if([String]::IsNullOrEmpty($Runtime)) { + $Runtime = Get-PackageRuntime $BaseName + } + + if([String]::IsNullOrEmpty($Version)) { + $Version = Get-PackageVersion $BaseName + } + + if([String]::IsNullOrEmpty($OS)) { + $OS = Get-PackageOS $BaseName + } + } else { + $Version = $VersionNuPkgOrAlias + } } - $PackageVersion = Get-PackageVersion $runtimeFullName - - _WriteDebug "Preparing to install runtime '$runtimeFullName'" - _WriteDebug "Architecture: $Architecture" - _WriteDebug "Runtime: $Runtime" - _WriteDebug "Version: $PackageVersion" + $runtimeInfo = GetRuntimeInfo $Architecture $Runtime $OS $Version + + if (!$IsNuPkg) { + if ($VersionNuPkgOrAlias -eq "latest") { + Write-Progress -Activity "Installing runtime" -Status "Determining latest runtime" -Id 1 + $findPackageResult = Find-Latest -runtimeInfo:$runtimeInfo -Feed:$selectedFeed + } + else { + $findPackageResult = Find-Package -runtimeInfo:$runtimeInfo -Feed:$selectedFeed + } + $Version = $findPackageResult.Version + } + + #If the version is still empty at this point then VersionOrNupkgOrAlias is an actual version. + if([String]::IsNullOrEmpty($Version)) { + $Version = $VersionNuPkgOrAlias + } + + $runtimeInfo.Version = $Version + + _WriteDebug "Preparing to install runtime '$($runtimeInfo.RuntimeName)'" + _WriteDebug "Architecture: $($runtimeInfo.Architecture)" + _WriteDebug "Runtime: $($runtimeInfo.Runtime)" + _WriteDebug "Version: $($runtimeInfo.Version)" + _WriteDebug "OS: $($runtimeInfo.OS)" + + $installDir = $RuntimesDir + if (!$Global) { + $RuntimeFolder = Join-Path $RuntimesDir $($runtimeInfo.RuntimeName) + } + else { + $installDir = $GlobalRuntimesDir + $RuntimeFolder = Join-Path $GlobalRuntimesDir $($runtimeInfo.RuntimeName) + } - $RuntimeFolder = Join-Path $RuntimesDir $runtimeFullName _WriteDebug "Destination: $RuntimeFolder" if((Test-Path $RuntimeFolder) -and $Force) { @@ -1121,14 +1403,26 @@ function dnvm-install { Remove-Item $RuntimeFolder -Recurse -Force } - if(Test-Path $RuntimeFolder) { - _WriteOut "'$runtimeFullName' is already installed." - dnvm-use $PackageVersion -Architecture:$Architecture -Runtime:$Runtime -Persistent:$Persistent + $installed="" + if(Test-Path (Join-Path $RuntimesDir $($runtimeInfo.RuntimeName))) { + $installed = Join-Path $RuntimesDir $($runtimeInfo.RuntimeName) + } + if(Test-Path (Join-Path $GlobalRuntimesDir $($runtimeInfo.RuntimeName))) { + $installed = Join-Path $GlobalRuntimesDir $($runtimeInfo.RuntimeName) + } + if($installed -ne "") { + _WriteOut "'$($runtimeInfo.RuntimeName)' is already installed in $installed." + if($runtimeInfo.OS -eq "win") { + dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS + } } else { - $Architecture = GetArch $Architecture - $Runtime = GetRuntime $Runtime - $TempFolder = Join-Path $RuntimesDir "temp" + + $Architecture = $runtimeInfo.Architecture + $Runtime = $runtimeInfo.Runtime + $OS = $runtimeInfo.OS + + $TempFolder = Join-Path $installDir "temp" $UnpackFolder = Join-Path $TempFolder $runtimeFullName $DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg" @@ -1145,9 +1439,9 @@ function dnvm-install { } else { # Download the package Write-Progress -Activity "Installing runtime" -Status "Downloading runtime" -Id 1 - _WriteDebug "Downloading version $VersionNuPkgOrAlias to $DownloadFile" + _WriteDebug "Downloading version $($runtimeInfo.Version) to $DownloadFile" - Download-Package $PackageVersion $Architecture $Runtime $DownloadFile -Proxy:$Proxy -Feed:$selectedFeed + Download-Package -RuntimeInfo:$runtimeInfo -DownloadUrl:$findPackageResult.DownloadUrl -DestinationFile:$DownloadFile -Proxy:$Proxy -Feed:$selectedFeed } Write-Progress -Activity "Installing runtime" -Status "Unpacking runtime" -Id 1 @@ -1155,7 +1449,7 @@ function dnvm-install { if(Test-Path $RuntimeFolder) { # Ensure the runtime hasn't been installed in the time it took to download the package. - _WriteOut "'$runtimeFullName' is already installed." + _WriteOut "'$($runtimeInfo.RuntimeName)' is already installed." } else { _WriteOut "Installing to $RuntimeFolder" @@ -1170,33 +1464,35 @@ function dnvm-install { } } #If there is nothing left in the temp folder remove it. There could be other installs happening at the same time as this. - if(-Not(Test-Path $(Join-Path $TempFolder "*"))) { + if(Test-Path $(Join-Path $TempFolder "*")) { Remove-Item $TempFolder -Recurse } } - dnvm-use $PackageVersion -Architecture:$Architecture -Runtime:$Runtime -Persistent:$Persistent + if($runtimeInfo.OS -eq "win") { + dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS + } - if ($Runtime -eq "clr") { + if ($runtimeInfo.Runtime -eq "clr") { if (-not $NoNative) { if ((Is-Elevated) -or $Ngen) { - $runtimeBin = Get-RuntimePath $runtimeFullName + $runtimeBin = Get-RuntimePath $runtimeInfo.RuntimeName Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1 - Ngen-Library $runtimeBin $Architecture + Ngen-Library $runtimeBin $runtimeInfo.Architecture } else { _WriteOut "Native image generation (ngen) is skipped. Include -Ngen switch to turn on native image generation to improve application startup time." } } } - elseif ($Runtime -eq "coreclr") { - if ($NoNative) { + elseif ($runtimeInfo.Runtime -eq "coreclr") { + if ($NoNative -or $runtimeInfo.OS -ne "win") { _WriteOut "Skipping native image compilation." } else { - _WriteOut "Compiling native images for $runtimeFullName to improve startup performance..." + _WriteOut "Compiling native images for $($runtimeInfo.RuntimeName) to improve startup performance..." Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1 - + if(Get-Command $CrossGenCommand -ErrorAction SilentlyContinue) { $crossGenCommand = $CrossGenCommand } else { @@ -1213,13 +1509,17 @@ function dnvm-install { } } else { - _WriteOut "Unexpected platform: $Runtime. No optimization would be performed on the package installed." + _WriteOut "Unexpected platform: $($runtimeInfo.Runtime). No optimization would be performed on the package installed." } } if($Alias) { - _WriteDebug "Aliasing installed runtime to '$Alias'" - dnvm-alias $Alias $PackageVersion -Architecture:$Architecture -Runtime:$Runtime + if($runtimeInfo.OS -eq "win") { + _WriteDebug "Aliasing installed runtime to '$Alias'" + dnvm-alias $Alias $runtimeInfo.Version -Architecture:$RuntimeInfo.Architecture -Runtime:$RuntimeInfo.Runtime -OS:$RuntimeInfo.OS + } else { + _WriteOut "Unable to set an alias for a non-windows runtime. Installing non-windows runtimes on Windows are meant only for publishing, not running." + } } Write-Progress -Status "Done" -Activity "Install complete" -Id 1 -Complete @@ -1235,6 +1535,8 @@ function dnvm-install { The processor architecture of the runtime to place on the PATH (default: x86, or whatever the alias specifies in the case of use-ing an alias) .PARAMETER Runtime The runtime flavor of the runtime to place on the PATH (default: clr, or whatever the alias specifies in the case of use-ing an alias) +.PARAMETER OS + The operating system that the runtime targets (default: win) .PARAMETER Persistent Make the change persistent across all processes run by the current user #> @@ -1253,36 +1555,41 @@ function dnvm-use { [Parameter(Mandatory=$false)] [string]$Runtime = "", + [ValidateSet("", "win", "osx", "darwin", "linux")] + [Parameter(Mandatory=$false)] + [string]$OS = "", + [Alias("p")] [Parameter(Mandatory=$false)] [switch]$Persistent) if ($versionOrAlias -eq "none") { _WriteOut "Removing all runtimes from process PATH" - Set-Path (Change-Path $env:Path "" ($RuntimeDirs)) + Set-Path (Change-Path $env:Path "" $RuntimeDirs) if ($Persistent) { _WriteOut "Removing all runtimes from user PATH" $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) - $userPath = Change-Path $userPath "" ($RuntimeDirs) + $userPath = Change-Path $userPath "" $RuntimeDirs [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User) } return; } - $runtimeFullName = Get-RuntimeName $VersionOrAlias $Architecture $Runtime + $runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS + $runtimeFullName = $runtimeInfo.RuntimeName $runtimeBin = Get-RuntimePath $runtimeFullName if ($runtimeBin -eq $null) { throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?" } _WriteOut "Adding $runtimeBin to process PATH" - Set-Path (Change-Path $env:Path $runtimeBin ($RuntimeDirs)) + Set-Path (Change-Path $env:Path $runtimeBin $RuntimeDirs) if ($Persistent) { _WriteOut "Adding $runtimeBin to user PATH" $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) - $userPath = Change-Path $userPath $runtimeBin ($RuntimeDirs) + $userPath = Change-Path $userPath $runtimeBin $RuntimeDirs [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User) } } @@ -1313,10 +1620,11 @@ function dnvm-run { [Parameter(Mandatory=$false, Position=1, ValueFromRemainingArguments=$true)] [object[]]$DnxArguments) - $runtimeFullName = Get-RuntimeName $VersionOrAlias $Architecture $Runtime - $runtimeBin = Get-RuntimePath $runtimeFullName + $runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias -Runtime:$Runtime -Architecture:$Architecture + + $runtimeBin = Get-RuntimePath $runtimeInfo.RuntimeName if ($runtimeBin -eq $null) { - throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?" + throw "Cannot find $($runtimeInfo.Name), do you need to run '$CommandName install $versionOrAlias'?" } $dnxExe = Join-Path $runtimeBin "dnx.exe" if(!(Test-Path $dnxExe)) { @@ -1324,6 +1632,7 @@ function dnvm-run { } _WriteDebug "> $dnxExe $DnxArguments" & $dnxExe @DnxArguments + $Script:ExitCode = $LASTEXITCODE } <# @@ -1353,10 +1662,11 @@ function dnvm-exec { [Parameter(Mandatory=$false, Position=2, ValueFromRemainingArguments=$true)] [object[]]$Arguments) - $runtimeFullName = Get-RuntimeName $VersionOrAlias $Architecture $Runtime - $runtimeBin = Get-RuntimePath $runtimeFullName + $runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias -Runtime:$Runtime -Architecture:$Architecture + $runtimeBin = Get-RuntimePath $runtimeInfo.RuntimeName + if ($runtimeBin -eq $null) { - throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?" + throw "Cannot find $($runtimeInfo.RuntimeName), do you need to run '$CommandName install $versionOrAlias'?" } $oldPath = $env:PATH @@ -1364,6 +1674,7 @@ function dnvm-exec { $env:PATH = "$runtimeBin;$($env:PATH)" & $Command @Arguments } finally { + $Script:ExitCode = $LASTEXITCODE $env:PATH = $oldPath } } @@ -1378,7 +1689,7 @@ function dnvm-setup { param( [switch]$SkipUserEnvironmentInstall) - $DestinationHome = "$env:USERPROFILE\$DefaultUserDirectoryName" + $DestinationHome = [Environment]::ExpandEnvironmentVariables("$DefaultUserHome") # Install scripts $Destination = "$DestinationHome\bin" @@ -1394,7 +1705,7 @@ function dnvm-setup { # Also, clean old user home values if present # We'll be removing any existing homes, both $PathsToRemove = @( - "%USERPROFILE%\$DefaultUserDirectoryName", + "$DefaultUserHome", [Environment]::ExpandEnvironmentVariables($OldUserHome), $DestinationHome, $OldUserHome) @@ -1410,20 +1721,36 @@ function dnvm-setup { [Environment]::SetEnvironmentVariable("PATH", $userPath, "User") } - # Now the HomeEnvVar - _WriteOut "Adding $DestinationHome to Process $HomeEnvVar" - $processHome = "" - if(Test-Path "env:\$HomeEnvVar") { - $processHome = Get-Content "env:\$HomeEnvVar" - } - $processHome = Change-Path $processHome "%USERPROFILE%\$DefaultUserDirectoryName" $PathsToRemove - Set-Content "env:\$HomeEnvVar" $processHome + # Now clean up the HomeEnvVar if currently set; script installed to default location. + Clean-HomeEnv($SkipUserEnvironmentInstall) +} - if(!$SkipUserEnvironmentInstall) { - _WriteOut "Adding $DestinationHome to User $HomeEnvVar" - $userHomeVal = [Environment]::GetEnvironmentVariable($HomeEnvVar, "User") - $userHomeVal = Change-Path $userHomeVal "%USERPROFILE%\$DefaultUserDirectoryName" $PathsToRemove - [Environment]::SetEnvironmentVariable($HomeEnvVar, $userHomeVal, "User") +function Check-Runtimes(){ + $runtimesInstall = $false; + foreach($runtimeHomeDir in $RuntimeHomes) { + if (Test-Path "$runtimeHomeDir\runtimes") { + if(Test-Path "$runtimeHomeDir\runtimes\$RuntimePackageName-*"){ + $runtimesInstall = $true; + break; + } + } + } + + if (-not $runtimesInstall){ + $title = "Getting started" + $message = "It looks like you don't have any runtimes installed. Do you want us to install a $RuntimeShortFriendlyName to get you started?" + + $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Install the latest runtime for you" + + $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Do not install the latest runtime and continue" + + $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no) + + $result = $host.ui.PromptForChoice($title, $message, $options, 0) + + if($result -eq 0){ + dnvm-upgrade + } } } @@ -1467,7 +1794,7 @@ if($cmdargs -icontains "-amd64") { $cmdargs = @($cmdargs | Where-Object { @("-amd64", "-x86", "-x64") -notcontains $_ }) if(!$cmd) { - _WriteOut "You must specify a command!" + Check-Runtimes $cmd = "help" $Script:ExitCode = $ExitCodes.InvalidArguments } diff --git a/build/dnvm.sh b/build/dnvm.sh index 140cfb6c32..5927888c18 100644 --- a/build/dnvm.sh +++ b/build/dnvm.sh @@ -2,8 +2,8 @@ # Source this file from your .bash-profile or script to use # "Constants" -_DNVM_BUILDNUMBER="beta6-10394" -_DNVM_AUTHORS=".NET Foundation" +_DNVM_BUILDNUMBER="beta8-15518" +_DNVM_AUTHORS="Microsoft Open Technologies, Inc." _DNVM_RUNTIME_PACKAGE_NAME="dnx" _DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment" _DNVM_RUNTIME_SHORT_NAME="DNX" @@ -14,7 +14,6 @@ _DNVM_VERSION_MANAGER_NAME=".NET Version Manager" _DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetcidev/api/v2" _DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetcidev/api/v2" _DNVM_UPDATE_LOCATION="https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh" -_DNVM_HOME_VAR_NAME="DNX_HOME" if [ "$NO_COLOR" != "1" ]; then # ANSI Colors @@ -47,7 +46,19 @@ if [ -z "$DNX_USER_HOME" ]; then eval DNX_USER_HOME="~/$_DNVM_RUNTIME_FOLDER_NAME" fi +if [ -z "$DNX_GLOBAL_HOME" ]; then + eval DNX_GLOBAL_HOME="/usr/local/lib/dnx" +fi + +if [ -z "$DNX_HOME" ]; then + # Set to the user home value + eval DNX_HOME="$DNX_USER_HOME:$DNX_GLOBAL_HOME" +elif [[ $DNX_HOME != *"$DNX_GLOBAL_HOME"* ]]; then + eval DNX_HOME="$DNX_HOME:$DNX_GLOBAL_HOME" +fi + _DNVM_USER_PACKAGES="$DNX_USER_HOME/runtimes" +_DNVM_GLOBAL_PACKAGES="$DNX_GLOBAL_HOME/runtimes" _DNVM_ALIAS_DIR="$DNX_USER_HOME/alias" _DNVM_DNVM_DIR="$DNX_USER_HOME/dnvm" @@ -63,35 +74,86 @@ __dnvm_current_os() fi } +__dnvm_os_runtime_defaults() +{ + local os=$1 + + if [[ $os == "win" ]]; then + echo "clr" + elif [[ $os == "linux" ]]; then + echo "mono" + elif [[ $os == "darwin" ]]; then + echo "mono" + else + echo "unknown os" + fi +} + +__dnvm_runtime_bitness_defaults() +{ + local runtime=$1 + if [[ $runtime == "clr" ]]; then + echo "x86" + elif [[ $runtime == "coreclr" ]]; then + echo "x64" + else + echo "unknown runtime" + fi +} + +__dnvm_query_feed() { + local url=$1 + xml="$(curl $url 2>/dev/null)" + echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1 + version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')" + downloadUrl="$(echo $xml | sed 's/.*&2; return 1 fi - + if [[ $platform == "mono" ]]; then #dnx-mono local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform" else #dnx-coreclr-linux-x64 - local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform-$(__dnvm_current_os)-$arch" + local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform-$os-$arch" fi + local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$packageId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false" - xml="$(curl $url 2>/dev/null)" - echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1 - version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')" - echo $version + __dnvm_query_feed $url + return $? +} + +__dnvm_find_package() { + local platform=$1 + local arch=$2 + local os=$3 + local version=$4 + + if [[ $platform == "mono" ]]; then + #dnx-mono + local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform" + else + #dnx-coreclr-linux-x64 + local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform-$os-$arch" + fi + + local url="$DNX_ACTIVE_FEED/Packages()?\$filter=Id%20eq%27$packageId%27%20and%20Version%20eq%20%27$version%27" + __dnvm_query_feed $url + return $? } __dnvm_strip_path() { - echo "$1" | sed -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" + echo "$1" | sed -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" | sed -e "s#$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*##g" } __dnvm_prepend_path() { @@ -125,12 +187,26 @@ __dnvm_package_arch() { fi } +__dnvm_package_os() { + local runtimeFullName="$1" + if [[ "$runtimeFullName" =~ "mono" ]]; then + echo "linux/osx" + else + echo "$runtimeFullName" | sed "s/$_DNVM_RUNTIME_PACKAGE_NAME-[^-.]*-\([^.-]*\).*/\1/" + fi +} + __dnvm_update_self() { local dnvmFileLocation="$_DNVM_DNVM_DIR/dnvm.sh" if [ ! -e $dnvmFileLocation ]; then local formattedDnvmFileLocation=`(echo $dnvmFileLocation | sed s=$HOME=~=g)` local formattedDnvmHome=`(echo $_DNVM_DNVM_DIR | sed s=$HOME=~=g)` - printf "%b\n" "${Red}$formattedDnvmFileLocation doesn't exist. This command assumes you have installed dnvm in the usual location and are trying to update it. If you want to use update-self then dnvm.sh should be sourced from $formattedDnvmHome ${RCol}" + local bashSourceLocation=${BASH_SOURCE} + local scriptLocation=$bashSourceLocation + if [ -z "${bashSourceLocation}" ]; then + local scriptLocation=${(%):-%x} + fi + printf "%b\n" "${Red}$formattedDnvmFileLocation doesn't exist. This command assumes you have installed dnvm in the usual location and are trying to update it. If you want to use update-self then dnvm.sh should be sourced from $formattedDnvmHome. dnvm is currently sourced from $scriptLocation ${RCol}" return 1 fi printf "%b\n" "${Cya}Downloading dnvm.sh from $_DNVM_UPDATE_LOCATION ${RCol}" @@ -142,14 +218,32 @@ __dnvm_update_self() { source "$dnvmFileLocation" } +__dnvm_promptSudo() { + local acceptSudo="$1" + + local answer= + if [ "$acceptSudo" == "0" ]; then + echo "In order to install dnx globally, dnvm will have to temporarily run as root." + read -p "You may be prompted for your password via 'sudo' during this process. Is this Ok? (y/N) " answer + else + answer="y" + fi + if echo $answer | grep -iq "^y" ; then + return 1 + else + return 0 + fi +} + __dnvm_download() { local runtimeFullName="$1" - local runtimeFolder="$2" - local force="$3" + local downloadUrl="$2" + local runtimeFolder="$3" + local force="$4" + local acceptSudo="$5" local pkgName=$(__dnvm_package_name "$runtimeFullName") local pkgVersion=$(__dnvm_package_version "$runtimeFullName") - local url="$DNX_ACTIVE_FEED/package/$pkgName/$pkgVersion" local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg" if [ -n "$force" ]; then @@ -161,18 +255,26 @@ __dnvm_download() { printf "%b\n" "${Gre}$runtimeFullName already installed. ${RCol}" return 0 fi - + if ! __dnvm_has "curl"; then printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2; return 1 fi + local useSudo= mkdir -p "$runtimeFolder" > /dev/null 2>&1 - + if [ ! -d $runtimeFolder ]; then + if ! __dnvm_promptSudo $acceptSudo ; then + useSudo=sudo + sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1 + else + return 1 + fi + fi echo "Downloading $runtimeFullName from $DNX_ACTIVE_FEED" - echo "Download: $url" + echo "Download: $downloadUrl" - local httpResult=$(curl -L -D - "$url" -o "$runtimeFile" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") + local httpResult=$($useSudo curl -L -D - "$downloadUrl" -o "$runtimeFile" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") if [[ $httpResult == "404" ]]; then printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}" @@ -181,13 +283,14 @@ __dnvm_download() { fi [[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching $runtimeFullName from $DNX_ACTIVE_FEED ${RCol}" && return 1 - __dnvm_unpack $runtimeFile $runtimeFolder + __dnvm_unpack $runtimeFile $runtimeFolder $useSudo return $? } __dnvm_unpack() { local runtimeFile="$1" local runtimeFolder="$2" + local useSudo=$3 echo "Installing to $runtimeFolder" @@ -196,28 +299,32 @@ __dnvm_unpack() { return 1 fi - unzip $runtimeFile -d $runtimeFolder > /dev/null 2>&1 + $useSudo unzip $runtimeFile -d $runtimeFolder > /dev/null 2>&1 - [ -e "$runtimeFolder/[Content_Types].xml" ] && rm "$runtimeFolder/[Content_Types].xml" + [ -e "$runtimeFolder/[Content_Types].xml" ] && $useSudo rm "$runtimeFolder/[Content_Types].xml" - [ -e "$runtimeFolder/_rels/" ] && rm -rf "$runtimeFolder/_rels/" + [ -e "$runtimeFolder/_rels/" ] && $useSudo rm -rf "$runtimeFolder/_rels/" - [ -e "$runtimeFolder/package/" ] && rm -rf "$runtimeFolder/_package/" + [ -e "$runtimeFolder/package/" ] && $useSudo rm -rf "$runtimeFolder/_package/" - [ -e "$runtimeFile" ] && rm -f "$runtimeFile" - - #Set shell commands as executable - find "$runtimeFolder/bin/" -type f \ - -exec sh -c "head -c 20 {} | grep '/usr/bin/env bash\|/bin/bash' > /dev/null" \; -print | xargs chmod 775 + [ -e "$runtimeFile" ] && $useSudo rm -f "$runtimeFile" #Set dnx to be executable - chmod 775 "$runtimeFolder/bin/dnx" + if [[ -s "$runtimeFolder/bin/dnx" ]]; then + $useSudo chmod 775 "$runtimeFolder/bin/dnx" + fi + + #Set dnu to be executable + if [[ -s "$runtimeFolder/bin/dnu" ]]; then + $useSudo chmod 775 "$runtimeFolder/bin/dnu" + fi } __dnvm_requested_version_or_alias() { local versionOrAlias="$1" local runtime="$2" local arch="$3" + local os="$4" local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$versionOrAlias") # If the name specified is an existing package, just use it as is @@ -226,22 +333,30 @@ __dnvm_requested_version_or_alias() { else if [ -e "$_DNVM_ALIAS_DIR/$versionOrAlias.alias" ]; then local runtimeFullName=$(cat "$_DNVM_ALIAS_DIR/$versionOrAlias.alias") - echo "$runtimeFullName" - else - local pkgVersion=$versionOrAlias - - if [[ -z $runtime || "$runtime" == "mono" ]]; then - echo "$_DNVM_RUNTIME_PACKAGE_NAME-mono.$pkgVersion" - elif [[ "$runtime" == "coreclr" ]]; then - local pkgArchitecture="x64" - local pkgSystem=$(__dnvm_current_os) - - if [ "$arch" != "" ]; then - local pkgArchitecture="$arch" - fi - - echo "$_DNVM_RUNTIME_PACKAGE_NAME-coreclr-$pkgSystem-$pkgArchitecture.$pkgVersion" + if [[ ! -n "$runtime" && ! -n "$arch" ]]; then + echo "$runtimeFullName" + return fi + local pkgVersion=$(__dnvm_package_version "$runtimeFullName") + fi + + if [[ ! -n "$pkgVersion" ]]; then + local pkgVersion=$versionOrAlias + fi + local pkgArchitecture="x64" + local pkgSystem=$os + + if [[ -z $runtime || "$runtime" == "mono" ]]; then + echo "$_DNVM_RUNTIME_PACKAGE_NAME-mono.$pkgVersion" + else + if [ "$arch" != "" ]; then + local pkgArchitecture="$arch" + fi + if [ "$os" == "" ]; then + local pkgSystem=$(__dnvm_current_os) + fi + + echo "$_DNVM_RUNTIME_PACKAGE_NAME-$runtime-$pkgSystem-$pkgArchitecture.$pkgVersion" fi fi } @@ -249,7 +364,11 @@ __dnvm_requested_version_or_alias() { # This will be more relevant if we support global installs __dnvm_locate_runtime_bin_from_full_name() { local runtimeFullName=$1 - [ -e "$_DNVM_USER_PACKAGES/$runtimeFullName/bin" ] && echo "$_DNVM_USER_PACKAGES/$runtimeFullName/bin" && return + for v in `echo $DNX_HOME | tr ":" "\n"`; do + if [ -e "$v/runtimes/$runtimeFullName/bin" ]; then + echo "$v/runtimes/$runtimeFullName/bin" && return + fi + done } __echo_art() { @@ -273,41 +392,50 @@ __dnvm_description() { printf "%b\n" "${Yel}Current feed settings:${RCol}" printf "%b\n" "${Cya}Default Stable:${Yel} $_DNVM_DEFAULT_FEED" printf "%b\n" "${Cya}Default Unstable:${Yel} $_DNVM_DEFAULT_UNSTABLE_FEED" - + local dnxStableOverride="" [[ -n $DNX_FEED ]] && dnxStableOverride="$DNX_FEED" printf "%b\n" "${Cya}Current Stable Override:${Yel} $dnxStableOverride" - + local dnxUnstableOverride="" [[ -n $DNX_UNSTABLE_FEED ]] && dnxUnstableOverride="$DNX_UNSTABLE_FEED" - + printf "%b\n" "${Cya}Current Unstable Override:${Yel} $dnxUnstableOverride${RCol}" echo "" } +__dnvm_version() { + echo "1.0.0-$_DNVM_BUILDNUMBER" +} + __dnvm_help() { __dnvm_description printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME [options] ${RCol}" echo "" - printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME upgrade [-f|-force] [-u|-unstable] ${RCol}" + printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME upgrade [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}" echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed" echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line" echo " set installed version as default" echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed" - echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable unstable feed" + echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed" echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)" + echo " -g|global Installs the latest $_DNVM_RUNTIME_SHORT_NAME in the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)" + echo " -y Assume Yes to all queries and do not prompt" echo "" - printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install |||latest [-a|-alias ] [-p|-persistent] [-f|-force] [-u|-unstable] ${RCol}" + printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install |||latest [-r ] [-OS ] [-a|-alias ] [-p|-persistent] [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}" echo " | install requested $_DNVM_RUNTIME_SHORT_NAME from feed" echo " install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem" echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed" + echo " -OS the operating system that the runtime targets (default:$(__dnvm_current_os)" echo " -a|-alias set alias for requested $_DNVM_RUNTIME_SHORT_NAME on install" echo " -p|-persistent set installed version as default" echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed" - echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable unstable feed" + echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed" echo " -r|runtime The runtime flavor to install [mono or coreclr] (default: mono)" + echo " -g|global Installs to the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)" + echo " -y Assume Yes to all queries and do not prompt" echo "" echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line" echo "" @@ -332,7 +460,9 @@ __dnvm_help() { echo " runs the specified command in the context of the specified version of the runtime without affecting the current PATH" echo " example: $_DNVM_COMMAND_NAME exec 1.0.0-beta4 $_DNVM_PACKAGE_MANAGER_NAME build" echo "" - printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME list ${RCol}" + printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME list [-detailed]${RCol}" + echo " -detailed display more detailed information on each runtime" + echo "" echo " list $_DNVM_RUNTIME_SHORT_NAME versions installed " echo "" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias ${RCol}" @@ -351,6 +481,9 @@ __dnvm_help() { printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [help|-h|-help|--help] ${RCol}" echo " displays this help text." echo "" + printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [version|-v|-version|--version] ${RCol}" + echo " print the dnvm version." + echo "" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME update-self ${RCol}" echo " updates dnvm itself." } @@ -370,6 +503,10 @@ dnvm() __dnvm_help ;; + "version"|"-v"|"-version"|"--version" ) + __dnvm_version + ;; + "update-self" ) __dnvm_update_self ;; @@ -387,8 +524,11 @@ dnvm() local alias= local force= local unstable= - local runtime="mono" - local arch="x64" + local os= + local runtime= + local arch= + local global=0 + local acceptSudo=0 while [ $# -ne 0 ] do if [[ $1 == "-p" || $1 == "-persistent" ]]; then @@ -403,20 +543,21 @@ dnvm() elif [[ $1 == "-r" || $1 == "-runtime" ]]; then local runtime=$2 shift + elif [[ $1 == "-OS" ]]; then + local os=$2 + shift + elif [[ $1 == "-y" ]]; then + local acceptSudo=1 elif [[ $1 == "-arch" ]]; then local arch=$2 shift - + if [[ $arch != "x86" && $arch != "x64" ]]; then - printf "%b\n" "${Red}Architecture must be x86 or x64.${RCol}" + printf "%b\n" "${Red}Architecture must be x86 or x64.${RCol}" return 1 fi - - if [[ $arch == "x86" && $runtime == "coreclr" ]]; then - printf "%b\n" "${Red}Core CLR doesn't currently have a 32 bit build. You must use x64.${RCol}" - return 1 - fi - + elif [[ $1 == "-g" || $1 == "-global" ]]; then + local global=1 elif [[ -n $1 ]]; then [[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1 local versionOrAlias=$1 @@ -424,6 +565,11 @@ dnvm() shift done + if [[ $arch == "x86" && $runtime == "coreclr" && $os != "win" ]]; then + printf "%b\n" "${Red}Core CLR doesn't currently have a 32 bit build. You must use x64.${RCol}" + return 1 + fi + if [ -z $unstable ]; then DNX_ACTIVE_FEED="$DNX_FEED" if [ -z "$DNX_ACTIVE_FEED" ]; then @@ -440,21 +586,66 @@ dnvm() fi fi + if [[ -z $os ]]; then + os=$(__dnvm_current_os) + fi + if [[ $os == "osx" ]]; then + os="darwin" + fi + + if [[ -z $runtime ]]; then + runtime=$(__dnvm_os_runtime_defaults "$os") + fi + + if [[ -z $arch ]]; then + arch=$(__dnvm_runtime_bitness_defaults "$runtime") + fi + if [[ $runtime == "mono" ]] && ! __dnvm_has "mono"; then printf "%b\n" "${Yel}It appears you don't have Mono available. Remember to get Mono before trying to run $DNVM_RUNTIME_SHORT_NAME application. ${RCol}" >&2; fi - if [[ "$versionOrAlias" == "latest" ]]; then - echo "Determining latest version" - versionOrAlias=$(__dnvm_find_latest "$runtime" "$arch") - [[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1 - printf "%b\n" "Latest version is ${Cya}$versionOrAlias ${RCol}" + local runtimeDir=$_DNVM_USER_PACKAGES + if [ $global == 1 ]; then + runtimeDir=$_DNVM_GLOBAL_PACKAGES fi - if [[ "$versionOrAlias" == *.nupkg ]]; then + if [[ "$versionOrAlias" != *.nupkg ]]; then + if [[ "$versionOrAlias" == "latest" ]]; then + echo "Determining latest version" + read versionOrAlias downloadUrl < <(__dnvm_find_latest "$runtime" "$arch" "$os") + [[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1 + printf "%b\n" "Latest version is ${Cya}$versionOrAlias ${RCol}" + else + local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os") + local runtimeVersion=$(__dnvm_package_version "$runtimeFullName") + + read versionOrAlias downloadUrl < <(__dnvm_find_package "$runtime" "$arch" "$os" "$runtimeVersion") + [[ $? == 1 ]] && echo "Error: Could not find version $runtimeVersion in feed $DNX_ACTIVE_FEED" && return 1 + fi + local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os") + local runtimeFolder="$runtimeDir/$runtimeFullName" + + local exist=0 + for folder in `echo $DNX_HOME | tr ":" "\n"`; do + if [ -e "$folder/runtimes/$runtimeFullName" ]; then + echo "$runtimeFullName already installed in $folder" + exist=1 + fi + done + + if [[ $exist != 1 ]]; then + __dnvm_download "$runtimeFullName" "$downloadUrl" "$runtimeFolder" "$force" "$acceptSudo" + fi + [[ $? == 1 ]] && return 1 + if [[ "$os" == $(__dnvm_current_os) ]]; then + $_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch" + [[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$versionOrAlias" + fi + else local runtimeFullName=$(basename $versionOrAlias | sed "s/\(.*\)\.nupkg/\1/") local runtimeVersion=$(__dnvm_package_version "$runtimeFullName") - local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName" + local runtimeFolder="$runtimeDir/$runtimeFullName" local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg" local runtimeClr=$(__dnvm_package_runtime "$runtimeFullName") @@ -466,20 +657,22 @@ dnvm() if [ -e "$runtimeFolder" ]; then echo "$runtimeFullName already installed" else + local useSudo= mkdir -p "$runtimeFolder" > /dev/null 2>&1 + if [ ! -d $runtimeFolder ]; then + if ! __dnvm_promptSudo $acceptSudo ; then + useSudo=sudo + sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1 + else + return 1 + fi + fi cp -a "$versionOrAlias" "$runtimeFile" - __dnvm_unpack "$runtimeFile" "$runtimeFolder" + __dnvm_unpack "$runtimeFile" "$runtimeFolder" $useSudo [[ $? == 1 ]] && return 1 fi $_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr" [[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$runtimeVersion" - else - local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch") - local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName" - __dnvm_download "$runtimeFullName" "$runtimeFolder" "$force" - [[ $? == 1 ]] && return 1 - $_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch" - [[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$versionOrAlias" fi ;; @@ -491,9 +684,9 @@ dnvm() local arch= local runtime= + local versionOrAlias= shift if [ $cmd == "use" ]; then - local versionOrAlias= while [ $# -ne 0 ] do if [[ $1 == "-p" || $1 == "-persistent" ]]; then @@ -513,8 +706,20 @@ dnvm() shift done else - local versionOrAlias=$1 - shift + while [ $# -ne 0 ] + do + if [[ $1 == "-a" || $1 == "-arch" ]]; then + local arch=$2 + shift + elif [[ $1 == "-r" || $1 == "-runtime" ]]; then + local runtime=$2 + shift + elif [[ -n $1 ]]; then + [[ -n $versionOrAlias ]] && break + local versionOrAlias=$1 + fi + shift + done fi if [[ $cmd == "use" && $versionOrAlias == "none" ]]; then @@ -529,7 +734,7 @@ dnvm() return 0 fi - local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch") + local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$(__dnvm_current_os)") local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$runtimeFullName") if [[ -z $runtimeBin ]]; then @@ -542,18 +747,20 @@ dnvm() local hostpath="$runtimeBin/dnx" if [[ -e $hostpath ]]; then $hostpath $@ + return $? else echo "Cannot find $_DNVM_RUNTIME_SHORT_NAME in $runtimeBin. It may have been corrupted. Use '$_DNVM_COMMAND_NAME install $versionOrAlias -f' to attempt to reinstall it" fi ;; - "exec") + "exec") ( PATH=$(__dnvm_strip_path "$PATH" "/bin") PATH=$(__dnvm_prepend_path "$PATH" "$runtimeBin") $@ ) + return $? ;; - "use") + "use") echo "Adding" $runtimeBin "to process PATH" PATH=$(__dnvm_strip_path "$PATH" "/bin") @@ -591,7 +798,7 @@ dnvm() local name="$1" if [[ $# == 1 ]]; then - [[ ! -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && echo "There is no alias called '$name'" && return + [[ ! -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && echo "There is no alias called '$name'" && return 1 cat "$_DNVM_ALIAS_DIR/$name.alias" echo "" return @@ -608,18 +815,21 @@ dnvm() elif [[ $1 == "-r" || $1 == "-runtime" ]]; then local runtime=$2 shift + elif [[ $1 == "-OS" ]]; then + local os=$2 + shift fi shift done - local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch") + local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os") - [[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1 + ([[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && [[ ! -d "$_DNVM_GLOBAL_PACKAGES/$runtimeFullName" ]]) && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1 local action="Setting" [[ -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && action="Updating" echo "$action alias '$name' to '$runtimeFullName'" - echo "$runtimeFullName" > "$_DNVM_ALIAS_DIR/$name.alias" + echo "$runtimeFullName" >| "$_DNVM_ALIAS_DIR/$name.alias" ;; "unalias" ) @@ -638,10 +848,20 @@ dnvm() [[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1 local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*" - if [ $# == 2 ]; then - local versionOrAlias=$2 - local searchGlob=$(__dnvm_requested_version_or_alias "$versionOrAlias") - fi + + local runtimes="" + for location in `echo $DNX_HOME | tr ":" "\n"`; do + location+="/runtimes" + if [ -d "$location" ]; then + local oruntimes="$(find $location -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;)" + for v in `echo $oruntimes | tr "\n" " "`; do + runtimes+="$v:$location"$'\n' + done + fi + done + + [[ -z $runtimes ]] && echo 'No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime.' && return + echo "" # Separate empty array declaration from initialization @@ -654,39 +874,79 @@ dnvm() local format="%-20s %s\n" if [ -d "$_DNVM_ALIAS_DIR" ]; then for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do - arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)" + if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ] && [ ! -d "$_DNVM_GLOBAL_PACKAGES/$(cat $__dnvm_file)" ]; then + arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/missing/$(cat $__dnvm_file)" + runtimes="$runtimes $(cat $__dnvm_file)" + else + arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)" + fi let i+=1 done fi - local formatString="%-6s %-20s %-7s %-4s %-20s %s\n" - printf "$formatString" "Active" "Version" "Runtime" "Arch" "Location" "Alias" - printf "$formatString" "------" "-------" "-------" "----" "--------" "-----" + if [[ $2 == "-detailed" ]]; then + # Calculate widest alias + local widestAlias=5 + for f in `echo $runtimes`; do + local pkgName=$(__dnvm_package_name "$f") + local pkgVersion=$(__dnvm_package_version "$f") + local alias="" + local delim="" + for i in "${arr[@]}"; do + if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then + alias+="$delim${i%%/*}" + delim=", " + if [[ "${i%/*}" =~ \/missing$ ]]; then + alias+=" (missing)" + fi + fi + done + if [ "${#alias}" -gt "$widestAlias" ]; then + widestAlias=${#alias} + fi + done + local formatString="%-6s %-20s %-7s %-12s %-15s %-${widestAlias}s %s\n" + printf "$formatString" "Active" "Version" "Runtime" "Architecture" "OperatingSystem" "Alias" "Location" + printf "$formatString" "------" "-------" "-------" "------------" "---------------" "-----" "--------" + else + local formatString="%-6s %-20s %-7s %-12s %-15s %s\n" + printf "$formatString" "Active" "Version" "Runtime" "Architecture" "OperatingSystem" "Alias" + printf "$formatString" "------" "-------" "-------" "------------" "---------------" "-----" + fi - local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)` - for f in $(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;); do + for f in `echo -e "$runtimes" | sort -t. -k2 -k3 -k4 -k1`; do + local location=`echo $f | sed 's/.*\([:]\)//'` + f=`echo $f | sed 's/\([:]\).*//'` + local formattedHome=`(echo $location | sed s=$HOME=~=g)` local active="" - [[ $PATH == *"$_DNVM_USER_PACKAGES/$f/bin"* ]] && local active=" *" + [[ $PATH == *"$location/$f/bin"* ]] && local active=" *" local pkgRuntime=$(__dnvm_package_runtime "$f") local pkgName=$(__dnvm_package_name "$f") local pkgVersion=$(__dnvm_package_version "$f") local pkgArch=$(__dnvm_package_arch "$f") + local pkgOs=$(__dnvm_package_os "$f") local alias="" local delim="" for i in "${arr[@]}"; do - if [[ ${i#*/} == "$pkgName.$pkgVersion" ]]; then - alias+="$delim${i%/*}" + if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then + alias+="$delim${i%%/*}" delim=", " + if [[ "${i%/*}" =~ \/missing$ ]]; then + alias+=" (missing)" + formattedHome="" + fi fi done - printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$formattedHome" "$alias" - [[ $# == 2 ]] && echo "" && return 0 + if [[ $2 == "-detailed" ]]; then + printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias" "$formattedHome" + else + printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias" + fi done echo "" - [[ $# == 2 ]] && echo "$versionOrAlias not found" && return 1 ;; *) @@ -697,5 +957,8 @@ dnvm() return 0 } +# Add the home location's bin directory to the path if it doesn't exist +[[ ":$PATH:" != *":$DNX_USER_HOME/bin:"* ]] && export PATH="$DNX_USER_HOME/bin:$PATH" + # Generate the command function using the constant defined above. -$_DNVM_COMMAND_NAME list default >/dev/null && $_DNVM_COMMAND_NAME use default >/dev/null || true +$_DNVM_COMMAND_NAME alias default >/dev/null && $_DNVM_COMMAND_NAME use default >/dev/null || true From 681e027f3fa6f36ede113acb7d3cdd4cf59d876d Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sun, 27 Sep 2015 14:16:52 -0700 Subject: [PATCH 22/25] Add dnx watch to the projects list --- makefile.shade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makefile.shade b/makefile.shade index e6d807e1a6..ecaafde5a6 100644 --- a/makefile.shade +++ b/makefile.shade @@ -734,8 +734,9 @@ functions "SignalR-SQLServer", "SignalR-Redis", "BrowserLink", + "dnx-watch", "Entropy", - "MusicStore" + "MusicStore" }; var repositoryInclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_INCLUDE"); From 6b9a7fb294eccc06a4fa70f098e5831ddb2d264f Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 28 Sep 2015 15:24:11 -0700 Subject: [PATCH 23/25] Add IISIntegration --- makefile.shade | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile.shade b/makefile.shade index ecaafde5a6..cdade939cf 100644 --- a/makefile.shade +++ b/makefile.shade @@ -715,6 +715,7 @@ functions "EntityFramework", "WebListener", "KestrelHttpServer", + "IISIntegration", "ServerTests", "Diagnostics", "Antiforgery", From d576f71090dfce01561dfd0321806297132823dd Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 28 Sep 2015 21:08:34 -0700 Subject: [PATCH 24/25] Reacting to feed and NuGet.config renames --- makefile.shade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefile.shade b/makefile.shade index cdade939cf..d3cad9a4eb 100644 --- a/makefile.shade +++ b/makefile.shade @@ -165,13 +165,13 @@ var buildTarget = "compile" { var original = File.ReadAllText(nugetConfigPath); var modified = original - .Replace("https://www.myget.org/F/aspnetlitedev", "https://www.myget.org/F/aspnetliterelease") + .Replace("https://www.myget.org/F/aspnetcidev", "https://www.myget.org/F/aspnetcirelease") .Replace("https://www.myget.org/F/azureadwebstacknightly", "https://www.myget.org/F/azureadwebstackrelease"); if (!string.Equals(original, modified, StringComparison.Ordinal)) { File.WriteAllText(nugetConfigPath, modified); - GitCommand(repo, "add NuGet.Config"); + GitCommand(repo, "add NuGet.config"); GitCommand(repo, "commit -m \"Updating to release NuGet.config.\""); } } From faf91c06e04306b4f4c571b3ea0b370f8f6057f5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 22 Sep 2015 11:17:59 -0700 Subject: [PATCH 25/25] * Use --quiet for git pull and git clone so git fetch messages do not show up in CI error logs. --- build/_git-clone.shade | 2 +- build/_git-pull.shade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/_git-clone.shade b/build/_git-clone.shade index 32355ab5a3..13b02334e6 100644 --- a/build/_git-clone.shade +++ b/build/_git-clone.shade @@ -3,7 +3,7 @@ default gitBranch='' -var gitCommand='clone ${gitUri}' +var gitCommand='clone --quiet ${gitUri}' set gitCommand='${gitCommand} --branch ${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)' git diff --git a/build/_git-pull.shade b/build/_git-pull.shade index cb1e565d0c..12a11edaad 100644 --- a/build/_git-pull.shade +++ b/build/_git-pull.shade @@ -2,7 +2,7 @@ default gitBranch='' -var gitCommand='pull --ff-only ${gitUri}' +var gitCommand='pull --quiet --ff-only ${gitUri}' set gitCommand='${gitCommand} ${gitBranch}:${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)' git