3
votes

I'm using Octopus Deploy to deploy ASP.NET 5 websites to Azure based on this guide: https://gist.github.com/alfhenrik/ee08dbb1fb6e2bc7f772

I'm trying to find a way to transform configuration files but haven't found any elegant solutions yet. Currently my best suggestion is to have an appsettings.json with config used in the local dev environment and an appsettings.Release.json which is an exact copy of appsettings.json where all values are octopus variables like #{myVariableName}. Then when deploying with Octopus we have a pre-deployment script that replaces appsettings.json with appsettings.Release.json and then run variable substitutions on appsettings.json.

Any better suggestions?

4

4 Answers

3
votes

What I did to solve this, was to use xml configuration instead of json. I moved all my config from my appsettings.json and appsettings.Release.json to Web.config and Web.Release.config and added .AddXmlFile("Web.config") in Startup.cs. This way, I can use the built in configuration transformation in Octopus Deploy while waiting for them to start supporting ASP.NET 5 apps properly.

UPDATE 2016-02-02: Support for .json configuration files has now been added to Octopus Deploy as of v3.3. See https://octopus.com/blog/octopus-deploy-3.3#ASPNETCoreJSON

0
votes

At the moment octopus deploy doesn't support ASP.NET 5 because it has significant amount of changes.

However the team at Octopus Deploy is working on getting there.

Go to this link for further information: http://help.octopusdeploy.com/discussions/questions/6083-deploying-aspnet-vnext-web-application

0
votes

henningst suggestion is correct. But if someone is stuck like me in a previous octopus version. You can work around it by running a custom powershell script that sets the environment variable in the box

sleep 50
$EnvName = $OctopusParameters["ASPNETCORE_ENVIRONMENT"]
[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", $EnvName, "Machine")

And just add a variable named "ASPNETCORE_ENVIRONMENT" with the name of the environment you are supposed to be deploying to e.g.: QA

e.g: appSettings.QA.Json -> Add Variable ASPNETCORE_ENVIRONMENT with value QA

And then rely on the normal:

.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)

To do the transforms in the box