コード例 #1
0
        private void GenerateBatchFiles()
        {
            string relativeAppBase;

            if (NoSource)
            {
                relativeAppBase = string.Format(@"{0}\{1}\{2}\{3}\{4}",
                                                AppRootName,
                                                "packages",
                                                _project.Name,
                                                _project.Version,
                                                "root");
            }
            else
            {
                relativeAppBase = string.Format(@"{0}\{1}\{2}", AppRootName, "src", _project.Name);
            }

            const string template = @"
@""{0}{1}.exe"" --appbase ""%~dp0{2}"" Microsoft.Framework.ApplicationHost {3} %*
";

            foreach (var commandName in _project.Commands.Keys)
            {
                var runtimeFolder = string.Empty;
                if (Runtimes.Any())
                {
                    runtimeFolder = string.Format(@"%~dp0{0}\packages\{1}\bin\", AppRootName, Runtimes.First().Name);
                }

                File.WriteAllText(
                    Path.Combine(OutputPath, commandName + ".cmd"),
                    string.Format(template, runtimeFolder, Runtime.Constants.BootstrapperExeName, relativeAppBase, commandName));
            }
        }
コード例 #2
0
        public void Emit()
        {
            Reports.Quiet.WriteLine("Copying to output path {0}", OutputPath);

            var mainProject = Projects.Single(project => project.Name == _project.Name);

            foreach (var deploymentPackage in Packages)
            {
                deploymentPackage.Emit(this);
            }

            foreach (var deploymentProject in Projects)
            {
                deploymentProject.Emit(this);
            }

            foreach (var deploymentRuntime in Runtimes)
            {
                deploymentRuntime.Emit(this);
            }

            mainProject.PostProcess(this);

            WriteGlobalJson();

            string relativeAppBase;

            if (NoSource)
            {
                relativeAppBase = Path.Combine(AppRootName, "packages", _project.Name,
                                               _project.Version.ToString(), "root");
            }
            else
            {
                relativeAppBase = Path.Combine(AppRootName, "src", _project.Name);
            }

            foreach (var commandName in _project.Commands.Keys)
            {
                const string template1 = @"
@""%~dp0{3}\packages\{2}\bin\klr.exe"" --appbase ""%~dp0{1}"" Microsoft.Framework.ApplicationHost {0} %*
";
                const string template2 = @"
@klr.exe --appbase ""%~dp0{1}"" Microsoft.Framework.ApplicationHost {0} %*
";
                if (Runtimes.Any())
                {
                    File.WriteAllText(
                        Path.Combine(OutputPath, commandName + ".cmd"),
                        string.Format(template1, commandName, relativeAppBase, Runtimes.First().Name, AppRootName));
                }
                else
                {
                    File.WriteAllText(
                        Path.Combine(OutputPath, commandName + ".cmd"),
                        string.Format(template2, commandName, relativeAppBase));
                }
            }
        }
コード例 #3
0
ファイル: PublishRoot.cs プロジェクト: pgrudzien12/dnx
        private void GenerateBashScripts()
        {
            string relativeAppBase;

            if (NoSource)
            {
                relativeAppBase = string.Format("{0}/{1}/{2}/{3}/{4}", AppRootName, "packages", _project.Name,
                                                _project.Version.ToString(), "root");
            }
            else
            {
                relativeAppBase = string.Format("{0}/{1}/{2}", AppRootName, "src", _project.Name);
            }

            const string template = @"#!/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 )""

export SET {0}=""$DIR/{1}""

exec ""{2}{3}"" --appbase ""${0}"" Microsoft.Dnx.ApplicationHost --configuration {4} {5} ""$@""";

            foreach (var commandName in _project.Commands.Keys)
            {
                var runtimeFolder = string.Empty;
                if (Runtimes.Any())
                {
                    runtimeFolder = string.Format(@"$DIR/{0}/runtimes/{1}/bin/",
                                                  AppRootName, Runtimes.First().Name);
                }

                var scriptPath = Path.Combine(OutputPath, commandName);
                File.WriteAllText(scriptPath,
                                  string.Format(template,
                                                EnvironmentNames.AppBase,
                                                relativeAppBase,
                                                runtimeFolder,
                                                Runtime.Constants.BootstrapperExeName,
                                                Configuration,
                                                commandName).Replace("\r\n", "\n"));

                if (!RuntimeEnvironmentHelper.IsWindows)
                {
                    if (!FileOperationUtils.MarkExecutable(scriptPath))
                    {
                        Reports.Information.WriteLine("Failed to mark {0} as executable".Yellow(), scriptPath);
                    }
                }
            }
        }
コード例 #4
0
        private void GenerateBatchFiles()
        {
            string relativeAppBase;

            if (NoSource)
            {
                relativeAppBase = $@"packages\{_project.Name}\{_project.Version}\root";
            }
            else
            {
                relativeAppBase = $@"src\{_project.Name}";
            }

            foreach (var commandName in _project.Commands.Keys)
            {
                var runtimeFolder = string.Empty;
                if (Runtimes.Any())
                {
                    runtimeFolder = Runtimes.First().Name;
                }

                var cmdPath   = Path.Combine(OutputPath, AppRootName, commandName + ".cmd");
                var cmdScript = $@"
@echo off
SET DNX_FOLDER={runtimeFolder}
SET ""LOCAL_DNX=%~dp0runtimes\%DNX_FOLDER%\bin\{Runtime.Constants.BootstrapperExeName}.exe""

IF EXIST %LOCAL_DNX% (
  SET ""DNX_PATH=%LOCAL_DNX%""
)

for %%a in (%DNX_HOME%) do (
    IF EXIST %%a\runtimes\%DNX_FOLDER%\bin\{Runtime.Constants.BootstrapperExeName}.exe (
        SET ""HOME_DNX=%%a\runtimes\%DNX_FOLDER%\bin\{Runtime.Constants.BootstrapperExeName}.exe""
        goto :continue
    )
)

:continue

IF ""%HOME_DNX%"" NEQ """" (
  SET ""DNX_PATH=%HOME_DNX%""
)

IF ""%DNX_PATH%"" == """" (
  SET ""DNX_PATH={Runtime.Constants.BootstrapperExeName}.exe""
)

@""%DNX_PATH%"" --project ""%~dp0{relativeAppBase}"" --configuration {Configuration} {commandName} %*
";
                File.WriteAllText(cmdPath, cmdScript);
            }
        }
コード例 #5
0
        private void GenerateBashScripts()
        {
            string relativeAppBase;

            if (NoSource)
            {
                relativeAppBase = $"packages/{_project.Name}/{_project.Version}/root";
            }
            else
            {
                relativeAppBase = $"src/{_project.Name}";
            }

            foreach (var commandName in _project.Commands.Keys)
            {
                var runtimeFolder = string.Empty;
                if (Runtimes.Any())
                {
                    var runtime = Runtimes.First().Name;
                    runtimeFolder = $@"$DIR/runtimes/{runtime}/bin/";
                }

                var scriptPath     = Path.Combine(OutputPath, AppRootName, commandName);
                var scriptContents = $@"#!/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 )""

exec ""{runtimeFolder}{Runtime.Constants.BootstrapperExeName}"" --project ""$DIR/{relativeAppBase}"" --configuration {Configuration} {commandName} ""$@""";

                File.WriteAllText(scriptPath, scriptContents.Replace("\r\n", "\n"));

                if (!RuntimeEnvironmentHelper.IsWindows)
                {
                    if (!FileOperationUtils.MarkExecutable(scriptPath))
                    {
                        Reports.Information.WriteLine("Failed to mark {0} as executable".Yellow(), scriptPath);
                    }
                }
            }
        }
コード例 #6
0
        private void GenerateBashScripts()
        {
            string relativeAppBase;

            if (NoSource)
            {
                relativeAppBase = string.Format("{0}/{1}/{2}/{3}/{4}", AppRootName, "packages", _project.Name,
                                                _project.Version.ToString(), "root");
            }
            else
            {
                relativeAppBase = string.Format("{0}/{1}/{2}", AppRootName, "src", _project.Name);
            }

            const string template = @"#!/bin/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 )""

export SET KRE_APPBASE=""$DIR/{0}""

""{1}klr"" Microsoft.Framework.ApplicationHost {2} ""$@""";

            foreach (var commandName in _project.Commands.Keys)
            {
                var klrFolder = string.Empty;
                if (Runtimes.Any())
                {
                    klrFolder = string.Format(@"$DIR/{0}/packages/{1}/bin/",
                                              AppRootName, Runtimes.First().Name);
                }

                var scriptPath = Path.Combine(OutputPath, commandName);
                File.WriteAllText(scriptPath,
                                  string.Format(template, relativeAppBase, klrFolder, commandName).Replace("\r\n", "\n"));
                if (PlatformHelper.IsMono)
                {
                    MarkExecutable(scriptPath);
                }
            }
        }
コード例 #7
0
        public void Emit()
        {
            Console.WriteLine("Copying to output path {0}", OutputPath);

            var mainProject = Projects.Single(project => project.Name == _project.Name);

            foreach (var deploymentPackage in Packages)
            {
                deploymentPackage.Emit(this);
            }

            foreach (var deploymentProject in Projects)
            {
                // TODO: temporarily we always emit sources for main project to make sure "k run"
                // can find entry point of the program. Later we should make main project
                // a nukpg too.
                if (deploymentProject == mainProject)
                {
                    deploymentProject.EmitSource(this);
                }
                else
                {
                    if (NoSource)
                    {
                        deploymentProject.EmitNupkg(this);
                    }
                    else
                    {
                        deploymentProject.EmitSource(this);
                    }
                }
            }

            foreach (var deploymentRuntime in Runtimes)
            {
                deploymentRuntime.Emit(this);
            }

            mainProject.PostProcess(this);

            WriteGlobalJson();

            foreach (var commandName in _project.Commands.Keys)
            {
                const string template1 = @"
@""%~dp0{3}\packages\{2}\bin\klr.exe"" --appbase ""%~dp0{1}"" Microsoft.Framework.ApplicationHost {0} %*
";
                const string template2 = @"
@klr.exe --appbase ""%~dp0{1}"" Microsoft.Framework.ApplicationHost {0} %*
";
                if (Runtimes.Any())
                {
                    File.WriteAllText(
                        Path.Combine(OutputPath, commandName + ".cmd"),
                        string.Format(template1, commandName, Path.Combine(AppRootName, "src", _project.Name),
                                      Runtimes.First().Name, AppRootName));
                }
                else
                {
                    File.WriteAllText(
                        Path.Combine(OutputPath, commandName + ".cmd"),
                        string.Format(template2, commandName, Path.Combine(AppRootName, "src", _project.Name)));
                }
            }
        }