简体   繁体   English

如何在MSBuild构建的Azure Cloud Service包中启用远程调试

[英]How to enable remote debugging in Azure Cloud Service package built by MSBuild

I'm building ccproj project directly by MSBuild (within TeamCity): 我正在通过MSBuild(在TeamCity中)直接构建ccproj项目:

msbuild Project.Azure.ccproj /p:Configuration=Debug /t:Publish

How to enable remote debugger? 如何启用远程调试器? Like in the UI: 就像在UI中一样:

在此输入图像描述

I don't think it is available as a command line switch. 我不认为它可用作命令行开关。 I did some searching and only found your question here. 我做了一些搜索,只在这里找到了你的问题。

If I do a publish, enabling debugging, in VS 2013 Update 1, it creates a temporary .cscfg file in the output directory along with the package to upload (now almost twice as big). 如果我在VS 2013 Update 1中进行发布,启用调试,它会在输出目录中创建一个临时的.cscfg文件以及要上载的包(现在几乎是原来的两倍)。 The .cscfg file contains some extra settings: .cscfg文件包含一些额外的设置:

<Setting name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.Connector.Enabled" value="true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.Connector.Version" value="2.3" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.ClientThumbprint" value="XXXX" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.ServerThumbprint" value="XXXX" />

Where XXXX is a thumbprint for a certificate created by VS and installed in the certificate store (My local) with a friendly name of RemoteDebuggerZZZZZ. 其中XXXX是由VS创建的证书的指纹,并安装在证书存储区(我的本地)中,其友好名称为RemoteDebuggerZZZZZ。

An updated .csdef file contains the following section under for my webrole: 更新的.csdef文件包含以下针对我的webrole的部分:

<Endpoints>
  <InputEndpoint name="HttpIn" protocol="http" port="80" localPort="80" />
  <InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="https" localPort="443" />
  <InstanceInputEndpoint name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.Connector" localPort="30398" protocol="tcp">
    <AllocatePublicPortFrom>
      <FixedPortRange min="30400" max="30424" />
    </AllocatePublicPortFrom>
  </InstanceInputEndpoint>
  <InstanceInputEndpoint name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.Forwarder" localPort="31398" protocol="tcp">
    <AllocatePublicPortFrom>
      <FixedPortRange min="31400" max="31424" />
    </AllocatePublicPortFrom>
  </InstanceInputEndpoint>
</Endpoints>

And for my worker role: 而对于我的工人角色:

<Endpoints>
  <InstanceInputEndpoint name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.Connector" localPort="30398" protocol="tcp">
    <AllocatePublicPortFrom>
      <FixedPortRange min="30425" max="30449" />
    </AllocatePublicPortFrom>
  </InstanceInputEndpoint>
  <InstanceInputEndpoint name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.Forwarder" localPort="31398" protocol="tcp">
    <AllocatePublicPortFrom>
      <FixedPortRange min="31425" max="31449" />
    </AllocatePublicPortFrom>
  </InstanceInputEndpoint>
</Endpoints>

It also added a certificate section for my worker role: 它还为我的worker角色添加了一个证书部分:

<Certificates>
  <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.TransportValidation" storeLocation="LocalMachine" storeName="My" />
</Certificates>

.. and added the same certificate for my web role: ..并为我的网络角色添加了相同的证书:

<Certificates>
  <Certificate name="https" storeLocation="LocalMachine" storeName="My" />
  <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteDebugger.TransportValidation" storeLocation="LocalMachine" storeName="My" />
</Certificates>

I have manually added the "https" certificate, so that was there before. 我手动添加了“https”证书,所以之前就是这样。

It seems the tooling in VS creates a range of ports to access the ports 30398 and 31398 used by the remote debugging tools and adding the "TransportValidation" certificate to the list of certificates. 似乎VS中的工具创建了一系列端口来访问远程调试工具使用的端口30398和31398,并将“TransportValidation”证书添加到证书列表中。

There are no extra settings or imports added for either role type. 没有为任一角色类型添加额外设置或导入。

I have yet to find some documentation on this, so if anybody can shed some light, please do! 我还没有找到关于此的一些文档,所以如果有人能说清楚,请做!

Hope this helps anyone else trying this out. 希望这有助于其他人尝试这一点。

We've been able to create different profiles for Azure projects per environment. 我们已经能够为每个环境的Azure项目创建不同的配置文件。 Then we pass in this: 然后我们传入这个:

/p:TargetProfile=Dev 

That way it gets built with the correct Cloud Service profile. 这样,它就可以使用正确的Cloud Service配置文件构建。

Beyond that, I know I would end up just writing some one-off C# or even a Powershell script to modify the config after build. 除此之外,我知道我最终只会编写一些一次性的C#甚至是Powershell脚本来修改构建后的配置。

This is explained in the Azure documentation . Azure文档中对此进行了解释。

Basically you should get the remote tools for visual studio 2013 and then add the following properties to the msbuild command: 基本上你应该为visual studio 2013获取远程工具 ,然后将以下属性添加到msbuild命令:

msbuild /TARGET:PUBLISH /PROPERTY:Configuration=Debug;EnableRemoteDebugger=true;VSX64RemoteDebuggerPath="<path-to-remote-tools>";RemoteDebuggerConnectorCertificateThumbprint="<thumbprint-of-ceritificate-that-is-added-to-the-cloud-service>";RemoteDebuggerConnectorVersion="2.4" "<path-to-solution-file>"

where VSX64RemoteDebuggerPath is a path to the folder that contains `msvsmon.exe in the remote tools for visual studio 其中VSX64RemoteDebuggerPath是Visual Studio远程工具中包含`msvsmon.exe的文件夹的路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM