asp.net – 如何使用OctopusDeploy安装Windows服务,使用app.conf
发布时间:2020-12-16 10:01:52 所属栏目:asp.Net 来源:网络整理
导读:到目前为止,我已经能够创建一个 Windows服务,然后我可以让TeamCity构建和打包并提供给Octopus Deploy. 我似乎无法做的是,有一个app.config,其中有一个连接字符串并使用该连接字符串. 以下是我的Deploy.ps1: # These variables should be set via the Octopu
到目前为止,我已经能够创建一个
Windows服务,然后我可以让TeamCity构建和打包并提供给Octopus Deploy.
我似乎无法做的是,有一个app.config,其中有一个连接字符串并使用该连接字符串. 以下是我的Deploy.ps1: # These variables should be set via the Octopus web portal: # # ServiceName - Name of the Windows service # # sc.exe is the Service Control utility in Windows # Default the service name if (! $ServiceName) { $ServiceName = "OctoService" } Write-Host "Service Name:" $ServiceName # Get the exe name based ont the directory $contentPath = (Join-Path $OctopusPackageDirectoryPath "content") $configName = (Get-ChildItem $contentPath*.config -Name | Select-Object -First 1) $binPath = (Join-Path $OctopusPackageDirectoryPath "libnet40") $exeName = (Get-ChildItem $binPath*.exe -Name | Select-Object -First 1) $fullPath = (Join-Path $binPath $exeName) Write-Host "Service Path:" $fullPath Write-Host "Config Path:" (Join-Path $contentPath $configName) Copy-Item (Join-Path $contentPath $configName) $binPath $service = Get-Service $ServiceName -ErrorAction SilentlyContinue if (! $service) { Write-Host "The service will be installed" New-Service -Name $ServiceName -BinaryPathName $fullPath -StartupType Automatic } else { Stop-Service $ServiceName -Force $fullPath = Resolve-Path $fullPath & "sc.exe" config "$ServiceName" binPath= $fullPath start= auto | Write-Host Start-Service $ServiceName } 这是我的.nuspec文件: <?xml version="1.0"?> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <id>$id$</id> <version>$version$</version> <title>$title$</title> <authors>$author$</authors> <owners>$author$</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>$description$</description> <copyright>Copyright 2012</copyright> </metadata> <files> <file src="app.config" target="content" /> <file src="Deploy.ps1" /> </files> </package> 如果我尝试访问ConfigurationManager.ConnectionStrings [“MyConnectionString”],我将获得一个空引用. 有什么建议? 解决方法
我的钱是你需要将你的app.config命名为exename.exe.config,以便你的服务选择它.
App.config是ide中使用的’临时’名称,它将作为构建的一部分重命名为exe名称 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 无法在应用程序级别下定义元素’buildProviders
- asp.net-mvc – 我能改变MVC中LabelFor渲染的方式吗?
- asp.net-core – IApplicationBuilder不包含UseStaticFiles
- asp.net-mvc – MVC中具有存储库/ DTO模式的实体的部分更新
- .NET Core的文件系统[1]:读取并监控文件的变化
- asp.net – 如何在.aspx页面中访问c#变量的值?
- 剃刀 – Telerik Kendo MVC TextBox多线模式
- asp.net-web-api – 如何从ASP.net 5 web api返回文件
- 根据存储的时区修改ASP.NET MVC C#中的日期
- asp.net-mvc – asp.net mvc – [HttpPost/HttpGet] vs. [A
推荐文章
站长推荐
- asp.net-core – 当视图位于Views文件夹之外时,标
- asp.net – NLogConfigurationException – 从’
- asp.net-mvc-3 – 在远程部署MVC3时获取“CS0103
- 如何防止ASP.NET MVC将日期从UTC转换为本地?
- msbuild – 为什么aspnet_compiler需要对构建服务
- asp.net – 带有MVC 2的自定义ViewModel强类型HT
- asp.net-mvc-3 – ASP.Net MVC 3重定向未经授权的
- ASP.NET MVC / WebApi的Azure表存储最佳实践
- asp.net – 在网页中显示OLAP SQL Server?
- asp.net – 访问.NET中的Web服务中的查询字符串(
热点阅读