Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure git deployment - missing references in 2nd assembly

I'm trying to setup Bitbucket deployment to an Azure website. I successfully have Bitbucket and Azure linked, but when I push to Bitbucket, I get the following error on the Azure site:

enter image description here

If I click on 'View Log', it shows the following compile errors:

    D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "WebMatrix.WebData, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    CustomMembershipProvider.cs(5,7): error CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    CustomMembershipProvider.cs(9,38): error CS0246: The type or namespace name 'ExtendedMembershipProvider' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(3,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    CustomMembershipProvider.cs(198,37): error CS0246: The type or namespace name 'OAuthAccountData' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(40,10): error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(40,10): error CS0246: The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(73,10): error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(73,10): error CS0246: The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]

Note that these compile errors are against another assembly in my project (the assembly where I put the business logic).

When Googling, the only mention I found was about having to set the "local copy" flag to true for those references. I've tried this, but still got the same errors.

This all compiles fine locally. Any ideas?

Update

To add a bit more information, my project structure that is in the Git repo is as follows:

+ProjName
    ProjName.csproj
    web.config
    ...etc...
+ProjName.Common
    ProjName.Common.csproj
+ProjName.Tests
    ProjName.Tests.csproj
+packages <-- these are Nuget packages
ProjName.sln

The compile errors shown by Azure say that it's ProjName.vcproj that failed - but they refer to the ProjName.Common assembly reference.

Note that this layout is what VisualStudio created (ie. an extra project subdirectory for the webroot).

I'm not really sure what Azure does when doing a Git deploy. Does it recognise that the ProjName directory is the webroot, and also parse the ProjName.sln compiling any other assemblies that are in the solution (the same way Visual Studio does)?

Also, I've not added any "bin" folders to Git. However, I did just try this as a test, and it didn't change the compile errors that Azure produced.

like image 519
Dan Avatar asked Nov 17 '12 10:11

Dan


2 Answers

Updated 11/25/2012: After looking at Dan's repo, the problem is that the library project is using Mvc 4 from the GAC instead of using the NuGet package. Switching to the NuGet package makes it work fine on Azure.

In theory, MVC4 could be in the GAC on the Azure machines and this would not be an issue. And maybe they'll get there at some point. Though generally, the MVC team is increasingly pushing a NuGet based model where you don't rely on things being in the GAC.

Original answer:

Generally, you should avoid committing binaries to your git repo, instead relying on NuGet to retrieve them. Please see https://github.com/KuduApps/Mvc4ApplicationFx40WithLib for a sample project that does this and works fine in Azure Web Sites.

But based on your project structure, I see that your projects seem to use C++ (.vcproj). If so, then the likely problem is that C++ may not be supported today in Azure Web Sites when publishing via git. So far, I don't think this has come up as must people use C# & VB. If that is indeed the issue, then I suggest you open an issue on https://github.com/projectkudu/kudu so we can properly track this.

like image 78
David Ebbo Avatar answered Oct 13 '22 11:10

David Ebbo


So my .Common assembly had a reference to System.Web.Mvc and WebMatrix.WebData, and it looks like Azure doesn't support that. I had some membership code which used those references in the common assembly rather the web project. Removing those, removes the error. I'll have to refactor the code slightly so that the common library doesn't require these references.

like image 28
Dan Avatar answered Oct 13 '22 13:10

Dan