コード例 #1
0
ファイル: PublishRuntime.cs プロジェクト: noahfalk/dnx
        public bool Emit(PublishRoot root)
        {
            root.Reports.Quiet.WriteLine("Bundling runtime {0}", Name);

            if (Directory.Exists(TargetPath))
            {
                root.Reports.Quiet.WriteLine("  {0} already exists.", TargetPath);

                // REVIEW: IS this correct?
                return(true);
            }

            if (!Directory.Exists(TargetPath))
            {
                Directory.CreateDirectory(TargetPath);
            }

            new PublishOperations().Copy(_runtimePath, TargetPath);

            if (!RuntimeEnvironmentHelper.IsWindows)
            {
                // Executable permissions on dnx lost on copy.
                var dnxPath = Path.Combine(TargetPath, "bin", "dnx");
                if (!FileOperationUtils.MarkExecutable(dnxPath))
                {
                    root.Reports.Information.WriteLine("Failed to mark {0} as executable".Yellow(), dnxPath);
                }
            }

            return(true);
        }
コード例 #2
0
    /// <summary>
    /// 初始化登录信息
    /// </summary>
    private void InitLoginInfo()
    {
        string path = "LoginInfo.config";

        string decriptStr = FileOperationUtils.FileRead(path);
        string jsonstr    = SecurityUtils.AESDecrypt(decriptStr, key, iv);

        if (jsonstr != null)
        {
            SaveLoginInfo info = JsonMapper.ToObject <SaveLoginInfo>(jsonstr);
            loginType = (LoginType)info.loginType;

            if (loginType == LoginType.WX)
            {
                LoginWeiXinInit(info);
            }
        }
        else
        {
            //没有保存的登录信息 重新登录
            login.gameObject.SetActive(true);
            loginType = LoginType.WX;
            account   = null;
            password  = null;
            headimg   = null;
            username  = null;
        }
    }
コード例 #3
0
ファイル: PublishRuntime.cs プロジェクト: voloda/dnx
        public void Emit(PublishRoot root)
        {
            root.Reports.Quiet.WriteLine("Bundling runtime {0}", Name);

            if (Directory.Exists(TargetPath))
            {
                root.Reports.Quiet.WriteLine("  {0} already exists.", TargetPath);
                return;
            }

            if (!Directory.Exists(TargetPath))
            {
                Directory.CreateDirectory(TargetPath);
            }

            new PublishOperations().Copy(_runtimePath, TargetPath);

            if (PlatformHelper.IsMono)
            {
                // Executable permissions on dnx lost on copy.
                var dnxPath = Path.Combine(TargetPath, "bin", "dnx");
                if (!FileOperationUtils.MarkExecutable(dnxPath))
                {
                    root.Reports.Information.WriteLine("Failed to mark {0} as executable".Yellow(), dnxPath);
                }
            }
        }
コード例 #4
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);
                    }
                }
            }
        }
コード例 #5
0
    private void SaveLoginInfo()
    {
        SaveLoginInfo info = new SaveLoginInfo();

        info.loginType = (int)loginType;
        info.account   = account;
        info.password  = password;
        info.username  = username;
        info.headimg   = headimg;
        string infojson   = JsonMapper.ToJson(info);
        string encriptStr = SecurityUtils.AESEncrypt(infojson, kv[0], kv[1]);

        DebugUtils.DebugerExtension.Log(this, encriptStr);
        FileOperationUtils.FileWrite("LoginInfo.config", encriptStr);
    }
コード例 #6
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);
                    }
                }
            }
        }
コード例 #7
0
        private void btnReadConfig_Click(object sender, EventArgs e)
        {
            if (tspConfigList != null)
            {
                tspConfigList.Clear();
            }
            else
            {
                tspConfigList = new List <TspConfig>();
            }
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "所有Dasp测试文件|*.tsp";
            openFileDialog.Multiselect = false;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string    hashCode  = FileOperationUtils.MD5File(openFileDialog.FileName);
                TspConfig tspConfig = ResolveTspFileAlgorithm.ReadDataFromTspFile(openFileDialog.FileName);
                tspConfig.FileHash = hashCode;
                tspConfigList.Add(tspConfig);
                dgvDataSource.AutoGenerateColumns = false;
                dgvDataSource.DataSource          = tspConfigList;
            }
        }
コード例 #8
0
        private void btnReadData_Click(object sender, EventArgs e)
        {
            if (stsDataList != null)
            {
                stsDataList.Clear();
            }
            else
            {
                stsDataList = new List <StsData>();
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "所有Dasp测试文件|*.sts";
            openFileDialog.Multiselect = false;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string  hashCode = FileOperationUtils.MD5File(openFileDialog.FileName);
                StsData stsData  = ResolveStsFileAlgorithm.ReadDataFromStsFile(openFileDialog.FileName);
                stsData.FileHash = hashCode;

                stsDataList.Add(stsData);
            }
        }
コード例 #9
0
 public void Delete(string folderPath)
 {
     FileOperationUtils.DeleteFolder(folderPath);
 }
コード例 #10
0
        public void DnuRestore_ExecutesScripts(string flavor, string os, string architecture)
        {
            bool isWindows   = TestUtils.CurrentRuntimeEnvironment.OperatingSystem == "Windows";
            var  environment = new Dictionary <string, string>
            {
                { "DNX_TRACE", "0" },
            };

            var expectedPreContent =
                @"""one""
""two""
"">three""
""four""
";
            var expectedPostContent =
                @"""five""
""six""
""argument seven""
""argument eight""
";

            string projectJsonContent;
            string scriptContent;
            string scriptName;

            if (isWindows)
            {
                projectJsonContent =
                    @"{
  ""frameworks"": {
    ""dnx451"": { }
  },
  ""scripts"": {
    ""prerestore"": [
      ""script.cmd one two > pre"",
      ""script.cmd ^>three >> pre && script.cmd ^ four >> pre""
    ],
    ""postrestore"": [
      ""\""%project:Directory%/script.cmd\"" five six > post"",
      ""\""%project:Directory%/script.cmd\"" \""argument seven\"" \""argument eight\"" >> post""
    ]
  }
}";
                scriptContent =
                    @"@echo off

:argumentStart
if ""%~1""=="""" goto argumentEnd
echo ""%~1""
shift
goto argumentStart
:argumentEnd";
                scriptName = "script.cmd";
            }
            else
            {
                projectJsonContent =
                    @"{
  ""frameworks"": {
    ""dnx451"": { }
  },
  ""scripts"": {
    ""prerestore"": [
      ""script one two > pre"",
      ""script.sh \\>three >> pre; ./script.sh four >> pre""
    ],
    ""postrestore"": [
      ""\""%project:Directory%/script\"" five six > post"",
      ""\""%project:Directory%/script.sh\"" \""argument seven\"" \""argument eight\"" >> post""
    ]
  }
}";
                scriptContent =
                    @"#!/usr/bin/env bash
set -o errexit

for arg in ""$@""; do
  printf ""\""%s\""\n"" ""$arg""
done";
                scriptName = "script.sh";
            }

            var projectStructure =
                $@"{{
  '.': ['project.json', '{ scriptName }']
}}";
            var runtimeHomePath = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var testEnv = new DnuTestEnvironment(runtimeHomePath, projectName: "Project Name"))
            {
                var projectPath = testEnv.ProjectPath;
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", projectJsonContent)
                .WithFileContents(scriptName, scriptContent)
                .WriteTo(projectPath);
                FileOperationUtils.MarkExecutable(Path.Combine(projectPath, scriptName));

                string output;
                string error;
                var    exitCode = DnuTestUtils.ExecDnu(
                    runtimeHomePath,
                    subcommand: "restore",
                    arguments: null,
                    stdOut: out output,
                    stdErr: out error,
                    environment: environment,
                    workingDir: projectPath);

                Assert.Equal(0, exitCode);
                Assert.Empty(error);
                Assert.Contains("Executing script 'prerestore' in project.json", output);
                Assert.Contains("Executing script 'postrestore' in project.json", output);

                var preContent = File.ReadAllText(Path.Combine(projectPath, "pre"));
                Assert.Equal(expectedPreContent, preContent);
                var postContent = File.ReadAllText(Path.Combine(projectPath, "post"));
                Assert.Equal(expectedPostContent, postContent);
            }
        }