Merge branch 'dev' into release

This commit is contained in:
Pranav K 2015-09-28 22:46:10 -07:00
commit b1a0e1b251
24 changed files with 1898 additions and 468 deletions

View File

@ -1,4 +0,0 @@
language: csharp
sudo: false
script:
- ./build.sh --quiet verify

View File

@ -4,8 +4,8 @@
<id>KoreBuild</id> <id>KoreBuild</id>
<title>The ProjectK build tools</title> <title>The ProjectK build tools</title>
<version>0.0</version> <version>0.0</version>
<authors>Microsoft Open Technologies, Inc.</authors> <authors>.NET Foundation</authors>
<owners>Microsoft Open Technologies, Inc.</owners> <owners>.NET Foundation</owners>
<description>ProjectK build tooling</description> <description>ProjectK build tooling</description>
<language>en-US</language> <language>en-US</language>
</metadata> </metadata>

View File

@ -1,7 +0,0 @@
init:
- git config --global core.autocrlf true
build_script:
- build.cmd --quiet verify
clone_depth: 1
test: off
deploy: off

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<packageSources> <packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" /> <add key="AspNetVNext" value="https://www.myget.org/F/aspnetlitedev/api/v2" />
<add key="NuGet" value="https://nuget.org/api/v2/" /> <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources> </packageSources>
</configuration> </configuration>

View File

@ -2,7 +2,6 @@
<configuration> <configuration>
<packageSources> <packageSources>
<clear /> <clear />
<add key="NuGet" value="https://nuget.org/api/v2/" /> <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="AspNetMaster" value="https://www.myget.org/F/aspnetmaster/api/v2" />
</packageSources> </packageSources>
</configuration> </configuration>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetrelease/api/v2" />
<add key="NuGet" value="https://nuget.org/api/v2/" />
</packageSources>
</configuration>

View File

@ -3,6 +3,8 @@ cd %~dp0
SETLOCAL SETLOCAL
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe
SET BUILDCMD_KOREBUILD_VERSION=""
SET BUILDCMD_DNX_VERSION=""
IF EXIST %CACHED_NUGET% goto copynuget IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe... echo Downloading latest version of NuGet.exe...
@ -16,21 +18,21 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul
:restore :restore
IF EXIST packages\KoreBuild goto run IF EXIST packages\KoreBuild goto run
IF DEFINED BUILDCMD_RELEASE ( IF %BUILDCMD_KOREBUILD_VERSION%=="" (
.nuget\NuGet.exe install KoreBuild -version 0.2.1-%BUILDCMD_RELEASE% -ExcludeVersion -o packages -nocache -pre
) ELSE (
.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .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 "%SKIP_DNX_INSTALL%"=="1" goto run
IF DEFINED BUILDCMD_RELEASE ( IF %BUILDCMD_DNX_VERSION%=="" (
CALL packages\KoreBuild\build\dnvm install 1.0.0-%BUILDCMD_RELEASE% -runtime CLR -arch x86 -a default CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86
) ELSE ( ) 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 CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86
:run :run
CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 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 %*

View File

@ -24,7 +24,7 @@ fi
if test ! -d packages/KoreBuild; then if test ! -d packages/KoreBuild; then
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre 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 fi
if ! type dnvm > /dev/null 2>&1; then if ! type dnvm > /dev/null 2>&1; then

View File

@ -15,5 +15,5 @@ md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul copy %CACHED_NUGET% .nuget\nuget.exe > nul
:build :build
.nuget\nuget.exe install Sake -version 0.2 -o packages .nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages
packages\Sake.0.2\tools\Sake.exe -I build -f makefile.shade %* packages\Sake\tools\Sake.exe -I build -f makefile.shade %*

View File

@ -24,7 +24,7 @@ fi
if test ! -d packages/KoreBuild; then if test ! -d packages/KoreBuild; then
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre 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 fi
if ! type dnvm > /dev/null 2>&1; then if ! type dnvm > /dev/null 2>&1; then

View File

@ -26,13 +26,6 @@ functions
return "t" + DateTime.UtcNow.ToString("yyMMddHHmmss"); return "t" + DateTime.UtcNow.ToString("yyMMddHHmmss");
} }
} }
bool IsTeamCity
{
get
{
return Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null;
}
}
bool IsBuildV2 bool IsBuildV2
{ {

883
build/Json.shade Normal file
View File

@ -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<JsonValue> 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<string, JsonValue> _data;
public JsonObject(IDictionary<string, JsonValue> data, int line, int column)
: base(line, column)
{
if (data == null)
{
throw new ArgumentNullException("data");
}
_data = data;
}
public ICollection<string> 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<JsonValue>();
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<string, JsonValue>();
// 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."; }
}
}
}

View File

@ -3,7 +3,7 @@
default gitBranch='' default gitBranch=''
var gitCommand='clone ${gitUri}' var gitCommand='clone --quiet ${gitUri}'
set gitCommand='${gitCommand} --branch ${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)' set gitCommand='${gitCommand} --branch ${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)'
git git

View File

@ -2,7 +2,7 @@
default gitBranch='' default gitBranch=''
var gitCommand='pull --ff-only ${gitUri}' var gitCommand='pull --quiet --ff-only ${gitUri}'
set gitCommand='${gitCommand} ${gitBranch}:${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)' set gitCommand='${gitCommand} ${gitBranch}:${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)'
git git

View File

@ -1,10 +1,16 @@
@{/* @{/*
k-restore 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' default restore_options='${ E("NUGET3_restore_options") }'
exec program='dnu' commandline='restore${restore_options}' if='IsMono'
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'

View File

@ -6,6 +6,7 @@ use namespace="System.Linq"
use import="Files" use import="Files"
use import="BuildEnv" use import="BuildEnv"
use import="Environment" use import="Environment"
use-teamcity
default BASE_DIR='${Directory.GetCurrentDirectory()}' default BASE_DIR='${Directory.GetCurrentDirectory()}'
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}' default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
@ -13,8 +14,9 @@ default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}'
default Configuration='${E("Configuration")}' default Configuration='${E("Configuration")}'
default Quiet='${ false }' 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 DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v3/index.json'
default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
@{ @{
if (string.IsNullOrEmpty(E("DNX_BUILD_VERSION"))) if (string.IsNullOrEmpty(E("DNX_BUILD_VERSION")))
@ -34,7 +36,7 @@ default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2'
Configuration = "Debug"; Configuration = "Debug";
E("Configuration", Configuration); E("Configuration", Configuration);
} }
Log.Info("Build v2: " + IsBuildV2); Log.Info("Build v2: " + IsBuildV2);
} }
@ -103,7 +105,7 @@ default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2'
{ {
projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration)); projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
} }
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg"))) foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
{ {
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true); File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
@ -113,31 +115,38 @@ default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2'
#build-compile target='compile' if='IsBuildV2' #build-compile target='compile' if='IsBuildV2'
@{ @{
// If the src folder, build and create the packages // 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"))) foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
{ {
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true); File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
} }
} }
// For test and samples only check if they compile // For test and samples only check if they compile
var projectsToBuild = new List<string>(); var projectsToBuild = new List<string>();
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( DnuBuild(
string.Join(";", projectsToBuild), string.Join(";", projectsToBuild),
Configuration); Configuration);
} }
} }
@ -182,6 +191,16 @@ default DNX_TOOLS_FEED = 'https://www.myget.org/F/dnxtools/api/v2'
copy sourceDir='${Path.GetDirectoryName(project)}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR, Path.GetFileNameWithoutExtension(project))}' overwrite='${true}' each='var project in nativeProjects' 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' #nuget-install target='install' description='Install NuGet packages to local repo'
kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}' kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
@ -213,17 +232,6 @@ 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 ${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 #make-roslyn-fast
ngen-roslyn ngen-roslyn
@ -351,7 +359,7 @@ macro name="DnuBuild" projectFile='string' configuration='string'
macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string' macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string'
kpm-pack kpm-pack
macro name="DeleteFolder" delete='string' macro name="DeleteFolder" delete='string'
directory directory

View File

@ -1,5 +1,4 @@
use namespace='System.Web.Script.Serialization' use import="Json"
use assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
use import="Environment" use import="Environment"
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}' 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 projectText = File.ReadAllText(projectFile);
var project = (Dictionary<string, object>)serializer.DeserializeObject(projectText); var project = (JsonObject)Json.Deserialize(projectText);
object commandsObject; var commands = project.ValueAsJsonObject("commands");
var commands = project.TryGetValue("commands", out commandsObject)
? (Dictionary<string, object>)commandsObject
: new Dictionary<string, object>();
if (commands.Keys.Contains("test")) if (commands != null && commands.Keys.Contains("test"))
{ {
var projectFolder = Path.GetDirectoryName(projectFile); var projectFolder = Path.GetDirectoryName(projectFile);
var projectName = Path.GetFileName(projectFolder); var projectName = Path.GetFileName(projectFolder);
@ -35,16 +30,20 @@ projectFile=''
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)',')); noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
} }
object configsObject; var configs = project.ValueAsJsonObject("frameworks");
var configs = project.TryGetValue("frameworks", out configsObject) IEnumerable<string> targetFrameworks;
? (Dictionary<string, object>)configsObject if (configs == null)
: new Dictionary<string, object> {
{ // Assume dnx451 only if none specified
{ "dnx451", new Dictionary<string, object>() } // Assume dnx451 only if none specified targetFrameworks = new[] { "dnx451" };
}; }
else
{
targetFrameworks = configs.Keys;
}
// Currently only dnx* targets are supported. See aspnet/Universe#53 // 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) foreach (var framework in targetFrameworks)
{ {

View File

@ -17,10 +17,9 @@ default build_options='${E("NUGET3_build_options")}'
if (IsBuildV2) if (IsBuildV2)
{ {
var projectsToPack = new List<string>(); var projectsToPack = new List<string>();
foreach(var arg in projectFile.Split((char)';')) foreach(var arg in projectFile.Split((char)';'))
{ {
if (!arg.Contains("*")) if (!arg.Contains("*"))
{ {
projectsToPack.Add(Path.GetDirectoryName(arg)); projectsToPack.Add(Path.GetDirectoryName(arg));
} }
@ -30,15 +29,15 @@ default build_options='${E("NUGET3_build_options")}'
projectsToPack.AddRange(projectFolders); projectsToPack.AddRange(projectFolders);
} }
} }
foreach(var projFolder in projectsToPack) foreach(var projFolder in projectsToPack)
{ {
DeleteFolder(Path.Combine(projFolder, "bin", configuration)); DeleteFolder(Path.Combine(projFolder, "bin", configuration));
} }
var projectsArg=projectFile.Replace(";", " "); var projectsArg=projectFile.Replace(";", " ");
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectsArg, configuration); var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectsArg, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }
@ -50,13 +49,12 @@ default build_options='${E("NUGET3_build_options")}'
else else
{ {
var projectFolder=Path.GetDirectoryName(projectFile); var projectFolder=Path.GetDirectoryName(projectFile);
var projectName=Path.GetFileName(projectFolder);
var projectBin=Path.Combine(projectFolder, "bin", configuration); var projectBin=Path.Combine(projectFolder, "bin", configuration);
DeleteFolder(projectBin); DeleteFolder(projectBin);
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration); var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }

View File

@ -1,7 +1,7 @@
@{/* @{/*
kpm-pack kpm-pack
Builds package from project. Downloads and executes k sdk tools. Builds package from project.
projectFile='' projectFile=''
Required. Path to the project.json to build. Required. Path to the project.json to build.
@ -20,10 +20,9 @@ default pack_options='${E("NUGET3_pack_options")}'
if (IsBuildV2) if (IsBuildV2)
{ {
var projectsToPack = new List<string>(); var projectsToPack = new List<string>();
foreach(var arg in projectFile.Split((char)';')) foreach(var arg in projectFile.Split((char)';'))
{ {
if (!arg.Contains("*")) if (!arg.Contains("*"))
{ {
projectsToPack.Add(Path.GetDirectoryName(arg)); 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)); DeleteFolder(Path.Combine(projFolder, "bin", configuration));
} }
var projectsArg=projectFile.Replace(";", " "); var projectsArg=projectFile.Replace(";", " ");
var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectsArg, configuration); var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectsArg, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }
@ -49,11 +48,11 @@ default pack_options='${E("NUGET3_pack_options")}'
{ {
Exec("dnu", dnuArgs); Exec("dnu", dnuArgs);
} }
foreach(var projFolder in projectsToPack) foreach(var projFolder in projectsToPack)
{ {
CopyFolder( CopyFolder(
Path.Combine(projFolder, "bin", configuration), Path.Combine(projFolder, "bin", configuration),
Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)), Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)),
true); true);
} }
@ -63,11 +62,11 @@ default pack_options='${E("NUGET3_pack_options")}'
var projectFolder=Path.GetDirectoryName(projectFile); var projectFolder=Path.GetDirectoryName(projectFile);
var projectName=Path.GetFileName(projectFolder); var projectName=Path.GetFileName(projectFolder);
var projectBin=Path.Combine(projectFolder, "bin", configuration); var projectBin=Path.Combine(projectFolder, "bin", configuration);
DeleteFolder(projectBin); DeleteFolder(projectBin);
var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration); var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }

View File

@ -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}'

View File

@ -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);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
# Source this file from your .bash-profile or script to use # Source this file from your .bash-profile or script to use
# "Constants" # "Constants"
_DNVM_BUILDNUMBER="beta6-10394" _DNVM_BUILDNUMBER="beta8-15518"
_DNVM_AUTHORS="Microsoft Open Technologies, Inc." _DNVM_AUTHORS="Microsoft Open Technologies, Inc."
_DNVM_RUNTIME_PACKAGE_NAME="dnx" _DNVM_RUNTIME_PACKAGE_NAME="dnx"
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment" _DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
@ -11,10 +11,9 @@ _DNVM_RUNTIME_FOLDER_NAME=".dnx"
_DNVM_COMMAND_NAME="dnvm" _DNVM_COMMAND_NAME="dnvm"
_DNVM_PACKAGE_MANAGER_NAME="dnu" _DNVM_PACKAGE_MANAGER_NAME="dnu"
_DNVM_VERSION_MANAGER_NAME=".NET Version Manager" _DNVM_VERSION_MANAGER_NAME=".NET Version Manager"
_DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetrelease/api/v2" _DNVM_DEFAULT_FEED="https://www.myget.org/F/aspnetcirelease/api/v2"
_DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetvnext/api/v2" _DNVM_DEFAULT_UNSTABLE_FEED="https://www.myget.org/F/aspnetcirelease/api/v2"
_DNVM_UPDATE_LOCATION="https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh" _DNVM_UPDATE_LOCATION="https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh"
_DNVM_HOME_VAR_NAME="DNX_HOME"
if [ "$NO_COLOR" != "1" ]; then if [ "$NO_COLOR" != "1" ]; then
# ANSI Colors # ANSI Colors
@ -47,7 +46,19 @@ if [ -z "$DNX_USER_HOME" ]; then
eval DNX_USER_HOME="~/$_DNVM_RUNTIME_FOLDER_NAME" eval DNX_USER_HOME="~/$_DNVM_RUNTIME_FOLDER_NAME"
fi 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_USER_PACKAGES="$DNX_USER_HOME/runtimes"
_DNVM_GLOBAL_PACKAGES="$DNX_GLOBAL_HOME/runtimes"
_DNVM_ALIAS_DIR="$DNX_USER_HOME/alias" _DNVM_ALIAS_DIR="$DNX_USER_HOME/alias"
_DNVM_DNVM_DIR="$DNX_USER_HOME/dnvm" _DNVM_DNVM_DIR="$DNX_USER_HOME/dnvm"
@ -63,35 +74,86 @@ __dnvm_current_os()
fi 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/.*<content.*src="\([^"]*\).*/\1/')"
echo $version $downloadUrl
}
__dnvm_find_latest() { __dnvm_find_latest() {
local platform=$1 local platform=$1
local arch=$2 local arch=$2
local os=$3
if [ -z $platform ]; then
local platform="mono"
fi
if ! __dnvm_has "curl"; then if ! __dnvm_has "curl"; then
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2; printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
return 1 return 1
fi fi
if [[ $platform == "mono" ]]; then if [[ $platform == "mono" ]]; then
#dnx-mono #dnx-mono
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform" local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform"
else else
#dnx-coreclr-linux-x64 #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 fi
local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$packageId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false" local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$packageId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
xml="$(curl $url 2>/dev/null)" __dnvm_query_feed $url
echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1 return $?
version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')" }
echo $version
__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() { __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() { __dnvm_prepend_path() {
@ -125,12 +187,26 @@ __dnvm_package_arch() {
fi 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() { __dnvm_update_self() {
local dnvmFileLocation="$_DNVM_DNVM_DIR/dnvm.sh" local dnvmFileLocation="$_DNVM_DNVM_DIR/dnvm.sh"
if [ ! -e $dnvmFileLocation ]; then if [ ! -e $dnvmFileLocation ]; then
local formattedDnvmFileLocation=`(echo $dnvmFileLocation | sed s=$HOME=~=g)` local formattedDnvmFileLocation=`(echo $dnvmFileLocation | sed s=$HOME=~=g)`
local formattedDnvmHome=`(echo $_DNVM_DNVM_DIR | 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 return 1
fi fi
printf "%b\n" "${Cya}Downloading dnvm.sh from $_DNVM_UPDATE_LOCATION ${RCol}" printf "%b\n" "${Cya}Downloading dnvm.sh from $_DNVM_UPDATE_LOCATION ${RCol}"
@ -142,14 +218,32 @@ __dnvm_update_self() {
source "$dnvmFileLocation" 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() { __dnvm_download() {
local runtimeFullName="$1" local runtimeFullName="$1"
local runtimeFolder="$2" local downloadUrl="$2"
local force="$3" local runtimeFolder="$3"
local force="$4"
local acceptSudo="$5"
local pkgName=$(__dnvm_package_name "$runtimeFullName") local pkgName=$(__dnvm_package_name "$runtimeFullName")
local pkgVersion=$(__dnvm_package_version "$runtimeFullName") local pkgVersion=$(__dnvm_package_version "$runtimeFullName")
local url="$DNX_ACTIVE_FEED/package/$pkgName/$pkgVersion"
local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg" local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg"
if [ -n "$force" ]; then if [ -n "$force" ]; then
@ -161,18 +255,26 @@ __dnvm_download() {
printf "%b\n" "${Gre}$runtimeFullName already installed. ${RCol}" printf "%b\n" "${Gre}$runtimeFullName already installed. ${RCol}"
return 0 return 0
fi fi
if ! __dnvm_has "curl"; then if ! __dnvm_has "curl"; then
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2; printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
return 1 return 1
fi fi
local useSudo=
mkdir -p "$runtimeFolder" > /dev/null 2>&1 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 "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 if [[ $httpResult == "404" ]]; then
printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}" printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}"
@ -181,13 +283,14 @@ __dnvm_download() {
fi fi
[[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching $runtimeFullName from $DNX_ACTIVE_FEED ${RCol}" && return 1 [[ $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 $? return $?
} }
__dnvm_unpack() { __dnvm_unpack() {
local runtimeFile="$1" local runtimeFile="$1"
local runtimeFolder="$2" local runtimeFolder="$2"
local useSudo=$3
echo "Installing to $runtimeFolder" echo "Installing to $runtimeFolder"
@ -196,28 +299,32 @@ __dnvm_unpack() {
return 1 return 1
fi 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" [ -e "$runtimeFile" ] && $useSudo 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
#Set dnx to be executable #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() { __dnvm_requested_version_or_alias() {
local versionOrAlias="$1" local versionOrAlias="$1"
local runtime="$2" local runtime="$2"
local arch="$3" local arch="$3"
local os="$4"
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$versionOrAlias") local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$versionOrAlias")
# If the name specified is an existing package, just use it as is # If the name specified is an existing package, just use it as is
@ -226,22 +333,30 @@ __dnvm_requested_version_or_alias() {
else else
if [ -e "$_DNVM_ALIAS_DIR/$versionOrAlias.alias" ]; then if [ -e "$_DNVM_ALIAS_DIR/$versionOrAlias.alias" ]; then
local runtimeFullName=$(cat "$_DNVM_ALIAS_DIR/$versionOrAlias.alias") local runtimeFullName=$(cat "$_DNVM_ALIAS_DIR/$versionOrAlias.alias")
echo "$runtimeFullName" if [[ ! -n "$runtime" && ! -n "$arch" ]]; then
else echo "$runtimeFullName"
local pkgVersion=$versionOrAlias return
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"
fi 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
fi fi
} }
@ -249,7 +364,11 @@ __dnvm_requested_version_or_alias() {
# This will be more relevant if we support global installs # This will be more relevant if we support global installs
__dnvm_locate_runtime_bin_from_full_name() { __dnvm_locate_runtime_bin_from_full_name() {
local runtimeFullName=$1 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() { __echo_art() {
@ -273,41 +392,50 @@ __dnvm_description() {
printf "%b\n" "${Yel}Current feed settings:${RCol}" printf "%b\n" "${Yel}Current feed settings:${RCol}"
printf "%b\n" "${Cya}Default Stable:${Yel} $_DNVM_DEFAULT_FEED" printf "%b\n" "${Cya}Default Stable:${Yel} $_DNVM_DEFAULT_FEED"
printf "%b\n" "${Cya}Default Unstable:${Yel} $_DNVM_DEFAULT_UNSTABLE_FEED" printf "%b\n" "${Cya}Default Unstable:${Yel} $_DNVM_DEFAULT_UNSTABLE_FEED"
local dnxStableOverride="<none>" local dnxStableOverride="<none>"
[[ -n $DNX_FEED ]] && dnxStableOverride="$DNX_FEED" [[ -n $DNX_FEED ]] && dnxStableOverride="$DNX_FEED"
printf "%b\n" "${Cya}Current Stable Override:${Yel} $dnxStableOverride" printf "%b\n" "${Cya}Current Stable Override:${Yel} $dnxStableOverride"
local dnxUnstableOverride="<none>" local dnxUnstableOverride="<none>"
[[ -n $DNX_UNSTABLE_FEED ]] && dnxUnstableOverride="$DNX_UNSTABLE_FEED" [[ -n $DNX_UNSTABLE_FEED ]] && dnxUnstableOverride="$DNX_UNSTABLE_FEED"
printf "%b\n" "${Cya}Current Unstable Override:${Yel} $dnxUnstableOverride${RCol}" printf "%b\n" "${Cya}Current Unstable Override:${Yel} $dnxUnstableOverride${RCol}"
echo "" echo ""
} }
__dnvm_version() {
echo "1.0.0-$_DNVM_BUILDNUMBER"
}
__dnvm_help() { __dnvm_help() {
__dnvm_description __dnvm_description
printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME <command> [options] ${RCol}" printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME <command> [options] ${RCol}"
echo "" 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 " install latest $_DNVM_RUNTIME_SHORT_NAME from feed"
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line" echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
echo " set installed version as default" echo " set installed version as default"
echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed" 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 " -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 "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-r <runtime>] [-OS <OS>] [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}"
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed" echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem" echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem"
echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed" 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 <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install" echo " -a|-alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
echo " -p|-persistent set installed version as default" 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 " -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 " -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 ""
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line" echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
echo "" 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 " 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 " example: $_DNVM_COMMAND_NAME exec 1.0.0-beta4 $_DNVM_PACKAGE_MANAGER_NAME build"
echo "" 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 " list $_DNVM_RUNTIME_SHORT_NAME versions installed "
echo "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias ${RCol}" 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}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [help|-h|-help|--help] ${RCol}"
echo " displays this help text." echo " displays this help text."
echo "" 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}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME update-self ${RCol}"
echo " updates dnvm itself." echo " updates dnvm itself."
} }
@ -370,6 +503,10 @@ dnvm()
__dnvm_help __dnvm_help
;; ;;
"version"|"-v"|"-version"|"--version" )
__dnvm_version
;;
"update-self" ) "update-self" )
__dnvm_update_self __dnvm_update_self
;; ;;
@ -387,8 +524,11 @@ dnvm()
local alias= local alias=
local force= local force=
local unstable= local unstable=
local runtime="mono" local os=
local arch="x64" local runtime=
local arch=
local global=0
local acceptSudo=0
while [ $# -ne 0 ] while [ $# -ne 0 ]
do do
if [[ $1 == "-p" || $1 == "-persistent" ]]; then if [[ $1 == "-p" || $1 == "-persistent" ]]; then
@ -403,20 +543,21 @@ dnvm()
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
local runtime=$2 local runtime=$2
shift shift
elif [[ $1 == "-OS" ]]; then
local os=$2
shift
elif [[ $1 == "-y" ]]; then
local acceptSudo=1
elif [[ $1 == "-arch" ]]; then elif [[ $1 == "-arch" ]]; then
local arch=$2 local arch=$2
shift shift
if [[ $arch != "x86" && $arch != "x64" ]]; then 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 return 1
fi fi
elif [[ $1 == "-g" || $1 == "-global" ]]; then
if [[ $arch == "x86" && $runtime == "coreclr" ]]; then local global=1
printf "%b\n" "${Red}Core CLR doesn't currently have a 32 bit build. You must use x64.${RCol}"
return 1
fi
elif [[ -n $1 ]]; then elif [[ -n $1 ]]; then
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1 [[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
local versionOrAlias=$1 local versionOrAlias=$1
@ -424,6 +565,11 @@ dnvm()
shift shift
done 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 if [ -z $unstable ]; then
DNX_ACTIVE_FEED="$DNX_FEED" DNX_ACTIVE_FEED="$DNX_FEED"
if [ -z "$DNX_ACTIVE_FEED" ]; then if [ -z "$DNX_ACTIVE_FEED" ]; then
@ -440,21 +586,66 @@ dnvm()
fi fi
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 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; 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 fi
if [[ "$versionOrAlias" == "latest" ]]; then local runtimeDir=$_DNVM_USER_PACKAGES
echo "Determining latest version" if [ $global == 1 ]; then
versionOrAlias=$(__dnvm_find_latest "$runtime" "$arch") runtimeDir=$_DNVM_GLOBAL_PACKAGES
[[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1
printf "%b\n" "Latest version is ${Cya}$versionOrAlias ${RCol}"
fi 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 runtimeFullName=$(basename $versionOrAlias | sed "s/\(.*\)\.nupkg/\1/")
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName") local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName" local runtimeFolder="$runtimeDir/$runtimeFullName"
local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg" local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg"
local runtimeClr=$(__dnvm_package_runtime "$runtimeFullName") local runtimeClr=$(__dnvm_package_runtime "$runtimeFullName")
@ -466,20 +657,22 @@ dnvm()
if [ -e "$runtimeFolder" ]; then if [ -e "$runtimeFolder" ]; then
echo "$runtimeFullName already installed" echo "$runtimeFullName already installed"
else else
local useSudo=
mkdir -p "$runtimeFolder" > /dev/null 2>&1 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" cp -a "$versionOrAlias" "$runtimeFile"
__dnvm_unpack "$runtimeFile" "$runtimeFolder" __dnvm_unpack "$runtimeFile" "$runtimeFolder" $useSudo
[[ $? == 1 ]] && return 1 [[ $? == 1 ]] && return 1
fi fi
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr" $_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr"
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$runtimeVersion" [[ -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 fi
;; ;;
@ -491,9 +684,9 @@ dnvm()
local arch= local arch=
local runtime= local runtime=
local versionOrAlias=
shift shift
if [ $cmd == "use" ]; then if [ $cmd == "use" ]; then
local versionOrAlias=
while [ $# -ne 0 ] while [ $# -ne 0 ]
do do
if [[ $1 == "-p" || $1 == "-persistent" ]]; then if [[ $1 == "-p" || $1 == "-persistent" ]]; then
@ -513,8 +706,20 @@ dnvm()
shift shift
done done
else else
local versionOrAlias=$1 while [ $# -ne 0 ]
shift 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 fi
if [[ $cmd == "use" && $versionOrAlias == "none" ]]; then if [[ $cmd == "use" && $versionOrAlias == "none" ]]; then
@ -529,7 +734,7 @@ dnvm()
return 0 return 0
fi 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") local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$runtimeFullName")
if [[ -z $runtimeBin ]]; then if [[ -z $runtimeBin ]]; then
@ -542,18 +747,20 @@ dnvm()
local hostpath="$runtimeBin/dnx" local hostpath="$runtimeBin/dnx"
if [[ -e $hostpath ]]; then if [[ -e $hostpath ]]; then
$hostpath $@ $hostpath $@
return $?
else 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" 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 fi
;; ;;
"exec") "exec")
( (
PATH=$(__dnvm_strip_path "$PATH" "/bin") PATH=$(__dnvm_strip_path "$PATH" "/bin")
PATH=$(__dnvm_prepend_path "$PATH" "$runtimeBin") PATH=$(__dnvm_prepend_path "$PATH" "$runtimeBin")
$@ $@
) )
return $?
;; ;;
"use") "use")
echo "Adding" $runtimeBin "to process PATH" echo "Adding" $runtimeBin "to process PATH"
PATH=$(__dnvm_strip_path "$PATH" "/bin") PATH=$(__dnvm_strip_path "$PATH" "/bin")
@ -591,7 +798,7 @@ dnvm()
local name="$1" local name="$1"
if [[ $# == 1 ]]; then 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" cat "$_DNVM_ALIAS_DIR/$name.alias"
echo "" echo ""
return return
@ -608,18 +815,21 @@ dnvm()
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
local runtime=$2 local runtime=$2
shift shift
elif [[ $1 == "-OS" ]]; then
local os=$2
shift
fi fi
shift shift
done 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" local action="Setting"
[[ -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && action="Updating" [[ -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && action="Updating"
echo "$action alias '$name' to '$runtimeFullName'" echo "$action alias '$name' to '$runtimeFullName'"
echo "$runtimeFullName" > "$_DNVM_ALIAS_DIR/$name.alias" echo "$runtimeFullName" >| "$_DNVM_ALIAS_DIR/$name.alias"
;; ;;
"unalias" ) "unalias" )
@ -638,10 +848,20 @@ dnvm()
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1 [[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*" local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
if [ $# == 2 ]; then
local versionOrAlias=$2 local runtimes=""
local searchGlob=$(__dnvm_requested_version_or_alias "$versionOrAlias") for location in `echo $DNX_HOME | tr ":" "\n"`; do
fi 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 "" echo ""
# Separate empty array declaration from initialization # Separate empty array declaration from initialization
@ -654,39 +874,79 @@ dnvm()
local format="%-20s %s\n" local format="%-20s %s\n"
if [ -d "$_DNVM_ALIAS_DIR" ]; then if [ -d "$_DNVM_ALIAS_DIR" ]; then
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do 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 let i+=1
done done
fi fi
local formatString="%-6s %-20s %-7s %-4s %-20s %s\n" if [[ $2 == "-detailed" ]]; then
printf "$formatString" "Active" "Version" "Runtime" "Arch" "Location" "Alias" # Calculate widest alias
printf "$formatString" "------" "-------" "-------" "----" "--------" "-----" 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 `echo -e "$runtimes" | sort -t. -k2 -k3 -k4 -k1`; do
for f in $(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;); do local location=`echo $f | sed 's/.*\([:]\)//'`
f=`echo $f | sed 's/\([:]\).*//'`
local formattedHome=`(echo $location | sed s=$HOME=~=g)`
local active="" local active=""
[[ $PATH == *"$_DNVM_USER_PACKAGES/$f/bin"* ]] && local active=" *" [[ $PATH == *"$location/$f/bin"* ]] && local active=" *"
local pkgRuntime=$(__dnvm_package_runtime "$f") local pkgRuntime=$(__dnvm_package_runtime "$f")
local pkgName=$(__dnvm_package_name "$f") local pkgName=$(__dnvm_package_name "$f")
local pkgVersion=$(__dnvm_package_version "$f") local pkgVersion=$(__dnvm_package_version "$f")
local pkgArch=$(__dnvm_package_arch "$f") local pkgArch=$(__dnvm_package_arch "$f")
local pkgOs=$(__dnvm_package_os "$f")
local alias="" local alias=""
local delim="" local delim=""
for i in "${arr[@]}"; do for i in "${arr[@]}"; do
if [[ ${i#*/} == "$pkgName.$pkgVersion" ]]; then if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then
alias+="$delim${i%/*}" alias+="$delim${i%%/*}"
delim=", " delim=", "
if [[ "${i%/*}" =~ \/missing$ ]]; then
alias+=" (missing)"
formattedHome=""
fi
fi fi
done done
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$formattedHome" "$alias" if [[ $2 == "-detailed" ]]; then
[[ $# == 2 ]] && echo "" && return 0 printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias" "$formattedHome"
else
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias"
fi
done done
echo "" echo ""
[[ $# == 2 ]] && echo "$versionOrAlias not found" && return 1
;; ;;
*) *)
@ -697,5 +957,8 @@ dnvm()
return 0 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. # 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

View File

@ -2,6 +2,7 @@
var PROJECT='AspNet' var PROJECT='AspNet'
var VERSION='0.2.1' var VERSION='0.2.1'
use-teamcity
use namespace='System' use namespace='System'
use namespace='System.IO' use namespace='System.IO'
use namespace='System.Collections.Generic' use namespace='System.Collections.Generic'
@ -153,22 +154,24 @@ var buildTarget = "compile"
} }
Log.Info("No conflicts in repos, continuing with creating release branch."); Log.Info("No conflicts in repos, continuing with creating release branch.");
foreach (var repo in GetAllRepos()) foreach (var repo in GetAllRepos())
{ {
GitCommand(repo, "checkout origin/dev -B release"); GitCommand(repo, "checkout origin/dev -B release");
// Update NuGet.Config // Update NuGet.Config
var nugetConfigPath = Path.Combine(repo, "NuGet.config"); var nugetConfigPath = Path.Combine(repo, "NuGet.config");
if (File.Exists(nugetConfigPath)) if (File.Exists(nugetConfigPath))
{ {
var original = File.ReadAllText(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/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)) if (!string.Equals(original, modified, StringComparison.Ordinal))
{ {
File.WriteAllText(nugetConfigPath, modified); File.WriteAllText(nugetConfigPath, modified);
GitCommand(repo, "add NuGet.Config"); GitCommand(repo, "add NuGet.config");
GitCommand(repo, "commit -m \"Updating to release NuGet.config.\""); GitCommand(repo, "commit -m \"Updating to release NuGet.config.\"");
} }
} }
@ -563,7 +566,6 @@ functions
var nonDefaultRepos = new[] var nonDefaultRepos = new[]
{ {
"DNX", "DNX",
"MusicStore",
"Coherence", "Coherence",
"Coherence-Signed", "Coherence-Signed",
"dnvm", "dnvm",
@ -711,9 +713,9 @@ functions
"RazorTooling", "RazorTooling",
"Hosting", "Hosting",
"EntityFramework", "EntityFramework",
"Helios",
"WebListener", "WebListener",
"KestrelHttpServer", "KestrelHttpServer",
"IISIntegration",
"ServerTests", "ServerTests",
"Diagnostics", "Diagnostics",
"Antiforgery", "Antiforgery",
@ -724,13 +726,18 @@ functions
"WebSockets", "WebSockets",
"Localization", "Localization",
"Session", "Session",
"BasicMiddleware",
"Proxy",
"Mvc", "Mvc",
"Identity", "Identity",
"Scaffolding", "Scaffolding",
"SignalR-Server", "SignalR-Server",
"SignalR-SQLServer", "SignalR-SQLServer",
"SignalR-Redis", "SignalR-Redis",
"BrowserLink",
"dnx-watch",
"Entropy", "Entropy",
"MusicStore"
}; };
var repositoryInclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_INCLUDE"); var repositoryInclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_INCLUDE");