KoreBuild-dotnet copy
This commit is contained in:
parent
5ed05d34ac
commit
7043b16980
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>KoreBuild-dotnet</id>
|
||||
<title>The ProjectK build tools</title>
|
||||
<version>0.0</version>
|
||||
<authors>.NET Foundation</authors>
|
||||
<owners>.NET Foundation</owners>
|
||||
<description>ProjectK build tooling</description>
|
||||
<language>en-US</language>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="build\*.*" target="build" />
|
||||
</files>
|
||||
</package>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
use namespace="System"
|
||||
|
||||
functions
|
||||
@{
|
||||
string CreateDayBasedVersionNumber()
|
||||
{
|
||||
var start = new DateTime(2015, 1, 1);
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
string version = "0";
|
||||
// If the computer date is set before the start date, then the version is 0
|
||||
if (now >= start)
|
||||
{
|
||||
var yearsSinceStart = (now.Year - start.Year) + 1;
|
||||
version = yearsSinceStart + now.ToString("MMdd");
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
string BuildNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return "t" + DateTime.UtcNow.ToString("yyMMddHHmmss");
|
||||
}
|
||||
}
|
||||
|
||||
bool IsBuildV2
|
||||
{
|
||||
get
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("KOREBUILD_BUILD_V2") == "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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."; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
<#@ template debug="true" hostspecific="true" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ assembly name="System.Windows.Forms" #>
|
||||
<#@ assembly name="Microsoft.VisualStudio.Shell.Interop.8.0" #>
|
||||
<#@ assembly name="EnvDTE" #>
|
||||
<#@ assembly name="EnvDTE80" #>
|
||||
<#@ import namespace="System" #>
|
||||
<#@ import namespace="System.Collections" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ import namespace="System.IO" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Resources" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Text.RegularExpressions" #>
|
||||
<#@ import namespace="Microsoft.VisualStudio.Shell.Interop" #>
|
||||
<#@ import namespace="EnvDTE" #>
|
||||
<#@ import namespace="EnvDTE80" #>
|
||||
<#
|
||||
var hostServiceProvider = (IServiceProvider)Host;
|
||||
var dte = (EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE));
|
||||
var templateProjectItem = dte.Solution.FindProjectItem(Host.TemplateFile);
|
||||
var projectDirectory = Path.GetDirectoryName(templateProjectItem.ContainingProject.FullName);
|
||||
var ttDirectory = Path.Combine(projectDirectory, "Properties");
|
||||
var projectNamespace = templateProjectItem.ContainingProject.Properties.Item("DefaultNamespace").Value;
|
||||
var projectName = Path.GetFileName(projectDirectory.TrimEnd('/'));
|
||||
var namedParameterMatcher = new Regex(@"\{([a-z]\w+)\}", RegexOptions.IgnoreCase);
|
||||
var numberParameterMatcher = new Regex(@"\{(\d+)\}");
|
||||
|
||||
foreach (var resxFile in Directory.EnumerateFiles(projectDirectory, "*.resx", SearchOption.AllDirectories))
|
||||
{
|
||||
var fileName = Path.GetFileNameWithoutExtension(resxFile);
|
||||
var resourceStrings = new List<ResourceData>();
|
||||
|
||||
using (var resxReader = new ResXResourceReader(resxFile))
|
||||
{
|
||||
resxReader.UseResXDataNodes = true;
|
||||
|
||||
foreach (DictionaryEntry entry in resxReader)
|
||||
{
|
||||
var node = (ResXDataNode)entry.Value;
|
||||
var value = (string)node.GetValue((System.ComponentModel.Design.ITypeResolutionService)null);
|
||||
|
||||
bool usingNamedArgs = true;
|
||||
var match = namedParameterMatcher.Matches(value);
|
||||
if (match.Count == 0)
|
||||
{
|
||||
usingNamedArgs = false;
|
||||
match = numberParameterMatcher.Matches(value);
|
||||
}
|
||||
|
||||
var arguments = match.Cast<Match>()
|
||||
.Select(m => m.Groups[1].Value)
|
||||
.Distinct();
|
||||
if (!usingNamedArgs)
|
||||
{
|
||||
arguments = arguments.OrderBy(Convert.ToInt32);
|
||||
}
|
||||
|
||||
resourceStrings.Add(
|
||||
new ResourceData
|
||||
{
|
||||
Name = node.Name,
|
||||
Value = value,
|
||||
Arguments = arguments.ToList(),
|
||||
UsingNamedArgs = usingNamedArgs
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
GenerationEnvironment.AppendFormat(
|
||||
@"// <auto-generated />
|
||||
namespace {0}
|
||||
{{
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
internal static class {2}
|
||||
{{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager(""{1}.{2}"", typeof({2}).GetTypeInfo().Assembly);
|
||||
", projectNamespace, projectName, fileName);
|
||||
|
||||
foreach (var resourceString in resourceStrings)
|
||||
{
|
||||
GenerationEnvironment.AppendLine();
|
||||
RenderHeader(GenerationEnvironment, resourceString);
|
||||
RenderProperty(GenerationEnvironment, resourceString);
|
||||
|
||||
GenerationEnvironment.AppendLine();
|
||||
RenderHeader(GenerationEnvironment, resourceString);
|
||||
RenderFormatMethod(GenerationEnvironment, resourceString);
|
||||
}
|
||||
|
||||
GenerationEnvironment.Append(@"
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
||||
System.Diagnostics.Debug.Assert(value != null);
|
||||
|
||||
if (formatterNames != null)
|
||||
{
|
||||
for (var i = 0; i < formatterNames.Length; i++)
|
||||
{
|
||||
value = value.Replace(""{"" + formatterNames[i] + ""}"", ""{"" + i + ""}"");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var outputPath = Path.Combine(ttDirectory, fileName + ".Designer.cs");
|
||||
|
||||
File.WriteAllText(outputPath, GenerationEnvironment.ToString());
|
||||
GenerationEnvironment.Length = 0;
|
||||
}
|
||||
#>
|
||||
<#+
|
||||
private static void RenderHeader(StringBuilder builder, ResourceData resourceString)
|
||||
{
|
||||
builder.Append(" /// <summary>")
|
||||
.AppendLine();
|
||||
foreach (var line in resourceString.Value.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
|
||||
{
|
||||
builder.AppendFormat(" /// {0}", line.Replace("<", "<").Replace(">", ">"))
|
||||
.AppendLine();
|
||||
}
|
||||
builder.Append(" /// </summary>")
|
||||
.AppendLine();
|
||||
}
|
||||
|
||||
private static void RenderProperty(StringBuilder builder, ResourceData resourceString)
|
||||
{
|
||||
builder.AppendFormat(" internal static string {0}", resourceString.Name)
|
||||
.AppendLine()
|
||||
.AppendLine(" {")
|
||||
.AppendFormat(@" get {{ return GetString(""{0}""); }}", resourceString.Name)
|
||||
.AppendLine()
|
||||
.AppendLine(" }");
|
||||
}
|
||||
|
||||
private static void RenderFormatMethod(StringBuilder builder, ResourceData resourceString)
|
||||
{
|
||||
builder.AppendFormat(" internal static string Format{0}({1})", resourceString.Name, resourceString.Parameters)
|
||||
.AppendLine()
|
||||
.AppendLine(" {");
|
||||
if(resourceString.Arguments.Count > 0)
|
||||
{
|
||||
builder.AppendFormat(@" return string.Format(CultureInfo.CurrentCulture, GetString(""{0}""{1}), {2});",
|
||||
resourceString.Name,
|
||||
resourceString.UsingNamedArgs ? ", " + resourceString.FormatArguments : null,
|
||||
resourceString.ArgumentNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendFormat(@" return GetString(""{0}"");", resourceString.Name);
|
||||
}
|
||||
builder.AppendLine()
|
||||
.AppendLine(" }");
|
||||
}
|
||||
|
||||
|
||||
private class ResourceData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public List<string> Arguments { get; set; }
|
||||
|
||||
public bool UsingNamedArgs { get; set; }
|
||||
|
||||
public string FormatArguments
|
||||
{
|
||||
get { return string.Join(", ", Arguments.Select(a => "\"" + a + "\"")); }
|
||||
}
|
||||
|
||||
public string ArgumentNames
|
||||
{
|
||||
get { return string.Join(", ", Arguments.Select(GetArgName)); }
|
||||
}
|
||||
|
||||
public string Parameters
|
||||
{
|
||||
get { return string.Join(", ", Arguments.Select(a => "object " + GetArgName(a))); }
|
||||
}
|
||||
|
||||
public string GetArgName(string name)
|
||||
{
|
||||
return UsingNamedArgs ? name : 'p' + name;
|
||||
}
|
||||
}
|
||||
#>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
default ASM_DIFF='${Environment.GetEnvironmentVariable("ASM_DIFF")}'
|
||||
default outFile = "artifacts\default.html"
|
||||
@{
|
||||
if (String.IsNullOrEmpty(ASM_DIFF))
|
||||
{
|
||||
Log.Warn("ASM_DIFF environment variable not set.");
|
||||
Environment.Exit(-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
exec program='${ASM_DIFF}' commandline='${oldBinariesDir} ${newBinariesDir} -adm -out:${outFile}'
|
||||
|
||||
@{
|
||||
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")))
|
||||
{
|
||||
var message = File.ReadAllText(outFile)
|
||||
.Replace("|", "||")
|
||||
.Replace("'", "|'")
|
||||
.Replace("\r", "|r")
|
||||
.Replace("\n", "|n")
|
||||
.Replace("]", "|]");
|
||||
Log.Info("##teamcity[message text='" + message + "' status='WARNING']");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||
var bowerLibrary = '${ Path.Combine(nodeDir, "node_modules", "bower", "bin", "bower") }'
|
||||
var bowerInstalled = '${ File.Exists(bowerLibrary) }'
|
||||
|
||||
default bowerGloballyInstalled = '${ !bowerInstalled && TestCommand("bower", "--version --config.interactive=false") }'
|
||||
var bowerCmd = '${ bowerGloballyInstalled ? "bower" : bowerLibrary }'
|
||||
|
||||
- // Turn off Bower's Insight reporting since this usage is scripted.
|
||||
- bowerCommand = bowerCommand + " --config.interactive=false";
|
||||
|
||||
- // Install bower locally if not already installed either globally or locally; creates bowerLibrary file if run
|
||||
var installCommand = 'install ${E("KOREBUILD_NPM_INSTALL_OPTIONS")} --prefix "${nodeDir}" bower'
|
||||
npm npmCommand='${installCommand}' if='!(bowerGloballyInstalled || bowerInstalled)' once='installBower'
|
||||
|
||||
- // Run bower
|
||||
exec program='cmd' commandline='/C ${bowerCmd} ${bowerCommand}' workingdir='${bowerDir}' if='bowerGloballyInstalled && !IsLinux'
|
||||
exec program='${bowerCmd}' commandline='${bowerCommand}' workingdir='${bowerDir}' if='bowerGloballyInstalled && IsLinux'
|
||||
node nodeCommand='"${bowerCmd}" ${bowerCommand}' workingdir='${bowerDir}' if='!bowerGloballyInstalled'
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
use import="Files"
|
||||
|
||||
default include='**/*.*'
|
||||
default exclude=''
|
||||
default overwrite='${ false }'
|
||||
|
||||
@{
|
||||
var copyFiles = Files.BasePath(Path.GetFullPath(sourceDir));
|
||||
if (!string.IsNullOrEmpty(include))
|
||||
{
|
||||
copyFiles = copyFiles.Include(include);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(exclude))
|
||||
{
|
||||
copyFiles = copyFiles.Exclude(exclude);
|
||||
}
|
||||
|
||||
foreach(var copyFile in copyFiles)
|
||||
{
|
||||
if (!Quiet)
|
||||
{
|
||||
Log.Info(string.Format("Copying {0}", copyFile));
|
||||
}
|
||||
|
||||
var sourceFile = Path.Combine(sourceDir, copyFile);
|
||||
var outputFile = Path.Combine(outputDir, copyFile);
|
||||
if (!Directory.Exists(Path.GetDirectoryName(outputFile)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(outputFile));
|
||||
}
|
||||
|
||||
File.Copy(sourceFile, outputFile, overwrite);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
@{/*
|
||||
|
||||
dnu
|
||||
Run dnu commands in your project. Executes `dnu` command.
|
||||
|
||||
command=''
|
||||
The `dnu` subcommand to execute.
|
||||
dnvmUse=''
|
||||
Optional. The DNX framework to use. Suitable for a `dnvm exec` or `dnvm use` command.
|
||||
*/}
|
||||
|
||||
default dnvmUse=''
|
||||
var dnvmPath = '${ Path.Combine(Directory.GetCurrentDirectory(), "packages", "KoreBuild", "build", "dnvm") }'
|
||||
|
||||
exec program='cmd' commandline='/C dnu ${command}' if='!IsLinux && string.IsNullOrEmpty(dnvmUse)'
|
||||
|
||||
var cmdCommand = '/S /C ""${dnvmPath}.cmd" use ${dnvmUse} && dnu ${command}"'
|
||||
exec program='cmd' commandline='${ cmdCommand }' if='!IsLinux && !string.IsNullOrEmpty(dnvmUse)'
|
||||
|
||||
exec program='dnu' commandline='${command}' if='IsLinux && string.IsNullOrEmpty(dnvmUse)'
|
||||
|
||||
var envCommand = 'bash -c "source \"${dnvmPath}.sh\" && dnvm use ${dnvmUse} && dnu ${command}"'
|
||||
exec program='/usr/bin/env' commandline='${ envCommand }' if='IsLinux && !string.IsNullOrEmpty(dnvmUse)'
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
|
||||
|
||||
default gitBranch=''
|
||||
|
||||
var gitCommand='clone --quiet ${gitUri}'
|
||||
set gitCommand='${gitCommand} --branch ${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)'
|
||||
|
||||
git
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
var gitCommand='config ${gitOptionName} ${gitOptionValue}'
|
||||
|
||||
git
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
|
||||
default gitBranch=''
|
||||
|
||||
var gitCommand='pull --quiet --ff-only ${gitUri}'
|
||||
set gitCommand='${gitCommand} ${gitBranch}:${gitBranch}' if='!string.IsNullOrEmpty(gitBranch)'
|
||||
|
||||
git
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
default gitFolder=''
|
||||
|
||||
-// Use cmd to invoke git so that people who have git as a 'cmd'
|
||||
exec program='cmd' commandline='/C git ${gitCommand}' workingdir='${gitFolder}' if='!IsLinux'
|
||||
exec program='git' commandline='${gitCommand}' workingdir='${gitFolder}' if='IsLinux'
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||
var gruntCliLibrary = '${ Path.Combine(nodeDir, "node_modules", "grunt-cli", "bin", "grunt") }'
|
||||
var gruntCliInstalled = '${ File.Exists(gruntCliLibrary) }'
|
||||
|
||||
default gruntCliGloballyInstalled = '${ !gruntCliInstalled && TestCommand("grunt", "--version") }'
|
||||
var gruntCmd = '${ gruntCliGloballyInstalled ? "grunt" : gruntCliLibrary }'
|
||||
|
||||
- // Install grunt-cli locally if not already installed either globally or locally; creates gruntCliLibrary file if run
|
||||
var installCommand = 'install ${E("KOREBUILD_NPM_INSTALL_OPTIONS")} --prefix "${nodeDir}" grunt-cli'
|
||||
npm npmCommand='${installCommand}' if='!(gruntCliGloballyInstalled || gruntCliInstalled)' once='installGruntCli'
|
||||
|
||||
-// Run grunt-cli
|
||||
exec program='cmd' commandline='/C ${gruntCmd}' workingdir='${gruntDir}' if='gruntCliGloballyInstalled && !IsLinux'
|
||||
exec program='${gruntCmd}' workingdir='${gruntDir}' if='gruntCliGloballyInstalled && IsLinux'
|
||||
node nodeCommand='"${gruntCmd}"' workingdir='${gruntDir}' if='!gruntCliGloballyInstalled'
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
@{/*
|
||||
|
||||
k-clean
|
||||
Cleans project. Downloads and executes k sdk tools.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the project.json to build.
|
||||
|
||||
*/}
|
||||
|
||||
var projectFolder='${Path.GetDirectoryName(projectFile)}'
|
||||
|
||||
directory delete='${Path.Combine(projectFolder, "bin")}'
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
use namespace="System"
|
||||
use namespace="System.Collections.Generic"
|
||||
use namespace="System.IO"
|
||||
use namespace="System.Linq"
|
||||
use namespace="System.Text"
|
||||
use namespace="System.Xml.Linq"
|
||||
|
||||
default resxFile=''
|
||||
|
||||
@{
|
||||
var projectDir = Path.GetDirectoryName(resxFile);
|
||||
var outDirectory = Path.Combine(projectDir, "Properties");
|
||||
var projectName = Path.GetFileName(projectDir.TrimEnd((char)'/'));
|
||||
var namedParameterMatcher = new Regex(@"\{([a-z]\w+)\}", RegexOptions.IgnoreCase);
|
||||
var numberParameterMatcher = new Regex(@"\{(\d+)\}");
|
||||
var generatingEnvironment = new StringBuilder();
|
||||
|
||||
var fileName = Path.GetFileNameWithoutExtension(resxFile);
|
||||
var resourceStrings = new List<ResourceData>();
|
||||
var xml = XDocument.Load(resxFile);
|
||||
|
||||
foreach (var entry in xml.Descendants("data"))
|
||||
{
|
||||
var name = entry.Attribute("name").Value;
|
||||
var value = entry.Element("value").Value;
|
||||
|
||||
bool usingNamedArgs = true;
|
||||
var match = namedParameterMatcher.Matches(value);
|
||||
if (match.Count == 0)
|
||||
{
|
||||
usingNamedArgs = false;
|
||||
match = numberParameterMatcher.Matches(value);
|
||||
}
|
||||
|
||||
var arguments = match.Cast<Match>()
|
||||
.Select(m => m.Groups[1].Value)
|
||||
.Distinct();
|
||||
if (!usingNamedArgs)
|
||||
{
|
||||
arguments = arguments.OrderBy(Convert.ToInt32);
|
||||
}
|
||||
|
||||
resourceStrings.Add(
|
||||
new ResourceData
|
||||
{
|
||||
Name = name,
|
||||
Value = value,
|
||||
Arguments = arguments.ToList(),
|
||||
UsingNamedArgs = usingNamedArgs
|
||||
});
|
||||
}
|
||||
|
||||
generatingEnvironment.AppendFormat(
|
||||
@"// <auto-generated />
|
||||
namespace {0}
|
||||
{{
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
internal static class {1}
|
||||
{{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager(""{0}.{1}"", typeof({1}).GetTypeInfo().Assembly);
|
||||
", projectName, fileName);
|
||||
|
||||
foreach (var resourceString in resourceStrings)
|
||||
{
|
||||
generatingEnvironment.AppendLine();
|
||||
RenderHeader(generatingEnvironment, resourceString);
|
||||
RenderProperty(generatingEnvironment, resourceString);
|
||||
|
||||
generatingEnvironment.AppendLine();
|
||||
RenderHeader(generatingEnvironment, resourceString);
|
||||
RenderFormatMethod(generatingEnvironment, resourceString);
|
||||
}
|
||||
|
||||
generatingEnvironment.Append(@"
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
||||
System.Diagnostics.Debug.Assert(value != null);
|
||||
|
||||
if (formatterNames != null)
|
||||
{
|
||||
for (var i = 0; i < formatterNames.Length; i++)
|
||||
{
|
||||
value = value.Replace(""{"" + formatterNames[i] + ""}"", ""{"" + i + ""}"");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
Directory.CreateDirectory(outDirectory);
|
||||
var outputPath = Path.Combine(outDirectory, fileName + ".Designer.cs");
|
||||
|
||||
File.WriteAllText(outputPath, generatingEnvironment.ToString());
|
||||
}
|
||||
|
||||
functions @{
|
||||
private static void RenderHeader(StringBuilder builder, ResourceData resourceString)
|
||||
{
|
||||
builder.Append(" /// <summary>")
|
||||
.AppendLine();
|
||||
foreach (var line in resourceString.Value.Split(new[] { '\n' }, StringSplitOptions.None))
|
||||
{
|
||||
builder.AppendFormat(" /// {0}", new XText(line))
|
||||
.AppendLine();
|
||||
}
|
||||
builder.Append(" /// </summary>")
|
||||
.AppendLine();
|
||||
}
|
||||
|
||||
private static void RenderProperty(StringBuilder builder, ResourceData resourceString)
|
||||
{
|
||||
builder.AppendFormat(" internal static string {0}", resourceString.Name)
|
||||
.AppendLine()
|
||||
.AppendLine(" {")
|
||||
.AppendFormat(@" get {{ return GetString(""{0}""); }}", resourceString.Name)
|
||||
.AppendLine()
|
||||
.AppendLine(" }");
|
||||
}
|
||||
|
||||
private static void RenderFormatMethod(StringBuilder builder, ResourceData resourceString)
|
||||
{
|
||||
builder.AppendFormat(" internal static string Format{0}({1})", resourceString.Name, resourceString.Parameters)
|
||||
.AppendLine()
|
||||
.AppendLine(" {");
|
||||
if(resourceString.Arguments.Count > 0)
|
||||
{
|
||||
builder.AppendFormat(@" return string.Format(CultureInfo.CurrentCulture, GetString(""{0}""{1}), {2});",
|
||||
resourceString.Name,
|
||||
resourceString.UsingNamedArgs ? ", " + resourceString.FormatArguments : null,
|
||||
resourceString.ArgumentNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendFormat(@" return GetString(""{0}"");", resourceString.Name);
|
||||
}
|
||||
builder.AppendLine()
|
||||
.AppendLine(" }");
|
||||
}
|
||||
|
||||
private class ResourceData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public List<string> Arguments { get; set; }
|
||||
|
||||
public bool UsingNamedArgs { get; set; }
|
||||
|
||||
public string FormatArguments
|
||||
{
|
||||
get { return string.Join(", ", Arguments.Select(a => "\"" + a + "\"")); }
|
||||
}
|
||||
|
||||
public string ArgumentNames
|
||||
{
|
||||
get { return string.Join(", ", Arguments.Select(GetArgName)); }
|
||||
}
|
||||
|
||||
public string Parameters
|
||||
{
|
||||
get { return string.Join(", ", Arguments.Select(a => "object " + GetArgName(a))); }
|
||||
}
|
||||
|
||||
public string GetArgName(string name)
|
||||
{
|
||||
return UsingNamedArgs ? name : 'p' + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
@{/*
|
||||
|
||||
k-restore
|
||||
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 currentDir = '${ Directory.GetCurrentDirectory() }'
|
||||
default restoreDir = '${ currentDir }'
|
||||
|
||||
-// Set KOREBUILD_DNU_RESTORE_CORECLR environment variable to any value and `dnu restore` will use Core CLR.
|
||||
var useCore = '${ E("KOREBUILD_DNU_RESTORE_CORECLR") }'
|
||||
default restoreUse='${ string.IsNullOrEmpty(useCore) ? string.Empty : "default -runtime coreclr" }'
|
||||
|
||||
default restore_options=' ${ E("KOREBUILD_DNU_RESTORE_OPTIONS") } ${ IsLinux ? string.Empty : "--parallel" }'
|
||||
|
||||
dnu command='restore${ restore_options }' workingDir='${ restoreDir }' dnvmUse='${ restoreUse }'
|
||||
|
|
@ -0,0 +1,398 @@
|
|||
use assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
||||
use namespace="System"
|
||||
use namespace="System.Globalization"
|
||||
use namespace="System.IO"
|
||||
use namespace="System.Linq"
|
||||
use import="BuildEnv"
|
||||
use import="Environment"
|
||||
use import="Files"
|
||||
use import="Json"
|
||||
use-teamcity
|
||||
|
||||
default BASE_DIR='${Directory.GetCurrentDirectory()}'
|
||||
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
|
||||
default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
|
||||
default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}'
|
||||
default Configuration='${E("Configuration")}'
|
||||
default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
|
||||
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")))
|
||||
{
|
||||
E("DNX_BUILD_VERSION", BuildNumber);
|
||||
}
|
||||
if (string.IsNullOrEmpty(E("DNX_AUTHOR")))
|
||||
{
|
||||
E("DNX_AUTHOR", AUTHORS);
|
||||
}
|
||||
if (string.IsNullOrEmpty(E("DNX_ASSEMBLY_FILE_VERSION")))
|
||||
{
|
||||
E("DNX_ASSEMBLY_FILE_VERSION", CreateDayBasedVersionNumber());
|
||||
}
|
||||
if (string.IsNullOrEmpty(Configuration))
|
||||
{
|
||||
Configuration = "Debug";
|
||||
E("Configuration", Configuration);
|
||||
}
|
||||
|
||||
Log.Info("Build v2: " + IsBuildV2);
|
||||
}
|
||||
|
||||
#restore-npm-modules
|
||||
-// Find all dirs that contain a package.json file
|
||||
var npmDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json")}'
|
||||
npm npmCommand='install ${E("KOREBUILD_NPM_INSTALL_OPTIONS")}' each='var npmDir in npmDirs'
|
||||
|
||||
#restore-bower-components
|
||||
-// Find all dirs that contain a bower.json file
|
||||
var bowerDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "bower.json")}'
|
||||
bower each='var bowerDir in bowerDirs' bowerCommand='install ${E("KOREBUILD_BOWER_INSTALL_OPTIONS")}'
|
||||
|
||||
#run-grunt .restore-npm-modules .restore-bower-components target='initialize'
|
||||
-// Find all dirs that contain a gruntfile.js file
|
||||
var gruntDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "gruntfile.js")}'
|
||||
grunt each='var gruntDir in gruntDirs'
|
||||
|
||||
#clean-bin-folder
|
||||
rimraf rimrafDir='bin' if='Directory.Exists("bin")'
|
||||
|
||||
#clean-npm-modules
|
||||
-// Find all dirs that contain a package.json file
|
||||
var npmDirs = '${
|
||||
GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json")
|
||||
.Select(directory => Path.Combine(directory, "node_modules"))
|
||||
.Where(directory => Directory.Exists(directory))
|
||||
}'
|
||||
rimraf each='var rimrafDir in npmDirs'
|
||||
|
||||
-// Target order is important because clean-npm-modules may (re)create bin folder.
|
||||
#deep-clean .clean-npm-modules .clean-bin-folder description='Clean folders that may cause problems for `git clean`.'
|
||||
|
||||
#repo-initialize target='initialize'
|
||||
k-restore
|
||||
|
||||
#target-dir-clean target='clean'
|
||||
@{
|
||||
if (Directory.Exists(TARGET_DIR))
|
||||
{
|
||||
var directory = new DirectoryInfo(TARGET_DIR);
|
||||
directory.Attributes &= ~FileAttributes.ReadOnly;
|
||||
|
||||
foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories))
|
||||
{
|
||||
info.Attributes &= ~FileAttributes.ReadOnly;
|
||||
}
|
||||
|
||||
directory.Delete(true);
|
||||
}
|
||||
}
|
||||
|
||||
#build-clean target='clean' if='Directory.Exists("src")'
|
||||
k-clean each='var projectFile in Files.Include("src/**/project.json")'
|
||||
|
||||
#ci-deep-clean .deep-clean target='clean' if='IsTeamCity'
|
||||
|
||||
#build-compile target='compile' if='!IsBuildV2 && Directory.Exists("src")'
|
||||
@{
|
||||
var projectFiles = Files.Include("src/**/project.json").ToList();
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
#build-compile target='compile' if='IsBuildV2'
|
||||
@{
|
||||
// If the src folder, build and create the packages
|
||||
if (Directory.Exists("src"))
|
||||
{
|
||||
// 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<string>();
|
||||
if (Directory.Exists("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"))
|
||||
{
|
||||
// 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())
|
||||
{
|
||||
DnuBuild(
|
||||
string.Join(";", projectsToBuild),
|
||||
Configuration);
|
||||
}
|
||||
}
|
||||
|
||||
#native-compile target='compile' if='!IsLinux && Directory.Exists(Path.Combine(BASE_DIR, "src"))'
|
||||
var programFilesX86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
|
||||
var nativeProjects ='${Files.Include(Path.Combine(BASE_DIR, "src", "**", "*.vcxproj"))}'
|
||||
|
||||
@{
|
||||
if (nativeProjects.Any())
|
||||
{
|
||||
var msbuildVersions = new[] { "14.0", "12.0"};
|
||||
|
||||
for (var i = 0; i < msbuildVersions.Length; i++)
|
||||
{
|
||||
var msbuildPath = Path.Combine(programFilesX86, "MSBuild", msbuildVersions[i], "Bin", "MSBuild.exe");
|
||||
if (File.Exists(msbuildPath))
|
||||
{
|
||||
var commonParameters =
|
||||
" /p:Configuration=" + Configuration +
|
||||
" /p:ProductVersion=1.0.0" +
|
||||
" /p:FileRevision=" + E("DNX_ASSEMBLY_FILE_VERSION") +
|
||||
" /p:BuildVersion=" + E("DNX_BUILD_VERSION");
|
||||
|
||||
foreach (var project in nativeProjects)
|
||||
{
|
||||
Exec(msbuildPath, project + " /p:Platform=Win32" + commonParameters);
|
||||
Exec(msbuildPath, project + " /p:Platform=x64" + commonParameters);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == msbuildVersions.Length - 1)
|
||||
{
|
||||
Log.Warn("msbuild version 14 or 12 not found. Please ensure you have the VS 2015 or VS 2013 C++ SDK installed.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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' if='Directory.Exists("src")' description='Install NuGet packages to local repo'
|
||||
kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
|
||||
nuget-resilient-publish sourcePackagesDir='${BUILD_DIR}' nugetFeed='${E("NUGET_PUBLISH_FEED")}' if='!string.IsNullOrEmpty(E("NUGET_PUBLISH_FEED"))'
|
||||
|
||||
#xunit-test target='test' if='Directory.Exists("test")'
|
||||
@{
|
||||
var projectFiles = Files.Include("test/**/project.json").Exclude("**/bin/*/app/project.json").ToList();
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnxTest(projectFile, testParallel: true));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFiles.ForEach(projectFile => DnxTest(projectFile, testParallel: false));
|
||||
}
|
||||
}
|
||||
|
||||
#build-samples target='test' if='!IsBuildV2 && Directory.Exists("samples")'
|
||||
@{
|
||||
var projectFiles = Files.Include("samples/**/project.json").ToList();
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnuBuild(projectFile, Configuration));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFiles.ForEach(projectFile => DnuBuild(projectFile, Configuration));
|
||||
}
|
||||
}
|
||||
|
||||
#make-roslyn-fast
|
||||
ngen-roslyn
|
||||
|
||||
#resx
|
||||
@{
|
||||
var cultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures | CultureTypes.InstalledWin32Cultures | CultureTypes.SpecificCultures);
|
||||
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.resx", SearchOption.AllDirectories))
|
||||
{
|
||||
var splitFileName = Path.GetFileNameWithoutExtension(file).Split(new string[] { "." }, StringSplitOptions.None);
|
||||
|
||||
if (splitFileName.Length > 1)
|
||||
{
|
||||
var localeString = splitFileName.Last();
|
||||
if (!cultures.Any(c => localeString.Equals(c.Name)))
|
||||
{
|
||||
UpdateResx(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateResx(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#--quiet
|
||||
@{
|
||||
AddToE("KOREBUILD_BOWER_INSTALL_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_DNU_BUILD_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_DNU_PACK_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_DNU_RESTORE_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_NPM_INSTALL_OPTIONS", "--quiet");
|
||||
Quiet = true;
|
||||
}
|
||||
|
||||
#--parallel
|
||||
@{
|
||||
E("KOREBUILD_PARALLEL", "1");
|
||||
}
|
||||
|
||||
#--test-dnxcore
|
||||
@{
|
||||
E("KOREBUILD_TEST_DNXCORE", "1");
|
||||
}
|
||||
|
||||
#stylecop if='Directory.Exists("src")'
|
||||
stylecop-setup
|
||||
stylecop-run each='var projectFile in Files.Include("src/**/project.json")'
|
||||
|
||||
functions @{
|
||||
private static bool Quiet { get; set; }
|
||||
|
||||
string E(string key) { return Environment.GetEnvironmentVariable(key); }
|
||||
void E(string key, string value) { Environment.SetEnvironmentVariable(key, value); }
|
||||
void AddToE(string key, string append)
|
||||
{
|
||||
var original = E(key);
|
||||
if (string.IsNullOrEmpty(original))
|
||||
{
|
||||
E(key, append);
|
||||
}
|
||||
else
|
||||
{
|
||||
E(key, original + " " + append);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<string> GetDirectoriesContaining(string path, string searchPattern)
|
||||
{
|
||||
var sep = Path.DirectorySeparatorChar;
|
||||
// Don't include directories that are children of a node_modules or bower_components directory
|
||||
return Directory.GetFiles(path, searchPattern, SearchOption.AllDirectories)
|
||||
.Where(p => p.IndexOf(sep + "node_modules" + sep) < 0 &&
|
||||
p.IndexOf(sep + "bower_components" + sep) < 0 &&
|
||||
p.IndexOf(sep + "wwwroot" + sep + "lib" + sep) < 0)
|
||||
.Select(p => Path.GetDirectoryName(p))
|
||||
.Distinct();
|
||||
}
|
||||
|
||||
bool TestCommand(string program, string commandline)
|
||||
{
|
||||
// Tests whether a given command succeeds at the command line.
|
||||
// Useful for testing whether a given command is installed and on the path, e.g. node
|
||||
ProcessStartInfo processStartInfo;
|
||||
|
||||
if(!IsLinux)
|
||||
{
|
||||
processStartInfo = new ProcessStartInfo {
|
||||
UseShellExecute = false,
|
||||
FileName = "cmd",
|
||||
Arguments = "/C " + program + " " + commandline,
|
||||
};
|
||||
} else
|
||||
{
|
||||
processStartInfo = new ProcessStartInfo {
|
||||
UseShellExecute = false,
|
||||
FileName = program,
|
||||
Arguments = commandline,
|
||||
};
|
||||
}
|
||||
try
|
||||
{
|
||||
Log.Info(string.Format("Testing for command: {0} {1}", program, commandline));
|
||||
var process = Process.Start(processStartInfo);
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode == 0)
|
||||
{
|
||||
Log.Info(" command found (0 exit code)");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn(" command not found (non-0 exit code)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warn(" command exception: " + ex.ToString());
|
||||
Log.Warn(" command not found");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ShouldRunInParallel
|
||||
{
|
||||
get { return !string.IsNullOrEmpty(E("KOREBUILD_PARALLEL")); }
|
||||
}
|
||||
|
||||
bool ShouldVerifyNupkgs
|
||||
{
|
||||
get { return E("KOREBUILD_VERIFY_NUPKGS") == "1"; }
|
||||
}
|
||||
}
|
||||
|
||||
macro name='Exec' program='string' commandline='string'
|
||||
exec
|
||||
|
||||
macro name='Dnu' command='string'
|
||||
dnu
|
||||
|
||||
macro name='Dnx' command='string' dnxDir='string'
|
||||
k
|
||||
|
||||
macro name='Dnx' command='string' dnxDir='string' dnvmUse='string'
|
||||
k
|
||||
|
||||
macro name="UpdateResx" resxFile='string'
|
||||
k-generate-resx
|
||||
|
||||
macro name="DnxTest" projectFile='string' testParallel='bool'
|
||||
k-test
|
||||
|
||||
macro name="DnuBuild" projectFile='string' configuration='string'
|
||||
kpm-build
|
||||
|
||||
macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string'
|
||||
kpm-pack
|
||||
|
||||
macro name="DeleteFolder" delete='string'
|
||||
directory
|
||||
|
||||
macro name="CopyFolder" sourceDir='string' outputDir='string' overwrite='bool'
|
||||
copy
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
use import="Json"
|
||||
use import="Environment"
|
||||
|
||||
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
|
||||
default KOREBUILD_TEST_DNXCORE='${E("KOREBUILD_TEST_DNXCORE")}'
|
||||
|
||||
@{/*
|
||||
|
||||
k-test
|
||||
Run unit tests in your project.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the test project.json to execute
|
||||
|
||||
*/}
|
||||
|
||||
@{
|
||||
var projectText = File.ReadAllText(projectFile);
|
||||
var project = (JsonObject)Json.Deserialize(projectText);
|
||||
|
||||
var commands = project.ValueAsJsonObject("commands");
|
||||
|
||||
if (commands != null && commands.Keys.Contains("test"))
|
||||
{
|
||||
var projectFolder = Path.GetDirectoryName(projectFile);
|
||||
var projectName = Path.GetFileName(projectFolder);
|
||||
|
||||
var noParallelTestProjects = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
if (!string.IsNullOrEmpty(NO_PARALLEL_TEST_PROJECTS))
|
||||
{
|
||||
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
|
||||
}
|
||||
|
||||
var configs = project.ValueAsJsonObject("frameworks");
|
||||
IEnumerable<string> 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
|
||||
targetFrameworks = targetFrameworks.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
foreach (var framework in targetFrameworks)
|
||||
{
|
||||
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
|
||||
|
||||
if (!framework.StartsWith("dnxcore", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (IsLinux)
|
||||
{
|
||||
// Work around issue with testing in parallel on Mono.
|
||||
testArgs = " -parallel none";
|
||||
}
|
||||
|
||||
Dnx("test" + testArgs, projectFolder);
|
||||
}
|
||||
else if (!IsLinux || !string.IsNullOrEmpty(KOREBUILD_TEST_DNXCORE))
|
||||
{
|
||||
Dnx("test" + testArgs, projectFolder, "default -runtime coreclr");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
use namespace="System"
|
||||
use namespace="System.Collections.Generic"
|
||||
use namespace="System.IO"
|
||||
use import="Files"
|
||||
|
||||
default BASE_DIR='${Directory.GetCurrentDirectory()}'
|
||||
|
||||
@{
|
||||
var srcDir = Path.Combine(BASE_DIR, "src");
|
||||
foreach (var projectFile in Files.Include(Path.Combine(srcDir, "**", "project.json")))
|
||||
{
|
||||
var binDirectory = Path.Combine(Path.GetDirectoryName(projectFile), "bin");
|
||||
if (Directory.Exists(binDirectory))
|
||||
{
|
||||
foreach (var xmlFilePath in Files.Include(Path.Combine(binDirectory, "**", "*.xml")))
|
||||
{
|
||||
var errors = 0;
|
||||
var xmlLines = File.ReadAllLines(xmlFilePath);
|
||||
for (var linesIndex = 0; linesIndex < xmlLines.Length; linesIndex++)
|
||||
{
|
||||
var xmlLine = xmlLines[linesIndex].Trim();
|
||||
if (xmlLine.StartsWith("<!--"))
|
||||
{
|
||||
// Compiler only emits comments for syntax errors.
|
||||
if (errors == 0)
|
||||
{
|
||||
Log.Warn(string.Format("Invalid documentation syntax in {0}:", xmlFilePath));
|
||||
}
|
||||
|
||||
errors++;
|
||||
Log.Warn(string.Format(" {0}: {1}", linesIndex + 1, xmlLine));
|
||||
}
|
||||
else if (xmlLine.Contains("\"!:"))
|
||||
{
|
||||
// '!' is reference string error token.
|
||||
if (errors == 0)
|
||||
{
|
||||
Log.Warn(string.Format("Invalid documentation syntax in {0}:", xmlFilePath));
|
||||
}
|
||||
|
||||
errors++;
|
||||
Log.Warn(string.Format(" {0}: {1}", linesIndex + 1, xmlLine));
|
||||
}
|
||||
}
|
||||
|
||||
if (errors != 0)
|
||||
{
|
||||
Environment.Exit(errors);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
@{/*
|
||||
|
||||
k
|
||||
Run dnx commands in your project. Executes `dnx` command.
|
||||
|
||||
command=''
|
||||
The `dnx` subcommand to execute.
|
||||
dnxDir=''
|
||||
Optional. The directory in which to execute the `dnx` command.
|
||||
dnvmUse=''
|
||||
Optional. The DNX framework to use. Suitable for a `dnvm run` or `dnvm use` command.
|
||||
*/}
|
||||
|
||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default dnxDir = '${ currentDir }'
|
||||
|
||||
default dnvmUse=''
|
||||
var dnvmPath = '${ Path.Combine(Directory.GetCurrentDirectory(), "packages", "KoreBuild", "build", "dnvm") }'
|
||||
|
||||
exec program='cmd' commandline='/C dnx ${command}' workingdir='${dnxDir}' if='!IsLinux && string.IsNullOrEmpty(dnvmUse)'
|
||||
|
||||
var cmdCommand = '/S /C ""${dnvmPath}.cmd" use ${dnvmUse} && dnx ${command}"'
|
||||
exec program='cmd' commandline='${ cmdCommand }' workingdir='${dnxDir}' if='!IsLinux && !string.IsNullOrEmpty(dnvmUse)'
|
||||
|
||||
exec program='dnx' commandline='${command}' workingdir='${dnxDir}' if='IsLinux && string.IsNullOrEmpty(dnvmUse)'
|
||||
|
||||
var envCommand = 'bash -c "source \"${dnvmPath}.sh\" && dnvm use ${dnvmUse} && dnx ${command}"'
|
||||
exec program='/usr/bin/env' commandline='${ envCommand }' workingdir='${dnxDir}' if='IsLinux && !string.IsNullOrEmpty(dnvmUse)'
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
@{/*
|
||||
|
||||
kpm-build
|
||||
Builds a project.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the project.json to build.
|
||||
|
||||
configuration=''
|
||||
Optional. The configuration to build in. Defaults to 'Debug'.
|
||||
*/}
|
||||
|
||||
default configuration = 'Debug'
|
||||
default build_options=' ${E("KOREBUILD_DNU_BUILD_OPTIONS")}'
|
||||
|
||||
@{
|
||||
if (IsBuildV2)
|
||||
{
|
||||
var projectsToPack = new List<string>();
|
||||
foreach(var arg in projectFile.Split((char)';'))
|
||||
{
|
||||
if (!arg.Contains("*"))
|
||||
{
|
||||
projectsToPack.Add(Path.GetDirectoryName(arg));
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectFolders = Files.Include(arg + "/project.json").Select(proj => Path.GetDirectoryName(proj));
|
||||
projectsToPack.AddRange(projectFolders);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
Dnu(dnuArgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectFolder=Path.GetDirectoryName(projectFile);
|
||||
var projectBin=Path.Combine(projectFolder, "bin", configuration);
|
||||
|
||||
DeleteFolder(projectBin);
|
||||
|
||||
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration);
|
||||
Dnu(dnuArgs);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
@{/*
|
||||
|
||||
kpm-pack
|
||||
Builds package from project.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the project.json to build.
|
||||
|
||||
kpmPackOutputDir=''
|
||||
Required. Base output directory.
|
||||
|
||||
configuration=''
|
||||
Optional. The configuration to build in. Defaults to 'Debug'.
|
||||
*/}
|
||||
|
||||
default configuration = 'Debug'
|
||||
default pack_options=' ${E("KOREBUILD_DNU_PACK_OPTIONS")}'
|
||||
|
||||
@{
|
||||
if (IsBuildV2)
|
||||
{
|
||||
var projectsToPack = new List<string>();
|
||||
foreach(var arg in projectFile.Split((char)';'))
|
||||
{
|
||||
if (!arg.Contains("*"))
|
||||
{
|
||||
projectsToPack.Add(Path.GetDirectoryName(arg));
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectFolders = Files.Include(arg + "/project.json").Select(proj => Path.GetDirectoryName(proj));
|
||||
projectsToPack.AddRange(projectFolders);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
Dnu(dnuArgs);
|
||||
|
||||
foreach(var projFolder in projectsToPack)
|
||||
{
|
||||
CopyFolder(
|
||||
Path.Combine(projFolder, "bin", configuration),
|
||||
Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)),
|
||||
true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
Dnu(dnuArgs);
|
||||
|
||||
CopyFolder(projectBin, Path.Combine(kpmPackOutputDir, projectName), true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
@{/*
|
||||
|
||||
kpm-publish
|
||||
Builds project. Downloads and executes k sdk tools.
|
||||
|
||||
sourcePackagesDir=''
|
||||
Required. Path to packages to install (skips symbol packages)
|
||||
|
||||
targetPackagesDir=''
|
||||
Optional. Path to publish packages.
|
||||
*/}
|
||||
|
||||
default targetPackagesDir=''
|
||||
|
||||
@{
|
||||
var packages = Directory.EnumerateFiles(sourcePackagesDir, "*.nupkg")
|
||||
.Where(p => !p.EndsWith(".symbols.nupkg"));
|
||||
}
|
||||
|
||||
dnu command='packages add ${package} ${targetPackagesDir}' each='var package in packages'
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
var oldRoslynAssemblies='${new[] { "Microsoft.CodeAnalysis.CSharp",
|
||||
"Microsoft.CodeAnalysis",
|
||||
"System.Collections.Immutable",
|
||||
"System.Reflection.Metadata.Ecma335",
|
||||
"System.Reflection.Metadata" }}'
|
||||
|
||||
var roslynAssemblies='${new[] { "Microsoft.CodeAnalysis.CSharp",
|
||||
"Microsoft.CodeAnalysis",
|
||||
"System.Collections.Immutable",
|
||||
"System.Reflection.Metadata" }}'
|
||||
|
||||
var programFilesX86='${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
|
||||
var gacutil='${Path.Combine(programFilesX86, "Microsoft SDKs", "Windows", "v8.1A", "bin", "NETFX 4.5.1 Tools", "gacutil.exe")}'
|
||||
|
||||
var windir='${Environment.GetFolderPath(Environment.SpecialFolder.Windows)}'
|
||||
var ngen='${Path.Combine(windir, "Microsoft.NET", "Framework", "v4.0.30319", "ngen.exe")}'
|
||||
|
||||
var tempRoslynPackagesDir='bin\_roslyn'
|
||||
var tempRoslynDir='bin\_roslyn\all'
|
||||
|
||||
exec program='${gacutil}' commandline='/u ${p}' each='var p in oldRoslynAssemblies'
|
||||
|
||||
nuget-install package='Microsoft.CodeAnalysis.CSharp' outputDir='${tempRoslynPackagesDir}' extra='-pre -ExcludeVersion -nocache'
|
||||
|
||||
@{
|
||||
var binaries = Files.Include(Path.Combine(tempRoslynPackagesDir, "**", "*net45*", "*.dll"));
|
||||
Directory.CreateDirectory(tempRoslynDir);
|
||||
|
||||
foreach(var file in binaries)
|
||||
{
|
||||
File.Copy(file, Path.Combine(tempRoslynDir, Path.GetFileName(file)), true);
|
||||
}
|
||||
}
|
||||
|
||||
exec program='${ngen}' commandline='install ${tempRoslynDir}\${p}.dll' each='var p in roslynAssemblies'
|
||||
exec program='${gacutil}' commandline='/i ${tempRoslynDir}\${p}.dll' each='var p in roslynAssemblies'
|
||||
|
||||
directory delete='${tempRoslynPackagesDir}'
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
use assembly="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
||||
use namespace="System.IO"
|
||||
use namespace="System.IO.Compression"
|
||||
use namespace="System.Net"
|
||||
|
||||
default binDir = '${Path.Combine(Directory.GetCurrentDirectory(), "bin")}'
|
||||
|
||||
-// When updating the node version you need to update the nodeExeSha to match what 'signtool.exe /pa /v node.exe' emits
|
||||
default nodeVer = '0.10.28'
|
||||
default npmVer = '1.4.9'
|
||||
default nodeExeSha = '628FFD6C3577068C00CEC9F6F897F0EC8F5212D9'
|
||||
default nodeDir = '${Path.Combine(binDir, "nodejs")}'
|
||||
|
||||
var nodeExe = 'node.exe'
|
||||
var npmZip = 'npm-${npmVer}.zip'
|
||||
var nodeDist = 'http://nodejs.org/dist/'
|
||||
var nodeUrl = '${nodeDist}v${nodeVer}/${nodeExe}'
|
||||
var npmUrl = '${nodeDist}npm/${npmZip}'
|
||||
var nodeInstallExePath = '${Path.Combine(nodeDir, nodeExe)}'
|
||||
var npmInstallZipPath = '${Path.Combine(nodeDir, npmZip)}'
|
||||
var nodeInstalled = '${ File.Exists(nodeInstallExePath) }'
|
||||
|
||||
default nodeGloballyInstalled = '${ !nodeInstalled && TestCommand("node", "--version") }'
|
||||
|
||||
-// Command simply fails on Linux if nodejs is not available.
|
||||
var doInstall = '${ !IsLinux && !(nodeGloballyInstalled || nodeInstalled) }'
|
||||
|
||||
@{
|
||||
if (doInstall) {
|
||||
Log.Info("Installing nodejs locally");
|
||||
|
||||
if (Directory.Exists(nodeDir))
|
||||
{
|
||||
Directory.Delete(nodeDir, recursive: true);
|
||||
}
|
||||
Directory.CreateDirectory(nodeDir);
|
||||
|
||||
// Download node
|
||||
var wc = new WebClient();
|
||||
|
||||
Log.Info(string.Format("Downloading {0} to {1}", nodeUrl, nodeInstallExePath));
|
||||
wc.DownloadFile(nodeUrl, nodeInstallExePath);
|
||||
|
||||
Log.Info(string.Format("Downloading {0} to {1}", npmUrl, npmInstallZipPath));
|
||||
wc.DownloadFile(npmUrl, npmInstallZipPath);
|
||||
|
||||
// Unzip npm
|
||||
Log.Info(string.Format("Unzipping npm to {0}", nodeDir));
|
||||
ZipFile.ExtractToDirectory(npmInstallZipPath, nodeDir);
|
||||
}
|
||||
}
|
||||
|
||||
verify-authenticode verifyFilePath='${nodeInstallExePath}' expectedHash='${nodeExeSha}' if='doInstall'
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default nodeDir = '${Path.Combine(currentDir, "bin", "node")}'
|
||||
|
||||
node-install once='installNode'
|
||||
|
||||
var nodeExeFile = '${ Path.Combine(nodeDir, "node.exe") }'
|
||||
var nodeExePath = '${ File.Exists(nodeExeFile) ? nodeExeFile : "node" }'
|
||||
|
||||
exec program='${nodeExePath}' commandline='${nodeCommand}'
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||
default npmDir = '${currentDir}'
|
||||
|
||||
node-install once='installNode'
|
||||
|
||||
var npmFile = '${ Path.Combine(nodeDir, "npm.cmd") }'
|
||||
var npmCmd = '${ File.Exists(npmFile) ? ("\"" + npmFile + "\"") : "npm" }'
|
||||
|
||||
- // Ensure nodeDir exists. npmCommand is likely a package installation targeting that directory.
|
||||
@{
|
||||
Directory.CreateDirectory(nodeDir);
|
||||
}
|
||||
|
||||
exec program='cmd' commandline='/S /C "${npmCmd} ${npmCommand}"' workingdir='${npmDir}' if='!IsLinux'
|
||||
exec program='${npmCmd}' commandline='${npmCommand}' workingdir='${npmDir}' if='IsLinux'
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
@{/*
|
||||
|
||||
nuget-local-publish
|
||||
Publishing nuget packages in the source directory to %USERPROFILE%\.nuget
|
||||
|
||||
sourcePackagesDir=''
|
||||
Directory of packages to publish to the local nuget feed
|
||||
|
||||
*/}
|
||||
|
||||
@{
|
||||
var HOME_DIR = Environment.GetEnvironmentVariable("HOME");
|
||||
if (string.IsNullOrEmpty(HOME_DIR))
|
||||
{
|
||||
HOME_DIR = Environment.GetEnvironmentVariable("HOMEDRIVE") +
|
||||
Environment.GetEnvironmentVariable("HOMEPATH");
|
||||
}
|
||||
}
|
||||
|
||||
copy sourceDir='${sourcePackagesDir}' include='*.nupkg' outputDir='${Path.Combine(HOME_DIR, ".nuget")}' overwrite='${true}'
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
use namespace="System.Threading.Tasks"
|
||||
|
||||
@{/*
|
||||
|
||||
nuget-resilient-publish
|
||||
Publishes NuGet packages with retries
|
||||
|
||||
sourcePackagesDir=''
|
||||
Required. Path to packages to push
|
||||
|
||||
nugetFeed=''
|
||||
Required. Feed to publish to.
|
||||
*/}
|
||||
|
||||
default apiKey='${Environment.GetEnvironmentVariable("APIKEY")}'
|
||||
default extra=''
|
||||
|
||||
var nugetArgs=''
|
||||
set nugetArgs='${nugetArgs} -ApiKey ${apiKey}' if='!string.IsNullOrEmpty(apiKey)'
|
||||
set nugetArgs='${nugetArgs} -Source ${nugetFeed}' if='!string.IsNullOrEmpty(nugetFeed)'
|
||||
set nugetArgs='${nugetArgs} ${extra}' if='!string.IsNullOrEmpty(extra)'
|
||||
|
||||
@{
|
||||
var packages = Directory.EnumerateFiles(sourcePackagesDir, "*.nupkg")
|
||||
.Where(p => !p.EndsWith(".symbols.nupkg"))
|
||||
.ToArray();
|
||||
|
||||
var nugetExePath = Environment.GetEnvironmentVariable("PUSH_NUGET_EXE");
|
||||
if (string.IsNullOrEmpty(nugetExePath))
|
||||
{
|
||||
nugetExePath = ".nuget/NuGet.exe";
|
||||
}
|
||||
|
||||
Parallel.ForEach(packages, package =>
|
||||
{
|
||||
var retries = 0;
|
||||
var packagePath = Path.Combine(sourcePackagesDir, package);
|
||||
start:
|
||||
try
|
||||
{
|
||||
ExecClr(nugetExePath, "push " + package + " " + nugetArgs);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (++retries == 3)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
goto start;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
macro name='ExecClr' program='string' commandline='string'
|
||||
exec-clr
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default workingDir = '${ currentDir }'
|
||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||
default rimrafLibrary = '${ Path.Combine(nodeDir, "node_modules", "rimraf", "bin.js") }'
|
||||
var rimrafInstalled = '${ File.Exists(rimrafLibrary) }'
|
||||
|
||||
default rimrafGloballyInstalled = '${ !rimrafInstalled && TestCommand("rimraf", "::") }'
|
||||
var rimrafCmd = '${ rimrafGloballyInstalled ? "rimraf" : rimrafLibrary }'
|
||||
|
||||
- // Install rimraf locally if not already installed either globally or locally; creates rimrafLibrary file if run
|
||||
var installCommand = 'install ${E("KOREBUILD_NPM_INSTALL_OPTIONS")} --prefix "${nodeDir}" rimraf'
|
||||
npm npmCommand='${installCommand}' if='!(rimrafGloballyInstalled || rimrafInstalled)' once='installRimraf'
|
||||
|
||||
- // Run rimraf
|
||||
exec program='cmd' commandline='/C ${rimrafCmd} "${rimrafDir}"' workingdir='${workingDir}' if='rimrafGloballyInstalled && !IsLinux'
|
||||
exec program='${rimrafCmd}' commandline='"${rimrafDir}"' workingdir='${workingDir}' if='rimrafGloballyInstalled && IsLinux'
|
||||
node nodeCommand='"${rimrafCmd}" "${rimrafDir}"' workingdir='${workingDir}' if='!rimrafGloballyInstalled'
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
-// Deletes a directory using robocopy such that long paths aren't an issue
|
||||
default parentDir = '${Directory.GetParent(dir).FullName}'
|
||||
default tempDir = '${Path.Combine(parentDir, "__emp_dir")}'
|
||||
default logFile = '${Path.Combine(parentDir, "robocopy-log.txt")}'
|
||||
|
||||
exec program='cmd' commandline='/C mkdir ${tempDir}'
|
||||
|
||||
@{
|
||||
var robocopyProcessStartInfo = new ProcessStartInfo {
|
||||
UseShellExecute = false,
|
||||
WorkingDirectory = dir,
|
||||
FileName = "cmd",
|
||||
Arguments = "/C robocopy " + tempDir + " " + dir + " /PURGE /NS /NC /NP /NFL /NDL /NJH /NJS /LOG:" + logFile,
|
||||
};
|
||||
|
||||
var robocopyProcess = Process.Start(robocopyProcessStartInfo);
|
||||
robocopyProcess.WaitForExit();
|
||||
|
||||
// Robocopy encodes results as a bitmap in the return code, see http://ss64.com/nt/robocopy-exit.html
|
||||
if (robocopyProcess.ExitCode >= 16)
|
||||
{
|
||||
throw new Exception(string.Format("Error {0} attempting to delete {1}, see {2} for more details", robocopyProcess.ExitCode, dir, logFile));
|
||||
}
|
||||
}
|
||||
-//exec program='cmd' commandline='/C robocopy ${tempDir} ${dir} /PURGE /NS /NC /NP /NFL /NDL /NJH /NJS /LOG:${logFile}'
|
||||
|
||||
exec program='cmd' commandline='/C rmdir ${tempDir}'
|
||||
exec program='cmd' commandline='/C rmdir ${dir}'
|
||||
exec program='cmd' commandline='/C del ${logFile}'
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
use namespace="System.Diagnostics"
|
||||
use namespace="System.IO"
|
||||
|
||||
default workingdir='${Directory.GetCurrentDirectory()}'
|
||||
default expectedHash = ''
|
||||
|
||||
@{
|
||||
Log.Info(string.Format("Verifying Authenticode signature of {0}", verifyFilePath));
|
||||
|
||||
var signToolExePaths = new [] { "C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x86\\signtool.exe", "C:\\Program Files\\Windows Kits\\8.1\\bin\\x86\\signtool.exe" };
|
||||
var signToolExe = signToolExePaths.FirstOrDefault(File.Exists);
|
||||
|
||||
if (string.IsNullOrEmpty(signToolExe))
|
||||
{
|
||||
throw new Exception("Could not find signtool.exe on this machine. Ensure Visual Studio is installed.");
|
||||
}
|
||||
|
||||
var processStartInfo = new ProcessStartInfo {
|
||||
UseShellExecute = false,
|
||||
WorkingDirectory = workingdir,
|
||||
FileName = signToolExe,
|
||||
RedirectStandardOutput = true,
|
||||
Arguments = "verify /pa /v \"" + verifyFilePath + "\"",
|
||||
};
|
||||
|
||||
var signTool = Process.Start(processStartInfo);
|
||||
var stdout = signTool.StandardOutput.ReadToEnd();
|
||||
signTool.WaitForExit();
|
||||
|
||||
if (signTool.ExitCode != 0)
|
||||
{
|
||||
File.Delete(verifyFilePath);
|
||||
throw new Exception(string.Format("The signature verification for {0} failed:{1}{2}", verifyFilePath, Environment.NewLine, stdout));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(expectedHash))
|
||||
{
|
||||
// SHA1 of the file is on 4th line and looks like: Hash of file (sha1): 628FFD6C3577068C00CEC9F6F897F0EC8F5212D9
|
||||
var lines = stdout.Split(new [] { Environment.NewLine }, StringSplitOptions.None);
|
||||
var hashLine = lines[3];
|
||||
var actualHash = hashLine.Substring(hashLine.IndexOf(":") + 1).Trim();
|
||||
|
||||
if (!string.Equals(expectedHash, actualHash, StringComparison.Ordinal))
|
||||
{
|
||||
File.Delete(verifyFilePath);
|
||||
throw new Exception(string.Format("The hash comparison for {0} failed: expected hash '{1}', actual hash '{2}'", verifyFilePath, expectedHash, actualHash));
|
||||
}
|
||||
}
|
||||
|
||||
Log.Info("Authenticode signature verified!");
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
@Echo off
|
||||
|
||||
for /f "delims=" %%i in ('PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.IO.Path]::GetTempFileName()"') do set DNVM_CMD_PATH_FILE=%%i.cmd
|
||||
|
||||
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%~dp0dnvm.ps1' %*"
|
||||
|
||||
IF EXIST %DNVM_CMD_PATH_FILE% (
|
||||
CALL %DNVM_CMD_PATH_FILE%
|
||||
DEL %DNVM_CMD_PATH_FILE%
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,50 @@
|
|||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
||||
*.jpg binary
|
||||
*.png binary
|
||||
*.gif binary
|
||||
|
||||
*.cs text=auto diff=csharp
|
||||
*.vb text=auto
|
||||
*.resx text=auto
|
||||
*.c text=auto
|
||||
*.cpp text=auto
|
||||
*.cxx text=auto
|
||||
*.h text=auto
|
||||
*.hxx text=auto
|
||||
*.py text=auto
|
||||
*.rb text=auto
|
||||
*.java text=auto
|
||||
*.html text=auto
|
||||
*.htm text=auto
|
||||
*.css text=auto
|
||||
*.scss text=auto
|
||||
*.sass text=auto
|
||||
*.less text=auto
|
||||
*.js text=auto
|
||||
*.lisp text=auto
|
||||
*.clj text=auto
|
||||
*.sql text=auto
|
||||
*.php text=auto
|
||||
*.lua text=auto
|
||||
*.m text=auto
|
||||
*.asm text=auto
|
||||
*.erl text=auto
|
||||
*.fs text=auto
|
||||
*.fsx text=auto
|
||||
*.hs text=auto
|
||||
|
||||
*.csproj text=auto
|
||||
*.vbproj text=auto
|
||||
*.fsproj text=auto
|
||||
*.dbproj text=auto
|
||||
*.sln text=auto eol=crlf
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
[Oo]bj/
|
||||
[Bb]in/
|
||||
TestResults/
|
||||
.nuget/
|
||||
*.sln.ide/
|
||||
_ReSharper.*/
|
||||
packages/
|
||||
artifacts/
|
||||
PublishProfiles/
|
||||
*.user
|
||||
*.suo
|
||||
*.cache
|
||||
*.docstates
|
||||
_ReSharper.*
|
||||
nuget.exe
|
||||
project.lock.json
|
||||
*net45.csproj
|
||||
*net451.csproj
|
||||
*k10.csproj
|
||||
*.psess
|
||||
*.vsp
|
||||
*.pidb
|
||||
*.userprefs
|
||||
*DS_Store
|
||||
*.ncrunchsolution
|
||||
*.*sdf
|
||||
*.ipch
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v2" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="AspNetVNext" value="https://www.myget.org/f/aspnetmaster/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
@echo off
|
||||
cd %~dp0
|
||||
|
||||
SETLOCAL
|
||||
SET NUGET_VERSION=latest
|
||||
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
|
||||
SET BUILDCMD_KOREBUILD_VERSION=
|
||||
SET BUILDCMD_DNX_VERSION=
|
||||
|
||||
IF EXIST %CACHED_NUGET% goto copynuget
|
||||
echo Downloading latest version of NuGet.exe...
|
||||
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
|
||||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"
|
||||
|
||||
:copynuget
|
||||
IF EXIST .nuget\nuget.exe goto restore
|
||||
md .nuget
|
||||
copy %CACHED_NUGET% .nuget\nuget.exe > nul
|
||||
|
||||
:restore
|
||||
IF EXIST packages\Sake goto getdnx
|
||||
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 -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages
|
||||
|
||||
:getdnx
|
||||
IF "%BUILDCMD_DNX_VERSION%"=="" (
|
||||
SET BUILDCMD_DNX_VERSION=latest
|
||||
)
|
||||
IF "%SKIP_DNX_INSTALL%"=="" (
|
||||
CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default
|
||||
CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default
|
||||
) ELSE (
|
||||
CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
|
||||
)
|
||||
|
||||
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if test `uname` = Darwin; then
|
||||
cachedir=~/Library/Caches/KBuild
|
||||
else
|
||||
if [ -z $XDG_DATA_HOME ]; then
|
||||
cachedir=$HOME/.local/share
|
||||
else
|
||||
cachedir=$XDG_DATA_HOME;
|
||||
fi
|
||||
fi
|
||||
mkdir -p $cachedir
|
||||
nugetVersion=latest
|
||||
cachePath=$cachedir/nuget.$nugetVersion.exe
|
||||
|
||||
url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe
|
||||
|
||||
if test ! -f $cachePath; then
|
||||
wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null
|
||||
fi
|
||||
|
||||
if test ! -e .nuget; then
|
||||
mkdir .nuget
|
||||
cp $cachePath .nuget/nuget.exe
|
||||
fi
|
||||
|
||||
if test ! -d packages/Sake; then
|
||||
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
|
||||
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
|
||||
source packages/KoreBuild/build/dnvm.sh
|
||||
fi
|
||||
|
||||
if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
|
||||
dnvm install latest -runtime coreclr -alias default
|
||||
dnvm install default -runtime mono -alias default
|
||||
else
|
||||
dnvm use default -runtime mono
|
||||
fi
|
||||
|
||||
mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
||||
|
|
@ -57,6 +57,7 @@ var buildTarget = "compile"
|
|||
#pack
|
||||
directory create='${TARGET_DIR}'
|
||||
nuget-pack nuspecFile='${Path.Combine(BASE_DIR, "KoreBuild.nuspec")}' packageVersion='${VERSION}' outputDir='${TARGET_DIR}'
|
||||
nuget-pack nuspecFile='${Path.Combine(BASE_DIR, "KoreBuild-dotnet", "KoreBuild-dotnet.nuspec")}' packageVersion='${VERSION}' outputDir='${TARGET_DIR}'
|
||||
|
||||
#pack-install .pack
|
||||
nuget-local-publish sourcePackagesDir='${TARGET_DIR}'
|
||||
|
|
|
|||
Loading…
Reference in New Issue