Domanda

Description

We are in a current project based on MVC4/Umbraco using Azure Websites to host it.

We are using SCM_BUILD_ARGS to change between different build setups depending on which site in Azure we deploy to (Test and Prod).

This is done by defining an app setting in the UI:

SCM_BUILD_ARGS = /p:Environment=Test

Earlier we used Bitbucket Integration to deploy and here this setting worked like a champ.

We have now switched to using Git Deployment, pushing the changes from our build server when tests have passed. But when we do this, we get a lovely error.

"MSB1008: Only one project can be specified."

Trying to redeploy the same failed deployment from the UI on Azure works though.

After some trial and error I ended going into the deploy.cmd and outputting the %SCM_BUILD_ARGS% value in the script. It looks like the / gets dropped from SCM_BUILD_ARGS but only when using Git deploy, not Bitbucket Integration or redeploy from UI.

Workaround

As workaround I have for now added a / to the deploy.cmd script in front of the %SCM_BUILD_ARGS%, but this of course breaks redeploy, since we then have //p:Environment=Test in the MSBuild command when the value of %SCM_BUILD_ARGS% has been inserted.

:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
:: Added / to SCM_BUILD_ARGS
  %MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\www\www.csproj" [....]  /%SCM_BUILD_ARGS%
) ELSE (
  %MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\www\www.csproj" [....] /%SCM_BUILD_ARGS%
)

Question

Anyone know of a better solution for this problem or is it possibly a bug in Kudu? We would love to have both deploy from Git and Redeploy working.

È stato utile?

Soluzione

Could you try changing from "/" to "-"? For instance, AppSettings from /p:Environment=Test to -p:Environment=Test, see if it helps.

Altri suggerimenti

-p:Environment=Test did not work for me, the setting which worked for me at the time of this writing (September 2015) was -p:Configuration=Test

There is clearly a Kudu bug in there, and you should open an issue on https://github.com/projectkudu/kudu. But for now, I can give you a workaround.

Instead of using an App Setting, include a .deployment file at the root of your repo, containing:

[config]
SCM_BUILD_ARGS = /p:Environment=Test

I think this will work in all cases. I suspect the bug has to do with bash messing up the environment in post receive hook scenarios, which only apply to direct git push but not to Bitbucket and Redeploy scenarios.

UPDATE: In fact, it's easy to see such weird bash behavior. Try this:

  • Open cmd.exe
  • Run: set foo=/abc to set a variable
  • Run bash
  • From bash, run cmd to launch a new cmd on top of bash (so cmd -> bash -> cmd)
  • Run set foo to get the value of foo

Result:

FOO=C:/Program Files (x86)/git/abc

So the value gets completely messed up. The key also gets upper cases, though that's mostly harmless. Strange stuff...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top