Support for dotnet
This commit is contained in:
parent
7043b16980
commit
1ccc412caf
|
|
@ -12,4 +12,4 @@
|
|||
<files>
|
||||
<file src="build\*.*" target="build" />
|
||||
</files>
|
||||
</package>
|
||||
</package>
|
||||
|
|
|
|||
|
|
@ -25,12 +25,4 @@ functions
|
|||
return "t" + DateTime.UtcNow.ToString("yyMMddHHmmss");
|
||||
}
|
||||
}
|
||||
|
||||
bool IsBuildV2
|
||||
{
|
||||
get
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("KOREBUILD_BUILD_V2") == "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
<#@ 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;
|
||||
}
|
||||
}
|
||||
#>
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
@{/*
|
||||
|
||||
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,24 @@
|
|||
@{/*
|
||||
|
||||
dotnet-compile
|
||||
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 compile_options=' ${E("KOREBUILD_DOTNET_COMPILE_OPTIONS")}'
|
||||
|
||||
@{
|
||||
var projectFolder=Path.GetDirectoryName(projectFile);
|
||||
var projectBin=Path.Combine(projectFolder, "bin", configuration);
|
||||
|
||||
DeleteFolder(projectBin);
|
||||
|
||||
var dotnetArgs=string.Format("compile{0} {1} --configuration {2}", compile_options, projectFolder, configuration);
|
||||
Dotnet(dotnetArgs);
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
@{/*
|
||||
|
||||
dotnet-pack
|
||||
Builds package from project.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the project.json to build.
|
||||
|
||||
dotnetPackOutputDir=''
|
||||
Required. Base output directory.
|
||||
|
||||
configuration=''
|
||||
Optional. The configuration to build in. Defaults to 'Debug'.
|
||||
*/}
|
||||
|
||||
default configuration = 'Debug'
|
||||
default pack_options=' ${E("KOREBUILD_DOTNET_PACK_OPTIONS")}'
|
||||
|
||||
@{
|
||||
var projectFolder=Path.GetDirectoryName(projectFile);
|
||||
var projectName=Path.GetFileName(projectFolder);
|
||||
var projectBin=Path.Combine(projectFolder, "bin", configuration);
|
||||
|
||||
DeleteFolder(projectBin);
|
||||
|
||||
var dotnetArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration);
|
||||
Dotnet(dotnetArgs);
|
||||
|
||||
CopyFolder(projectBin, Path.Combine(dotnetPackOutputDir, projectName), true);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
@{/*
|
||||
|
||||
kpm-publish
|
||||
Builds project. Downloads and executes k sdk tools.
|
||||
dotnet-publish
|
||||
Builds project. Downloads and executes dotnet sdk tools.
|
||||
|
||||
sourcePackagesDir=''
|
||||
Required. Path to packages to install (skips symbol packages)
|
||||
|
|
@ -17,4 +17,4 @@ default targetPackagesDir=''
|
|||
.Where(p => !p.EndsWith(".symbols.nupkg"));
|
||||
}
|
||||
|
||||
dnu command='packages add ${package} ${targetPackagesDir}' each='var package in packages'
|
||||
dotnet command='packages add ${package} ${targetPackagesDir}' each='var package in packages'
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
@{/*
|
||||
|
||||
dotnet-restore
|
||||
Restores nuget packages required for dotnet projects. Downloads and executes dotnet sdk tools.
|
||||
|
||||
restoreDir=''
|
||||
Optional. The directory in which to execute the dnu restore command.
|
||||
*/}
|
||||
|
||||
default currentDir = '${ Directory.GetCurrentDirectory() }'
|
||||
default restoreDir = '${ currentDir }'
|
||||
|
||||
default restore_options=' ${ E("KOREBUILD_DOTNET_RESTORE_OPTIONS") } ${ IsLinux ? string.Empty : "--parallel" }'
|
||||
|
||||
dotnet command='restore${ restore_options }' workingDir='${ restoreDir }'
|
||||
|
|
@ -6,7 +6,7 @@ default KOREBUILD_TEST_DNXCORE='${E("KOREBUILD_TEST_DNXCORE")}'
|
|||
|
||||
@{/*
|
||||
|
||||
k-test
|
||||
dotnet-test
|
||||
Run unit tests in your project.
|
||||
|
||||
projectFile=''
|
||||
|
|
@ -50,6 +50,7 @@ projectFile=''
|
|||
{
|
||||
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
|
||||
|
||||
Console.WriteLine("!!! Tests skipped for " + projectName);
|
||||
if (!framework.StartsWith("dnxcore", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (IsLinux)
|
||||
|
|
@ -58,11 +59,11 @@ projectFile=''
|
|||
testArgs = " -parallel none";
|
||||
}
|
||||
|
||||
Dnx("test" + testArgs, projectFolder);
|
||||
// Dotnet("test" + testArgs, projectFolder);
|
||||
}
|
||||
else if (!IsLinux || !string.IsNullOrEmpty(KOREBUILD_TEST_DNXCORE))
|
||||
{
|
||||
Dnx("test" + testArgs, projectFolder, "default -runtime coreclr");
|
||||
// Dotnet("test" + testArgs, projectFolder, "default -runtime coreclr");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
@{/*
|
||||
|
||||
dotnet
|
||||
Run dotnet commands in your project. Executes `dotnet` command.
|
||||
|
||||
command=''
|
||||
The `dotnet` subcommand to execute.
|
||||
dotnetDir=''
|
||||
Optional. The directory in which to execute the `dotnet` command.
|
||||
*/}
|
||||
|
||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||
default dotnetDir = '${ currentDir }'
|
||||
|
||||
exec program='dotnet' commandline='${command}' workingdir='${dotnetDir}'
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
@{/*
|
||||
|
||||
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 }'
|
||||
|
|
@ -36,8 +36,6 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
Configuration = "Debug";
|
||||
E("Configuration", Configuration);
|
||||
}
|
||||
|
||||
Log.Info("Build v2: " + IsBuildV2);
|
||||
}
|
||||
|
||||
#restore-npm-modules
|
||||
|
|
@ -71,7 +69,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
#deep-clean .clean-npm-modules .clean-bin-folder description='Clean folders that may cause problems for `git clean`.'
|
||||
|
||||
#repo-initialize target='initialize'
|
||||
k-restore
|
||||
dotnet-restore
|
||||
|
||||
#target-dir-clean target='clean'
|
||||
@{
|
||||
|
|
@ -94,16 +92,16 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
|
||||
#ci-deep-clean .deep-clean target='clean' if='IsTeamCity'
|
||||
|
||||
#build-compile target='compile' if='!IsBuildV2 && Directory.Exists("src")'
|
||||
#build-compile target='compile' if='Directory.Exists("src")'
|
||||
@{
|
||||
var projectFiles = Files.Include("src/**/project.json").ToList();
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
||||
Parallel.ForEach(projectFiles, projectFile => DotnetPack(projectFile, BUILD_DIR, Configuration));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
||||
projectFiles.ForEach(projectFile => DotnetPack(projectFile, BUILD_DIR, Configuration));
|
||||
}
|
||||
|
||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
||||
|
|
@ -112,45 +110,6 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
}
|
||||
}
|
||||
|
||||
#build-compile target='compile' if='IsBuildV2'
|
||||
@{
|
||||
// If the src folder, build and create the packages
|
||||
if (Directory.Exists("src"))
|
||||
{
|
||||
// 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"))}'
|
||||
|
|
@ -203,7 +162,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
}
|
||||
|
||||
#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")}'
|
||||
dotnet-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")'
|
||||
|
|
@ -211,24 +170,24 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
var projectFiles = Files.Include("test/**/project.json").Exclude("**/bin/*/app/project.json").ToList();
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnxTest(projectFile, testParallel: true));
|
||||
Parallel.ForEach(projectFiles, projectFile => DotnetTest(projectFile, testParallel: true));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFiles.ForEach(projectFile => DnxTest(projectFile, testParallel: false));
|
||||
projectFiles.ForEach(projectFile => DotnetTest(projectFile, testParallel: false));
|
||||
}
|
||||
}
|
||||
|
||||
#build-samples target='test' if='!IsBuildV2 && Directory.Exists("samples")'
|
||||
#build-samples target='test' if='Directory.Exists("samples")'
|
||||
@{
|
||||
var projectFiles = Files.Include("samples/**/project.json").ToList();
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnuBuild(projectFile, Configuration));
|
||||
Parallel.ForEach(projectFiles, projectFile => DotnetCompile(projectFile, Configuration));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFiles.ForEach(projectFile => DnuBuild(projectFile, Configuration));
|
||||
projectFiles.ForEach(projectFile => DotnetCompile(projectFile, Configuration));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,9 +219,9 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
|||
#--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_DOTNET_BUILD_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_DOTNET_PACK_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_DOTNET_RESTORE_OPTIONS", "--quiet");
|
||||
AddToE("KOREBUILD_NPM_INSTALL_OPTIONS", "--quiet");
|
||||
Quiet = true;
|
||||
}
|
||||
|
|
@ -370,26 +329,23 @@ functions @{
|
|||
macro name='Exec' program='string' commandline='string'
|
||||
exec
|
||||
|
||||
macro name='Dnu' command='string'
|
||||
dnu
|
||||
macro name='Dotnet' command='string'
|
||||
dotnet
|
||||
|
||||
macro name='Dnx' command='string' dnxDir='string'
|
||||
k
|
||||
|
||||
macro name='Dnx' command='string' dnxDir='string' dnvmUse='string'
|
||||
k
|
||||
macro name='Dotnet' command='string' dotnetDir='string'
|
||||
dotnet
|
||||
|
||||
macro name="UpdateResx" resxFile='string'
|
||||
k-generate-resx
|
||||
|
||||
macro name="DnxTest" projectFile='string' testParallel='bool'
|
||||
k-test
|
||||
macro name="DotnetTest" projectFile='string' testParallel='bool'
|
||||
dotnet-test
|
||||
|
||||
macro name="DnuBuild" projectFile='string' configuration='string'
|
||||
kpm-build
|
||||
macro name="DotnetCompile" projectFile='string' configuration='string'
|
||||
dotnet-compile
|
||||
|
||||
macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string'
|
||||
kpm-pack
|
||||
macro name="DotnetPack" projectFile='string' dotnetPackOutputDir='string' configuration='string'
|
||||
dotnet-pack
|
||||
|
||||
macro name="DeleteFolder" delete='string'
|
||||
directory
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
@{/*
|
||||
|
||||
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)'
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
@{/*
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
@{/*
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,10 +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
|
||||
for /f "delims=" %%i in ('PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.IO.Path]::GetTempFileName()"') do set INSTALL_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' %*"
|
||||
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%INSTALL_CMD_PATH_FILE%';& '%~dp0install.ps1' %*"
|
||||
|
||||
IF EXIST %DNVM_CMD_PATH_FILE% (
|
||||
CALL %DNVM_CMD_PATH_FILE%
|
||||
DEL %DNVM_CMD_PATH_FILE%
|
||||
IF EXIST %INSTALL_CMD_PATH_FILE% (
|
||||
CALL %INSTALL_CMD_PATH_FILE%
|
||||
DEL %INSTALL_CMD_PATH_FILE%
|
||||
)
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
$ErrorActionPreference="Stop"
|
||||
$ProgressPreference="SilentlyContinue"
|
||||
|
||||
$Feed="https://dotnetcli.blob.core.windows.net/dotnet"
|
||||
$Channel="dev"
|
||||
$DotNetFileName="dotnet-win-x64.latest.zip"
|
||||
$DotNetUrl="$Feed/$Channel/Binaries/Latest"
|
||||
|
||||
function say($str)
|
||||
{
|
||||
Write-Host "dotnet_install: $str"
|
||||
}
|
||||
|
||||
$InstallDir = $env:DOTNET_INSTALL_DIR
|
||||
if (!$InstallDir) {
|
||||
$InstallDir = "$env:LocalAppData\Microsoft\dotnet"
|
||||
}
|
||||
|
||||
say "Preparing to install .NET Tools to $InstallDir"
|
||||
|
||||
# Check if we need to bother
|
||||
$LocalFile = "$InstallDir\cli\.version"
|
||||
if (Test-Path $LocalFile)
|
||||
{
|
||||
$LocalData = @(cat $LocalFile)
|
||||
$LocalHash = $LocalData[0].Trim()
|
||||
$LocalVersion = $LocalData[1].Trim()
|
||||
if ($LocalVersion -and $LocalHash)
|
||||
{
|
||||
$RemoteResponse = Invoke-WebRequest -UseBasicParsing "$Feed/$Channel/dnvm/latest.win.version"
|
||||
$RemoteData = @([Text.Encoding]::UTF8.GetString($RemoteResponse.Content).Split());
|
||||
$RemoteHash = $RemoteData[0].Trim()
|
||||
$RemoteVersion = $RemoteData[1].Trim()
|
||||
|
||||
if (!$RemoteVersion -or !$RemoteHash) {
|
||||
throw "Invalid response from feed"
|
||||
}
|
||||
|
||||
say "Latest version: $RemoteVersion"
|
||||
say "Local Version: $LocalVersion"
|
||||
|
||||
if($LocalHash -eq $RemoteHash)
|
||||
{
|
||||
say "You already have the latest version"
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Set up the install location
|
||||
if (!(Test-Path $InstallDir)) {
|
||||
mkdir $InstallDir | Out-Null
|
||||
}
|
||||
|
||||
# De-powershell the path before passing to .NET APIs
|
||||
$InstallDir = Convert-Path $InstallDir
|
||||
|
||||
say "Downloading $DotNetFileName from $DotNetUrl"
|
||||
$resp = Invoke-WebRequest -UseBasicParsing "$DotNetUrl/$DotNetFileName" -OutFile "$InstallDir\$DotNetFileName"
|
||||
|
||||
say "Extracting zip"
|
||||
|
||||
# Create the destination
|
||||
if (Test-Path "$InstallDir\cli_new") {
|
||||
del -rec -for "$InstallDir\cli_new"
|
||||
}
|
||||
mkdir "$InstallDir\cli_new" | Out-Null
|
||||
|
||||
Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$InstallDir\$DotNetFileName", "$InstallDir\cli_new")
|
||||
|
||||
# Replace the old installation (if any)
|
||||
if (Test-Path "$InstallDir\cli") {
|
||||
del -rec -for "$InstallDir\cli"
|
||||
}
|
||||
mv "$InstallDir\cli_new" "$InstallDir\cli"
|
||||
|
||||
# Clean the zip
|
||||
if (Test-Path "$InstallDir\$DotNetFileName") {
|
||||
del -for "$InstallDir\$DotNetFileName"
|
||||
}
|
||||
|
||||
say "The .NET Tools have been installed to $InstallDir\cli!"
|
||||
|
||||
# New layout
|
||||
say "Add '$InstallDir\cli\bin' to your PATH to use dotnet"
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
# Note: This script should be compatible with the dash shell used in Ubuntu. So avoid bashisms! See https://wiki.ubuntu.com/DashAsBinSh for more info
|
||||
|
||||
# This is a herestring Everything from the line AFTER the "read" until the line containing ONLY "EOF" is part of the string
|
||||
# The quotes around "EOF" ensure that $ is not interpreted as a variable expansion. The indentation of the herestring must be
|
||||
# kept exactly consistent
|
||||
LINK_SCRIPT_CONTENT=$(cat <<-"EOF"
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
if [ -z "$DOTNET_TOOLS" ]; then
|
||||
# We should be in $PREFIX/bin, so just get the directory above us.
|
||||
PREFIX="$( cd -P "$DIR/.." && pwd)"
|
||||
|
||||
# The tools are in $PREFIX/share/dotnet/cli by default
|
||||
DOTNET_TOOLS_DEFAULT=$PREFIX/share/dotnet/cli
|
||||
|
||||
# Check the default location
|
||||
if [ -d "$DOTNET_TOOLS_DEFAULT" ]; then
|
||||
export DOTNET_TOOLS=$DOTNET_TOOLS_DEFAULT
|
||||
else
|
||||
echo "error: the .NET tools installation appears to be corrupt!" 1>&2
|
||||
echo "error: specifically, the tools could not be located in the $DOTNET_TOOLS_DEFAULT directory" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
MY_NAME=$(basename ${BASH_SOURCE[0]})
|
||||
MY_TARGET=$DOTNET_TOOLS/bin/$MY_NAME
|
||||
|
||||
if [ ! -e "$MY_TARGET" ]; then
|
||||
echo "error: the tool $MY_TARGET cannot be found" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$MY_TARGET" ]; then
|
||||
echo "error: the tool $MY_TARGET is not executable" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$MY_TARGET" "$@"
|
||||
EOF
|
||||
)
|
||||
|
||||
#set default prefix (PREFIX is a fairly standard env-var, but we also want to allow the use the specific "DOTNET_INSTALL_DIR" one)
|
||||
if [ ! -z "$DOTNET_INSTALL_DIR" ]; then
|
||||
PREFIX=$DOTNET_INSTALL_DIR
|
||||
elif [ -z "$PREFIX" ]; then
|
||||
PREFIX=/usr/local
|
||||
fi
|
||||
|
||||
#setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors.
|
||||
#See if stdout is a terminal
|
||||
if [ -t 1 ]; then
|
||||
# see if it supports colors
|
||||
ncolors=$(tput colors)
|
||||
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
|
||||
bold="$(tput bold)"
|
||||
normal="$(tput sgr0)"
|
||||
black="$(tput setaf 0)"
|
||||
red="$(tput setaf 1)"
|
||||
green="$(tput setaf 2)"
|
||||
yellow="$(tput setaf 3)"
|
||||
blue="$(tput setaf 4)"
|
||||
magenta="$(tput setaf 5)"
|
||||
cyan="$(tput setaf 6)"
|
||||
white="$(tput setaf 7)"
|
||||
fi
|
||||
fi
|
||||
|
||||
#Standardise OS name to what is put into filenames of the tarballs.
|
||||
current_os()
|
||||
{
|
||||
local uname=$(uname)
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
echo "osx"
|
||||
else
|
||||
echo "linux"
|
||||
fi
|
||||
}
|
||||
|
||||
machine_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
#Not 100% sure at the moment that these checks are enough. We might need to take version into account or do something
|
||||
#more complicated. This seemed like a good beginning though as it should catch the default "clean" machine case and give
|
||||
#people an appropriate hint.
|
||||
check_pre_reqs() {
|
||||
local os=$(current_os)
|
||||
local _failing=false;
|
||||
|
||||
if [ "$DOTNET_INSTALL_SKIP_PREREQS" = "1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$os" = "linux" ]; then
|
||||
[ -z "$(ldconfig -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true
|
||||
fi
|
||||
|
||||
if [ "$_failing" = true ]; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
say_err() {
|
||||
printf "%b\n" "${red}dotnet_install: Error: $1${normal}" >&2
|
||||
}
|
||||
|
||||
say() {
|
||||
printf "%b\n" "dotnet_install: $1"
|
||||
}
|
||||
|
||||
make_link() {
|
||||
local target_name=$1
|
||||
local dest=$PREFIX/bin/$target_name
|
||||
say "Linking $dest -> $PREFIX/share/dotnet/cli/$target_name"
|
||||
if [ -e $dest ]; then
|
||||
rm $dest
|
||||
fi
|
||||
|
||||
[ -d "$PREFIX/bin" ] || mkdir -p $PREFIX/bin
|
||||
|
||||
echo "$LINK_SCRIPT_CONTENT" > $dest
|
||||
|
||||
# Make mode: rwxr-xr-x
|
||||
chmod 755 $dest
|
||||
}
|
||||
|
||||
install_dotnet()
|
||||
{
|
||||
if ! machine_has "curl"; then
|
||||
printf "%b\n" "${red}curl is required to download dotnet. Install curl to proceed. ${normal}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
say "Preparing to install .NET Tools to $PREFIX"
|
||||
|
||||
if [ -e "$PREFIX/share/dotnet/cli/dotnet" ] && [ ! -w "$PREFIX/share/dotnet/cli/dotnet" ]; then
|
||||
say_err "dotnet cli is already installed and not writeable. Use 'curl -sSL <url> | sudo sh' to force install."
|
||||
say_err "If you have previously installed the cli using a package manager or installer then that is why it is write protected, and you need to run sudo to install the new version."
|
||||
say_err "Alternatively, removing the '$PREFIX/share/dotnet' directory completely before running the script will also resolve the issue."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! check_pre_reqs; then
|
||||
say_err "Ending install due to missing pre-reqs"
|
||||
return 1;
|
||||
fi
|
||||
local os=$(current_os)
|
||||
local installLocation="$PREFIX/share/dotnet"
|
||||
local dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/dev/Binaries/Latest"
|
||||
local dotnet_filename="dotnet-$os-x64.latest.tar.gz"
|
||||
|
||||
if [ "$RELINK" = "0" ]; then
|
||||
if [ "$FORCE" = "0" ]; then
|
||||
# Check if we need to bother
|
||||
local remoteData="$(curl -s https://dotnetcli.blob.core.windows.net/dotnet/dev/dnvm/latest.$os.version)"
|
||||
[ $? != 0 ] && say_err "Unable to determine latest version." && return 1
|
||||
|
||||
local remoteVersion=$(IFS="\n" && echo $remoteData | tail -n 1)
|
||||
local remoteHash=$(IFS="\n" && echo $remoteData | head -n 1)
|
||||
|
||||
local localVersion=$(tail -n 1 "$installLocation/cli/.version" 2>/dev/null)
|
||||
[ -z $localVersion ] && localVersion='<none>'
|
||||
local localHash=$(head -n 1 "$installLocation/cli/.version" 2>/dev/null)
|
||||
|
||||
say "Latest Version: $remoteVersion"
|
||||
say "Local Version: $localVersion"
|
||||
|
||||
[ "$remoteHash" = "$localHash" ] && say "${green}You already have the latest version.${normal}" && return 0
|
||||
fi
|
||||
|
||||
#This should noop if the directory already exists.
|
||||
mkdir -p $installLocation
|
||||
|
||||
say "Downloading $dotnet_filename from $dotnet_url"
|
||||
|
||||
#Download file and check status code, error and return if we cannot download a cli tar.
|
||||
local httpResult=$(curl -L -D - "$dotnet_url/$dotnet_filename" -o "$installLocation/$dotnet_filename" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
||||
[ $httpResult -ne "302" ] && [ $httpResult -ne "200" ] && echo "${Red}HTTP Error $httpResult fetching the dotnet cli from $dotnet_url ${RCol}" && return 1
|
||||
|
||||
say "Extracting tarball"
|
||||
#Any of these could fail for various reasons so we will check each one and end the script there if it fails.
|
||||
rm -rf "$installLocation/cli_new"
|
||||
mkdir "$installLocation/cli_new"
|
||||
[ $? != 0 ] && say_err "failed to clean and create temporary cli directory to extract into" && return 1
|
||||
|
||||
tar -xzf "$installLocation/$dotnet_filename" -C "$installLocation/cli_new"
|
||||
[ $? != 0 ] && say_err "failed to extract tar" && return 1
|
||||
|
||||
say "Moving new CLI into install location and symlinking"
|
||||
|
||||
rm -rf "$installLocation/cli"
|
||||
[ $? != 0 ] && say_err "Failed to clean current dotnet install" && return 1
|
||||
|
||||
mv "$installLocation/cli_new" "$installLocation/cli"
|
||||
elif [ ! -e "$installLocation/cli" ]; then
|
||||
say_err "${red}cannot relink dotnet, it is not installed in $PREFIX!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
for f in $(find "$installLocation/cli" -regex ".*/dotnet[a-z\-]*$")
|
||||
do
|
||||
local baseFile=$(basename $f)
|
||||
make_link $baseFile
|
||||
done
|
||||
|
||||
if [ -e "$installLocation/$dotnet_filename" ]; then
|
||||
say "Cleaning $dotnet_filename"
|
||||
if ! rm "$installLocation/$dotnet_filename"; then
|
||||
say_err "Failed to delete tar after extracting."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
FORCE=0
|
||||
RELINK=0
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
if [ $1 = "-f" ] || [ $1 = "--force" ]; then
|
||||
FORCE=1
|
||||
elif [ $1 = "-r" ] || [ $1 = "--relink" ]; then
|
||||
RELINK=1
|
||||
elif [ $1 = "-?" ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then
|
||||
echo ".NET Tools Installer"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " $0 [-f]"
|
||||
echo " $0 -r"
|
||||
echo " $0 -h"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -f Force reinstallation even if you have the most recent version installed"
|
||||
echo " -r Don't re-download, just recreate the links in $PREFIX/bin"
|
||||
echo " -h Show this help message"
|
||||
echo ""
|
||||
echo "The PREFIX environment variable can be used to affect the root installation directory"
|
||||
exit 0
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
install_dotnet
|
||||
|
|
@ -2,6 +2,9 @@
|
|||
cd %~dp0
|
||||
|
||||
SETLOCAL
|
||||
SET REPO_FOLDER=%CD%
|
||||
SET DOTNET_INSTALL_DIR=%REPO_FOLDER%\packages
|
||||
|
||||
SET NUGET_VERSION=latest
|
||||
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
|
||||
SET BUILDCMD_KOREBUILD_VERSION=
|
||||
|
|
@ -13,28 +16,27 @@ 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
|
||||
IF EXIST .nuget\nuget.exe goto getsake
|
||||
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
|
||||
)
|
||||
:getsake
|
||||
IF EXIST packages\Sake goto skipgetsake
|
||||
.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages
|
||||
:skipgetsake
|
||||
|
||||
: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
|
||||
:getkorebuild
|
||||
IF EXIST packages\KoreBuild-dotnet goto skipgetkorebuild
|
||||
IF "%BUILDCMD_KOREBUILD_VERSION%"=="" (
|
||||
.nuget\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o packages -nocache -pre
|
||||
) ELSE (
|
||||
CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
|
||||
.nuget\nuget.exe install KoreBuild-dotnet -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre
|
||||
)
|
||||
:skipgetkorebuild
|
||||
|
||||
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*
|
||||
:getdotnet
|
||||
SET DOTNET_INSTALL_DIR=packages
|
||||
CALL packages\KoreBuild-dotnet\build\install.cmd
|
||||
SET PATH=%DOTNET_INSTALL_DIR%\cli\bin;%PATH%
|
||||
|
||||
packages\Sake\tools\Sake.exe -I packages\KoreBuild-dotnet\build -f makefile.shade %*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
REPO_FOLDER="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
export DOTNET_INSTALL_DIR=$REPO_FOLDER/packages/cli
|
||||
|
||||
if test `uname` = Darwin; then
|
||||
cachedir=~/Library/Caches/KBuild
|
||||
else
|
||||
|
|
@ -25,19 +35,13 @@ if test ! -e .nuget; then
|
|||
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
|
||||
if test ! -d packages/KoreBuild-dotnet; then
|
||||
mono .nuget/nuget.exe install KoreBuild-dotnet -ExcludeVersion -o packages -nocache -pre
|
||||
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 "$@"
|
||||
packages/KoreBuild-dotnet/build/install.sh
|
||||
export PATH=$DOTNET_INSTALL_DIR/bin/:$PATH
|
||||
mono packages/Sake/tools/Sake.exe -I packages/KoreBuild-dotnet/build -f makefile.shade "$@"
|
||||
|
|
|
|||
Loading…
Reference in New Issue