Jack
Jack

Reputation: 9242

No DEBUG constant define, #if DEBUG returns true on release build

We have a console app, that we use to call DbUp (create db, update, test data, etc..).

We have a configuration, Stable, that is configured to NOT define the DEBUG constant:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Stable|AnyCPU'">
    <OutputPath>bin\Stable\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>

Yet when this gets run on Octopus, this always returns true and holds up the deployment:

#if DEBUG
Console.ReadLine();
#endif

When I switch to the Stable configuration locally (VS), it runs and exits as expected.

When I switch to the Debug configuration locally (VS), it runs and waits for input, as expected.

If I comment out the lines completely, it runs fine on Octopus (exits, deployment finishes on Octopus).

This has me questioning all my choices in life.

Any idea why this may be happening?

EDIT - Command used to build the project (using TeamCity)

# Database
Invoke-Msbuild "$rootDir\artifacts\output\Database" `
             "$rootDir\MyClient.Database\MyClient.Database.csproj" `
             -target 'build' `
             -toolsVersion 4.0 `
             -maxCpuCount 8 `
             -VisualStudioVersion 14.0 `
             -logPath "$rootDir\artifacts\logs\Database" `
             -namespace 'MyClient' `
             -customParameters @('/property:RunOctoPack=true', "/property:OctoPackPackageVersion=$version", "/property:OctoPackNuGetProperties=env=$environment")

Upvotes: 1

Views: 663

Answers (1)

Christian Alt-Wibbing
Christian Alt-Wibbing

Reputation: 357

Build servers build. Octopus deploys.

So i do not think that Octopus has something to do with this problem. Do you have a build server like TeamCity? Perhabs is there something wrong in the configuration?

EDIT:

Do you try this Parameter?

-MsBuildParameters "/target:Clean;Build /property:Configuration=Stable;Platform=""Mixed Platforms""

Upvotes: 2

Related Questions