如何方便地推断Azure SDK csrun.exe的路径?
我遇到了一些 Azure 计算模拟器无法正确重新启动的问题。为了解决这个问题,我想在 Visual Studio 解决方案中的预构建步骤中添加 csrun /devfabric:stop
调用。
问题是 csrun.exe 位于我的计算机上的 C:\Program Files\Windows Azure SDK\v1.4\bin
中,并且该路径不在 %PATH%
上> 目录列表。我不想在我的解决方案中硬编码该路径。
有没有某种方法可以推断出路径,例如使用某些环境变量或类似的东西?
I have some problems with Azure Compute Emulator not restarting properly. To resolve this I want to add csrun /devfabric:stop
call to a pre-build step in Visual Studio solution.
The problem is csrun.exe is located in C:\Program Files\Windows Azure SDK\v1.4\bin
on my machine and that path is not on the %PATH%
directories list. I don't want to hardcode that path in my solution.
Is there some way to deduce the path like using some environment variable or something similar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以按版本从注册表中读取 Azure SDK 路径。路径的最后一部分是版本...您的代码可以设置为版本,也可以迭代 v 键查找最新版本。我建议您为您支持的版本设置一个常量,并且当您将新的 SDK 作为先决条件时。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v1.4
这些路径下有一个“InstallPath”键。
You can read the Azure SDK path from the registry by version. The last part of the path is the version ... Your code can either be set to a version or you can iterate over the v keys finding the latest. I would recommend having a constant for the version you support and as you take a new SDK as a pre-req.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v1.4
There's an "InstallPath" key under those paths.
我遇到了同样的问题,我生成了一个 PowerShell 脚本,该脚本使用 SDK bin 文件夹的路径设置环境变量。它会自动搜索注册表并找到最新安装的版本。它还可以回退到备用注册表位置,具体取决于您的脚本是在 32 位模式还是 64 位模式下运行。希望有帮助!
免责声明:在将脚本发布到此处之前,我从脚本中删除了一些内容,之后我没有对其进行测试,但我认为根据您的需要调试/调整它并不困难。
I had this same problem and I produced a PowerShell script that sets an environment variable with the path to the SDK bin folder. It will automatically search the registry and find the latest installed version. It also has a fallback to the alternate registry location, depending whether your script runs in 32bit or 64bit mode. Hope it helps!
Disclaimer: I removed some stuff from the script before posting it here and I didn't test it afterwards but I think it's not difficult to debug/adjust it to your needs.