我有一个Azure云服务,具有Web角色和工作人员。
从命令行创建Package时,我遇到了worker角色的问题。 我的worker是一个带有App.Config的简单类库,使用SlowCheetah 2.5.5进行转换。
如果我右键单击我的Azure Cloud Service并将其打包,一切都很好,最后的app.config将是SlowCheetah转换的那个,如下所示
22>Target "CopyWorkerRoleFiles" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0\Microsoft.WindowsAzure.targets" from project "C:\dev\My\WindowsAzure\WindowsAzure.ccproj" (target "CopyRoleFiles" depends on it):
22> WorkerFiles=C:\dev\My\MyWorker\bin\QA\MyWorker.dll.config -> MyWorker.dll.config
22> WorkerFiles=C:\dev\My\MyWorker\obj\QA\MyWorker.dll -> MyWorker.dll
22> WorkerFiles=C:\dev\My\MyWorker\obj\QA\MyWorker.pdb -> MyWorker.pdb
22> WorkerFiles=C:\dev\My\MyWorker\obj\QA\SlowCheetah\App.config -> MyWorker.dll.config
从命令行开始,现在,当我创建包时,不再使用SlowCheetah而且我没有转换
CopyWorkerRoleFiles:
WorkerFiles=C:\CI\My\MyWorker\bin\QA\MyWorker.dll.config -> MyWorker.dll.config
WorkerFiles=C:\CI\My\MyWorker\bin\QA\App.config -> App.config
WorkerFiles=C:\CI\My\MyWorker\obj\QA\MyWorker.dll -> MyWorker.dll
WorkerFiles=C:\CI\My\MyWorker\obj\QA\MyWorker.pdb -> MyWorker.pdb
如何在VS和命令行之间找到相同的行为?
修改
我创建了一个带有一个辅助角色和slowcheetah的小型云项目,一切都在这个新项目上正常运行...... 问题来自我的项目,我已经加倍检查了我的解决方案中的csproj和ccproj以及测试解决方案中的csproj和ccproj,我没有看到任何重大差异......
编辑2:
这是我的msbuild命令来编译我的项目
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\MyProject.sln
/p:Configuration=QA /p:TargetProfile=CloudQA /target:Publish /nr:false
编辑3: 我终于把问题缩小到了这个,我已经将Microsoft.Bcl更新为1.1.3,我编译了它,转换工作正常!
我已将Microsoft.Net.Http更新为2.2.13,我编译了它,转换失败了。
nuget包将此添加到我的csproj ...
<Reference Include="System.Net.Http" />
+ <Reference Include="System.Net.Http.Extensions">
+ <HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Extensions.dll</HintPath>
+ </Reference>
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
</Reference>
+ <Reference Include="System.Net.Http.Primitives">
+ <HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest" />
如果我删除所有引用,转换再次起作用......
我添加了这个引用,转换仍然有效:
+ <Reference Include="System.Net.Http.WebRequest" />
我逐一添加了这个参考文献
+ <Reference Include="System.Net.Http.Extensions">
+ <HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.Primitives">
+ <HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Primitives.dll</HintPath>
+ </Reference>
项目转型再次失败。
编辑4:
有关此问题的更多信息,Micorosoft.Net.HttpClient Nuget Packages还在System.Net.Http.Extensions和System.Net.Http.Primitives时修改app.config。它将以下内容添加到app.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.13.0" newVersion="2.2.13.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.13.0" newVersion="4.2.13.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
以下是引用这些程序集的构建输出
17>_CopyAppConfigFile:
17> Copying file from "obj\Debug\Tests.MyProject.Data.csproj.App.config" to "bin\Debug\Tests.MyProject.Data.dll.config".
17>CopyFilesToOutputDirectory:
17> Copying file from "obj\Debug\Tests.MyProject.Data.dll" to "bin\Debug\Tests.MyProject.Data.dll".
17> Tests.MyProject.Data -> C:\dev\MyProject\Tests\Tests.MyProject.Data\bin\Debug\Tests.MyProject.Data.dll
17> Copying file from "obj\Debug\Tests.MyProject.Data.pdb" to "bin\Debug\Tests.MyProject.Data.pdb".
17>ScReplaceAppConfigItem:
17> Updated app.config to point to transformed file
17> AppConfigWithTargetPath: obj\Debug\Tests.MyProject.Data.csproj.App.config
17> AppConfigWithTargetPath.TargetPath: Tests.MyProject.Data.dll.config
删除Microsoft引用
17>_CopyAppConfigFile:
17> Copying file from "App.config" to "bin\Debug\Tests.MyProject.Data.dll.config".
17>CopyFilesToOutputDirectory:
17> Copying file from "obj\Debug\Tests.MyProject.Data.dll" to "bin\Debug\Tests.MyProject.Data.dll".
17> Tests.MyProject.Data -> C:\dev\MyProject\Tests\Tests.MyProject.Data\bin\Debug\Tests.MyProject.Data.dll
17> Copying file from "obj\Debug\Tests.MyProject.Data.pdb" to "bin\Debug\Tests.MyProject.Data.pdb".
17>ScReplaceAppConfigItem:
17> Copying file from "bin\Debug\Tests.MyProject.Data.dll.config" to "obj\Debug\SlowCheetah\App.config".
17> Updated app.config to point to transformed file
17> AppConfigWithTargetPath: obj\Debug\SlowCheetah\App.config
17> AppConfigWithTargetPath.TargetPath: Tests.MyProject.Data.dll.config
答案 0 :(得分:0)
使用Slowcheetah 2.5.7解决问题