Update Azure CSPKG with modified web.config after publishing

My build:

  • Build with msbuild (/ t: build)
  • Publish with msbuild (/ t: publish)
  • Nuget package
  • Deploy with octopus

creates an artifact (nuget package) that contains the following files:

  • Azure.ccproj.cspkg
  • ServiceConfiguration.Production.csfg
  • Web.config (which will be converted when deploying via Octopus)

Cspkg is a valid, deployable package. The problem is that it contains a web.config file that is pre-converted because the conversion happens during deployment. See the Octopus Documentation for converting and substituting variables for reference.

How to overwrite the web.config inside cspkg with the converted web.config that is in the deployment package?

I have powershell and a complete .net infrastructure at my disposal.

Alternatively, if it makes sense to unpack cspkg, overwrite the file and then repackage, I find it acceptable. I also don't know how to do this.

I know Save-AzureServiceProjectPackage exists, but I cannot get it to work and the documentation is lacking.

+3


source to share


3 answers


I figured out how to do what I need based on the information contained in the Brad Webber post on the Octopus support forum.



I posted a public git repository containing a simple example solution and documentation here .

0


source


I solved this by posting a solution the same as Octopus Deploy, which allows me to run .config transformations in Octopus. After doing the transformations, I create a .cspkg package with a custom powershell script.



I wrote a detailed post on Octopus deployment. You can find it here: http://henrihietala.github.io/

+1


source


I have an Octopus project with two steps: first for Dev hosted in IIS, second for Prod hosted in Azure. TeamCity has released 2 nuget packages, one is OctoPack for Dev, the other is 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 only allows you to work on the build server, not locally.

0


source







All Articles