Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I have a Windows Service, installed using OctopusDeploy, use an app.config?
    primarykey
    data
    text
    <p>So far, I've been able to create a Windows Service, which I can then get TeamCity to build and pack up and make available for Octopus Deploy.</p> <p>What I can't seem to do, is have an app.config which has a connection string in it and use that connection string. </p> <p>The following is my Deploy.ps1:</p> <pre><code># 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 "lib\net40") $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 &amp; "sc.exe" config "$ServiceName" binPath= $fullPath start= auto | Write-Host Start-Service $ServiceName } </code></pre> <p>Here's my .nuspec file:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"&gt; &lt;metadata&gt; &lt;id&gt;$id$&lt;/id&gt; &lt;version&gt;$version$&lt;/version&gt; &lt;title&gt;$title$&lt;/title&gt; &lt;authors&gt;$author$&lt;/authors&gt; &lt;owners&gt;$author$&lt;/owners&gt; &lt;requireLicenseAcceptance&gt;false&lt;/requireLicenseAcceptance&gt; &lt;description&gt;$description$&lt;/description&gt; &lt;copyright&gt;Copyright 2012&lt;/copyright&gt; &lt;/metadata&gt; &lt;files&gt; &lt;file src="app.config" target="content" /&gt; &lt;file src="Deploy.ps1" /&gt; &lt;/files&gt; &lt;/package&gt; </code></pre> <p>If I try to access ConfigurationManager.ConnectionStrings["MyConnectionString"], I'll get a null reference. </p> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload