3
votes

I have an MVC4 + EF4.0 .NET 4.5 project (say, MyProject) I'm able to run the project locally just fine. When I FTP deploy it to Azure Websites (not cloud service) it runs fine too. However, if I do a GIT deploy, the site 'runs' for the most part until it does some EF5.0 database operations. I get an exception Unable to load the specified metadata resource.

Upon debugging I noticed that if I:

  • GIT deploy the entire MVC4 project (as before)
  • FTP in and then replace bin\MyProject.dll with the bin\MyProject.dll file that I just built locally (Windows 8 x64, VS2012, Oct'12 Azure tools) after the GIT push (i.e. same source)

then the Azure hosted website runs just fine (even the EF5.0 database functionality portion).

The locally built .dll is about 5KB larger than the Azure GIT publish built one and both are 'Release' mode. It's obvious that the project as built after the GIT push (inside Azure) is being built differently than as on my own PC. I checked the portal and it's set to .NET 4.5. I'm also GIT pushing the entire solution folder (with just one project) and not just small bits and pieces.

When I load the locally built as well as the remotely built MyProject.dll files, I noticed the following difference(FrameworkDisplayName)

  • local: System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5"),

  • remote: System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ""),

Anyone knows why this is happening and what the fix might be?

2

2 Answers

2
votes

Yes, this is a bug that will be fixed in the next release. The good news is that it's possible to work around it today:

First, you need to use a custom deployment script, per this post.

Then you need to change the MSBuild command line in the custom script per this issue.

2
votes

Credit goes to David above for the pointers and hints. I voted him up but I'll also post the exact solution to the issue here. I've edited my original post because I found there was a major bug that I didn't notice until I started from scratch (moved GIT servers). So here is the entire process, worked for me.

  • Download Node.JS (it's needed even for .NET projects because the GIT deploy tools use it)
  • Install the azure-cli tool (open regular command prompt => npm install azure-cli -g)
  • In the command prompt, cd to the root of your repository (cd \projects\MyRepoRoot)
  • In there, type azure site deploymentscript --aspWAP PathToMyProject\MyProject.csproj -s PathToMySolution.sln (obviously adjust the paths as needed)
  • This will create the .deployment and deploy.cmd files
  • Now edit the deploy.cmd file, find the line starting with %MSBUILD_PATH% (will be just one)
  • Insert the /t:Build parameter. For example:
    • [Before] %MSBUILD_PATH% <blah blah> /verbosity:m /t:pipelinePreDeployCopyAllFilesToOneFolder
    • [After] %MSBUILD_PATH% <blah blah> /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder)
  • Push to GIT (check the GIT output if everything went ok)
  • Browse to your website and confirm it works!

I'll be glad when it's fixed in the next revision so we won't maintain the build script