2015-12-14 6 views
5

Ho un progetto API Web ASP.NET con file Web.conig. Quando viene creato in VS2015, non vengono segnalati errori e avvisi. Tuttavia quando ho costruire questo progetto su TeamCity utilizzando MSBuild costruire passo, vengo avvertimento MSB3247:MSBuild step in TeamCity considera app.config invece di web.config per il progetto API WEB ASP.NET che genera un avviso MSB3247

[ResolveAssemblyReferences] ResolveAssemblyReference 
[14:30:01] : [ResolveAssemblyReference] No way to resolve conflict between "protobuf-net, Version=2.0.0.602, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" and "protobuf-net, Version=2.0.0.480, Culture=neutral, PublicKeyToken=257b51d87d2e4d67". Choosing "protobuf-net, Version=2.0.0.602, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" arbitrarily. 
[14:30:01] : [ResolveAssemblyReference] No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily. 
[14:30:01] : [ResolveAssemblyReference] Consider app.config remapping of assembly "protobuf-net, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" from Version "2.0.0.602" [] to Version "2.0.0.668" [D:\TeamCity\buildAgent\work\2772494ce0e0bbd7\branches\Stategic.Window.Release1\src\Strategic.Window\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll] to solve conflict and get rid of warning. 
[14:30:01] : [ResolveAssemblyReference] Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "6.0.0.0" [] to Version "7.0.0.0" [D:\TeamCity\buildAgent\work\2772494ce0e0bbd7\branches\Stategic.Window.Release1\src\Strategic.Window\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll] to solve conflict and get rid of warning. 
[14:30:01] : [ResolveAssemblyReference] Consider app.config remapping of assembly "RazorEngine, Culture=neutral, PublicKeyToken=9ee697374c7e744a" from Version "3.0.8.0" [] to Version "3.7.4.0" [D:\TeamCity\buildAgent\work\2772494ce0e0bbd7\branches\Stategic.Window.Release1\src\Strategic.Window\packages\RazorEngine.3.7.4\lib\net45\RazorEngine.dll] to solve conflict and get rid of warning. 
[14:30:01] : [ResolveAssemblyReference] Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.5.1.25624" [] to Version "1.5.2.14234" [D:\TeamCity\buildAgent\work\2772494ce0e0bbd7\branches\Stategic.Window.Release1\src\Strategic.Window\packages\WebGrease.1.5.2\lib\WebGrease.dll] to solve conflict and get rid of warning. 
[14:30:01]W: [ResolveAssemblyReference] C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819, 5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="protobuf-net" culture="neutral" publicKeyToken="257b51d87d2e4d67" /><bindingRedirect oldVersion="0.0.0.0-2.0.0.668" newVersion="2.0.0.668" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /><bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="RazorEngine" culture="neutral" publicKeyToken="9ee697374c7e744a" /><bindingRedirect oldVersion="0.0.0.0-3.7.4.0" newVersion="3.7.4.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /></dependentAssembly></assemblyBinding> 

Sembra che il file app.config viene considerato da MSBuild invece di web.config, perché propone di aggiungere bindingRedirtect, che sono già presenti nel mio file Web.config. Ho ricontrollato questo problema incollando il file Web.config e rinominandolo in App.config. Questo ha rimosso l'avviso. Quando App.config viene eliminato - riappare l'avviso. Quindi le mie domande sono 1) perché anche se MSBuild sembra utilizzare app.config non fallisce quando ho solo Web.config nel progetto; 2) Come posso dare un suggerimento a MSBuild per usare Web.config per il reindirizzamento del binding? 3) perché costruire esattamente lo stesso progetto in VS non produce un avvertimento?

risposta

6

Il problema è che Microsoft Web Developer Tools non è installato. In questo caso, MSBuild non sa come gestire correttamente i file web.config.

Possibili soluzioni:

  1. Installare Microsoft ASP.NET e Web Tools 2015 sul server TeamCity

  2. Copia tali cartelle al server TeamCity

    • c: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v14.0 \ WebApplications \
    • c: \ Programmi (x86) \ MSBuild \ Microsoft \ Visual Studio \ v14.0 \ Web \

    assicurarsi che <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> nel web csproj sia corretto.

Il file Microsoft.WebApplication.targets fa riferimento ai file nella cartella Web, pertanto, deve essere presente anche.

La soluzione è stata raccolta da here.

Problemi correlati