Reputation: 18434
My build:
produces an artifact (nuget package) that contains the following files:
The cspkg is a valid, deployable package. The problem is that it contains a web.config that is pre-transform because the transform occurs at deployment time. See the Octopus documentation for transforms and variable substitution for reference.
How do I overwrite the web.config inside the cspkg with the transformed web.config that resides in the deployment package?
I have powershell and the full .net framework at my disposal.
Alternatively, if it makes more sense to unpack the cspkg, overwrite the file and then re-package, I consider that acceptable. I am not sure how to do that either.
I know that Save-AzureServiceProjectPackage exists but I cannot get it to run and the documentation is lacking.
Upvotes: 6
Views: 1344
Reputation: 3041
I have solved this by sending the solution as it is to Octopus Deploy which allows me to run .config transformations in Octopus. After running the transformations I create the .cspkg package with custom powershell script.
I have written a thorough post of the Octopus deploying part. You can find it here: http://henrihietala.github.io/
Upvotes: 1
Reputation: 18434
I have figured out how to do what I need based upon the information contained in Brad Webber's post in the Octopus Support forum.
I have posted a public git repo containing a simple sample solution and documentation here.
Upvotes: 0
Reputation: 100258
I have an Octopus project with 2 steps: first for Dev hosted in IIS, second for Prod hosted in Azure. TeamCity procuded 2 nuget packages: one by OctoPack for Dev, another by NuGet Pack for Prod with cspkg.
I have this target in my Azure.ccproj:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="Transform" BeforeTargets="BeforeBuild" Condition="'$(TEAMCITY_VERSION)' != ''">
<PropertyGroup>
<SourceTransformFile>..\Api\Web.config</SourceTransformFile>
<TransformFile>..\Api\Web.Prod.config</TransformFile>
<DestinationTransformFile>..\Api\Web.config</DestinationTransformFile>
</PropertyGroup>
<TransformXml
Source="$(SourceTransformFile)"
Transform="$(TransformFile)"
Destination="$(DestinationTransformFile)" />
</Target>
The condition allows to run in only on the build server and not locally.
Upvotes: 1