2013-06-26 74 views
21

注意:此問題在最初發布後的幾天完全重寫。與Microsoft HTTP客戶端庫v2.1.10相關的問題NuGet更新

我有一個在VS 2012中開發的ASP.NET MVC應用程序,部署到Azure。原始項目是從ASP.NET MVC 4項目模板創建的。

NuGet最近開始顯示來自微軟的更新軟件包。其中一個更新Microsoft HTTP客戶端庫v2.1.10在安裝時會導致嚴重問題。

  1. 它安裝MicrosoftBcl.Build,這不符合我的Azure項目(見this SO question的問題及其解決方案)兼容。

  2. 它會導致整個「不兼容的DLL」問題(見下文)。

這引發了一些棘手問題:

  1. 我的MVC應用程序僅僅是一個網站。它只是在網頁瀏覽器中運行。我需要這個包嗎? (例如,它是否被模板代碼所使用,如果我移除包裝,這可能會巧妙地破壞)

  2. 根據項目網站(http://blogs.msdn.com/b/bclteam/p/httpclient.aspx),有幾個較新版本(儘管是beta版本)這個產品。我假設我會看到他們,如果我告訴NuGet向我展示非發佈版本。這些版本是否解決了上述問題?

下面是當我安裝更新的NuGet包之後建立的解決方案,我得到的警告......

1>------ Build started: Project: Ruby, Configuration: Release Any CPU ------ 
1> All packages listed in packages.config are already installed. 
1> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily. 
1> Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.AspNet.4.3.0.13117\lib\net45-full\DotNetOpenAuth.AspNet.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to Version "4.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "System.Web.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "1.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\WebGrease.1.3.0\lib\WebGrease.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "System.Web.WebPages.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "Microsoft.Data.OData, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version "5.5.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Data.OData.5.5.0\lib\net40\Microsoft.Data.OData.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "System.Web.WebPages, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "DotNetOpenAuth.Core, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net45-full\DotNetOpenAuth.Core.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "System.Web.WebPages.Deployment, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll] to solve conflict and get rid of warning. 
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. 
1> Ruby -> C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\Ruby\bin\Ruby.dll 
2>------ Build started: Project: Ruby.Azure, Configuration: Release Any CPU ------ 
3>------ Publish started: Project: Ruby.Azure, Configuration: Release Any CPU ------ 
3>C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets(220,5): warning : All projects referencing Ruby.csproj must install nuget package Microsoft.Bcl.Build. 
3>  No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily. 
3>  Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.AspNet.4.3.0.13117\lib\net45-full\DotNetOpenAuth.AspNet.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to Version "4.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "System.Web.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "1.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\WebGrease.1.3.0\lib\WebGrease.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "System.Web.WebPages.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "Microsoft.Data.OData, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version "5.5.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Data.OData.5.5.0\lib\net40\Microsoft.Data.OData.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "System.Web.WebPages, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "DotNetOpenAuth.Core, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net45-full\DotNetOpenAuth.Core.dll] to solve conflict and get rid of warning. 
3>  Consider app.config remapping of assembly "System.Web.WebPages.Deployment, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll] to solve conflict and get rid of warning. 
3>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. 
3>  Transformed Web.config using C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\Ruby\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config. 
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227. 
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227. 
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227. 
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227. 
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227. 
+0

你看過[發佈一個MVC項目作爲Web角色到Windows Azure(HTTP:/ /msdn.microsoft.com/en-us/library/hh369932.aspx#PublishMVC)? –

+2

在開發環境中(與Azure無關),添加需要'Microsoft.Bcl.Build'的Nuget包會產生相同的警告。 – mostruash

+3

我在MVC 4應用程序中遇到了同樣的問題 - 除了我沒有發佈到Azure ...只是一個普通的舊版Windows 2008 R2 Web服務器。 – theBoringCoder

回答

8

您可以使用binding redirects在web.config文件來解決問題。

例如,對於行:

Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" 

添加在Web.config中:

<configuration> 
    <runtime> 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="DotNetOpenAuth.AspNet" 
           publicKeyToken="2780ccd10d57b246" 
           culture="neutral" /> 
      <bindingRedirect oldVersion="1.0.0.0-4.3.0.0" 
          newVersion="4.3.0.0"/> 
     </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
</configuration> 

...等有關創建例外添加額外dependentAssembly節點的每個DLL。

+4

我和這裏的原始海報有相同的問題(我不會將我的應用程序發佈到Azure),並立即添加綁定重定向。它不能解決問題。它應該......但它沒有。 – theBoringCoder

+0

我有同樣的問題,也嘗試綁定重定向沒有運氣。您需要顯式使用'dependentAssembly',如上所示,而不僅僅是'bindingRedirect'。 – TheCodeKing

4

導致此錯誤的一種情況是運行Azure軟件包或oder發佈命令,而未對相同配置(例如發行版)執行乾淨重建。

這個固定對我來說:

  1. 通過運行在NuGet包管理器控制檯執行以下命令重新安裝WindowsAzure.Storage NuGet包:

  2. 重建的MVC Web應用程序項目(調試和發佈)。

如果這沒有幫助,你可以設置工具下的「MSBuild項目生成輸出的詳細程度」 - >選項 - >「項目和解決方案」 - >「生成和運行」到「診斷」,檢查是什麼原因導致大會衝突(例如,查找「項目文件項目包括引起參考的項目」)。

+0

這個答案爲我做了NuGet包恢復。切換到發佈配置(在我的情況下發布),清理解決方案,重建解決方案 - 在包恢復的情況下可能需要執行兩次。然後發佈到Azure的作品。謝謝! –

4
+0

創建一個'app.config'文件並複製我的'web.config'中的重定向,爲我擺脫了愚蠢的警告。儘管如此,爲什麼我需要一個MVC項目的'app.config'文件仍然沒有意義。哦,我很高興終於擺脫那些討厭的警告! – Alexander