Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:11:54+00:00 2026-05-30T23:11:54+00:00

So far, I’ve been able to create a Windows Service, which I can then

  • 0

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.

What I can’t seem to do, is have an app.config which has a connection string in it and use that connection string.

The following is my 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 "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
    & "sc.exe" config "$ServiceName" binPath= $fullPath start= auto | Write-Host

    Start-Service $ServiceName
}

Here’s my .nuspec file:

<?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>

If I try to access ConfigurationManager.ConnectionStrings[“MyConnectionString”], I’ll get a null reference.

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:11:55+00:00Added an answer on May 30, 2026 at 11:11 pm

    my money is on you needing to name your app.config to exename.exe.config so it is picked up by your service.

    App.config is the ‘temporary’ name used in the ide, it gets renamed as part of the build to whatever the exe name is

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I've been able to find out, Windows doesn't offer an API
as far as I can get gowalla auth code response contains both expires_at and
So far I've been able to find out how to add a line at
Far as best practices are concerned, which is better: public void SomeMethod(string str) {
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
As far as I can tell, this is isn't possible, so I'm really just
So far I've got: :notice :alert :error but is there definitive list, that can
As far as I can tell both provide an onion layer mechanism and pass
So far i wrote a code to download a file from ftp server then
As far as I see every time I make a change, for example the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.