Пример #1
0
        private void MakeCompilationOutputRunnableForCoreCLR(string outputPath, LibraryExporter exporter)
        {
            WriteDepsFileAndCopyProjectDependencies(exporter, _context.ProjectFile.Name, outputPath);

            // TODO: Pick a host based on the RID
            CoreHost.CopyTo(outputPath, _context.ProjectFile.Name + Constants.ExeSuffix);
        }
Пример #2
0
        private void MakeCompilationOutputRunnableForCoreCLR()
        {
            WriteDepsFileAndCopyProjectDependencies(_exporter);

            // TODO: Pick a host based on the RID
            CoreHost.CopyTo(_runtimeOutputPath, _context.ProjectFile.Name + Constants.ExeSuffix);
        }
Пример #3
0
        /// <remarks>
        /// Please set the following connection strings in app.config for this WebJob to run:
        /// AzureWebJobsDashboard and AzureWebJobsStorage
        /// Better yet, add them to your Azure portal so they can be changed at runtime without re-deploying or re-compiling.
        /// </remarks>
        protected static void StartHost()
        {
            // We use console state as, even though a webjob runs in an azure website, it's technically loaded via something call the 'WindowsScriptHost', which is not web and IIS based so it's threading model is very different and more console based.
            // This actually does all the work... Just sit back and relax... but also stay in memory and don't shutdown.
            CoreHost.Run();

#if NET472
            JobHost host;
            bool    disableHostControl;
            // I set this to false ... just because.
            if (!bool.TryParse(_configurationManager.GetSetting("Cqrs.Azure.WebJobs.DisableWebJobHostControl"), out disableHostControl))
            {
                disableHostControl = false;
            }

            if (disableHostControl)
            {
                var jobHostConfig = new JobHostConfiguration
                {
                    // https://github.com/Azure/azure-webjobs-sdk/issues/741
                    DashboardConnectionString = null
                };
                host = new JobHost(jobHostConfig);
            }
            else
            {
                host = new JobHost();
            }

            if (PreRunAndBlockAction != null)
            {
                PreRunAndBlockAction();
            }

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
#endif
#if NETSTANDARD2_0
            string environment = null;
            // I set this to false ... just because.
            environment = _configurationManager?.GetSetting("Cqrs.Azure.WebJobs.Environment");

            var builder = new HostBuilder();
            if (!string.IsNullOrWhiteSpace(environment))
            {
                builder.UseEnvironment(environment);
            }
            builder.ConfigureWebJobs(b =>
            {
                b.AddAzureStorageCoreServices();
            });
            IHost host = builder.Build();
            using (host)
            {
                host.Run();
            }
#endif
        }
Пример #4
0
        private void MakeCompilationOutputRunnableForCoreCLR()
        {
            WriteDepsFileAndCopyProjectDependencies(_exporter);

            var emitEntryPoint = _compilerOptions.EmitEntryPoint ?? false;

            if (emitEntryPoint && !string.IsNullOrEmpty(_context.RuntimeIdentifier))
            {
                // TODO: Pick a host based on the RID
                CoreHost.CopyTo(_runtimeOutputPath, _compilerOptions.OutputName + Constants.ExeSuffix);
            }
        }
Пример #5
0
 /// <summary>
 /// 服务器初始化确定在线离线
 /// </summary>
 /// <param name="url">在线服务地址</param>
 /// <returns>返回是否初始化成功</returns>
 public static bool ServiceIni(string url)
 {
     try
     {
         //检测服务是否正常连接  若无法连接 开启离线模式
         GlobalVar.ServiceBaseUrl = url;
         App.CreateWsService().Test();
         GlobalVar.UserInfo = App.CreateWsService().GetUserInfo(new UserInfo {
             UserName = "******"
         });
         IsOnLine = true;
     }
     catch (Exception ex)
     {
         CoreLog.Error(ex);
         //离线服务开启
         if (MessageBoxX.Show(@"离线中!是否还要继续?", @"提示", null, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
         {
             return(false);
         }
         IsOnLine = false;
         var httpUrl = new CoreHost(typeof(Test.Service.Ws)).Open();
         try
         {
             GlobalVar.ServiceBaseUrl = httpUrl;
             App.CreateWsService().Test();
             GlobalVar.UserInfo = App.CreateWsService().GetUserInfo(new UserInfo {
                 UserName = "******"
             });
         }
         catch (Exception e)
         {
             CoreLog.Error(e);
             return(false);
         }
     }
     return(true);
 }
Пример #6
0
        private static int RenamePublishedHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions)
        {
            if (context.TargetFramework.IsDesktop())
            {
                return(0);
            }

            var publishedHostFile = ResolvePublishedHostFile(outputPath);

            if (publishedHostFile == null)
            {
                Reporter.Output.WriteLine($"publish: warning: host executable not available in dependencies, using host for current platform");
                // TODO should this be an error?

                CoreHost.CopyTo(outputPath, compilationOptions.OutputName + Constants.ExeSuffix);
                return(0);
            }

            var publishedHostExtension = Path.GetExtension(publishedHostFile);
            var renamedHostName        = compilationOptions.OutputName + publishedHostExtension;
            var renamedHostFile        = Path.Combine(outputPath, renamedHostName);

            try
            {
                Reporter.Verbose.WriteLine($"publish: renaming published host {publishedHostFile} to {renamedHostFile}");
                File.Copy(publishedHostFile, renamedHostFile, true);
                File.Delete(publishedHostFile);
            }
            catch (Exception e)
            {
                Reporter.Error.WriteLine($"publish: Failed to rename {publishedHostFile} to {renamedHostFile}: {e.Message}");
                return(1);
            }

            return(0);
        }
Пример #7
0
        /// <remarks>
        /// Please set the following connection strings in app.config for this WebJob to run:
        /// AzureWebJobsDashboard and AzureWebJobsStorage
        /// Better yet, add them to your Azure portal so they can be changed at runtime without re-deploying or re-compiling.
        /// </remarks>
        protected static void StartHost()
        {
            // We use console state as, even though a webjob runs in an azure website, it's technically loaded via something call the 'WindowsScriptHost', which is not web and IIS based so it's threading model is very different and more console based.
            // This actually does all the work... Just sit back and relax... but also stay in memory and don't shutdown.
            CoreHost.Run();

            JobHost host;
            bool    disableHostControl;

            // I set this to true ... just because.
            if (!bool.TryParse(_configurationManager.GetSetting("Cqrs.Azure.WebJobs.DisableWebJobHostControl"), out disableHostControl))
            {
                disableHostControl = false;
            }
            if (disableHostControl)
            {
                var jobHostConfig = new JobHostConfiguration
                {
                    // https://github.com/Azure/azure-webjobs-sdk/issues/741
                    DashboardConnectionString = null
                };
                host = new JobHost(jobHostConfig);
            }
            else
            {
                host = new JobHost();
            }

            if (PreRunAndBlockAction != null)
            {
                PreRunAndBlockAction();
            }

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }