WAT080是否有解决方法:找不到Microsoft Azure SDK

时间:2018-09-24 16:24:53

标签: .net visual-studio azure msbuild azure-sdk

我正在构建一个需要安装Azure SDK的项目。不幸的是,我无法安装SDK,因为VSTools安装程序未在Docker容器中运行。我正在尝试重新创建安装程序执行的步骤,以便项目认为SDK已正确安装。我收到的错误消息是:

  

C:\ Program Files(x86)\ Microsoft Visual   Studio \ 2017 \ BuildTools \ MSBuild \ Microsoft \ VisualStudio \ v15.0 \ Windows   Azure Tools \ 2.9 \ Microsoft.WindowsAzure.targets(1093,5):错误:WAT080   :找不到Microsoft Azure SDK。请确保他   已安装Microsoft Azure SDK v2.9。   [C:\ BuildAgent \ work \ da35ef67e7dea9a9 \ EMCloudService \ EMCloudService.ccproj]

.targets文件中的第1093行是:

  <Target
      Name="VerifySDKInstallation"> // <---- Line 1093

    <WATMessage Condition=" !Exists('$(ServiceHostingSDKInstallDir)') or
                            !Exists('$(ServiceHostingSDKBinDir)') or
                            !Exists('$(ServiceHostingSDKTaskPath)') "
                Type="Error"
                Code="WAT080"
                Arguments="$(ActiveAzureSdkVersion)" />

    <WATMessage Condition=" !Exists('$(AzureClientLibInstallDir)') or
                            !Exists('$(AzureClientLibToolsRefDir)') or
                            !Exists('$(StorageClientAssemblyFullPath)') "
                Type="Error"
                Code="WAT081"
                Arguments="$(ActiveAzureClientLibVersion)" />

  </Target>

因此,似乎错误是因为这三个路径之一不存在。第一个来自以下行:

<ServiceHostingSDKInstallDir Condition=" '$(ServiceHostingSDKInstallDir)' == '' ">$([MSBuild]::GetRegistryValueFromView('$(ServiceHostingSDKRegistryKey)', 'InstallPath', null, RegistryView.Registry32))</ServiceHostingSDKInstallDir>

因此,基本上,它正在注册表中查找。我从一台正在运行的计算机上复制了此值,它的值为“ C:\ Program Files \ Microsoft SDKs \ Azure.NET SDK \”

我复制了该目录。下一个是ServiceHostingSDKBinDir,定义为:

<ServiceHostingSDKBinDir     Condition=" '$(ServiceHostingSDKBinDir)' == '' ">$(ServiceHostingSDKInstallDir)bin\</ServiceHostingSDKBinDir>

因为ServiceHostingSDKInstallDir存在,所以应该没问题。最后是ServiceHostingSDKTaskPath,它是:

<ServiceHostingSDKTaskPath   Condition=" '$(ServiceHostingSDKTaskPath)' == '' ">$(ServiceHostingSDKBinDir)Microsoft.ServiceHosting.Tools.MSBuildTasks.dll</ServiceHostingSDKTaskPath>

因此,似乎我真的应该能够复制“ C:\ Program Files \ Microsoft SDKs \ Azure.NET SDK \”目录,并为ActiveAzureSdkVersion和ServiceHostingSDKInstallDir传递正确的参数,并且一切正常:

msbuild EM.sln `
  /p:ActiveAzureSdkVersion="2.9" `
  /p:ServiceHostingSDKInstallDir="C:/Program Files/Microsoft SDKs/Azure/.NET SDK/"

但是,我仍然遇到相同的错误。有人能想到我需要复制或传递的其他内容吗?谢谢!

2 个答案:

答案 0 :(得分:1)

  

WAT080是否有解决方法:找不到Microsoft Azure SDK

根据文件Microsoft.WindowsAzure.targets(1093,5),我们可以获得以下代码片段:

  <PropertyGroup>
    <ActiveAzureSdkVersion Condition=" '$(ActiveAzureSdkVersion)' == '' ">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure Tools for Microsoft Visual Studio\15.0\v2.9', 'ActiveWindowsAzureVersion', null, RegistryView.Registry32))</ActiveAzureSdkVersion>
    <!-- Sdk reversion -->
    <ActiveAzureSdkVersion Condition=" '$(ActiveAzureSdkVersion)' == '' ">2.9</ActiveAzureSdkVersion>
    <ServiceHostingSDKRegistryKey>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v$(ActiveAzureSdkVersion)</ServiceHostingSDKRegistryKey>
    <ServiceHostingSDKInstallDir Condition=" '$(ServiceHostingSDKInstallDir)' == '' ">$([MSBuild]::GetRegistryValueFromView('$(ServiceHostingSDKRegistryKey)', 'InstallPath', null, RegistryView.Registry32))</ServiceHostingSDKInstallDir>

    <!-- Ensure ServiceHostingSDKInstallDir has a trailing slash, so it can be concatenated -->
    <ServiceHostingSDKInstallDir Condition=" '$(ServiceHostingSDKInstallDir)' != '' and !HasTrailingSlash('$(ServiceHostingSDKInstallDir)')">$(ServiceHostingSDKInstallDir)\</ServiceHostingSDKInstallDir>

    ...
    ...
  </PropertyGroup>

我们可以知道参数ServiceHostingSDKRegistryKey的值为:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v$(ActiveAzureSdkVersion)

很容易知道$(ActiveAzureSdkVersion)的值是 2.9 ,因此 ServiceHostingSDKInstallDir的值应该是参数{的InstallPath的值{1}}

然后,我们打开regedit并将路径切换到上述注册表项:

enter image description here

ServiceHostingSDKRegistryKey的值为InstallPath,而不是旧值C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\

此外,您还可以找到Azure SDK的位置也是C:\Program Files\Microsoft SDKs\Azure.NET SDK\,并在命令行中使用参数C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9指定了它。

因此,此问题的原因是注册表项的值不正确。尽管您用/p:ServiceHostingSDKInstallDir进行了重写,但是将/p:ServiceHostingSDKInstallDir导入项目文件并执行目标Microsoft.WindowsAzure.targets时,MSBuild / Visual Studio似乎将在其中调用参数$(ServiceHostingSDKInstallDir)基于邻近性原理的VerifySDKInstallation文件。

此问题的解决方法,您可以尝试将注册表项更改为正确的路径,或者如果您不想修改注册表,则可以尝试将SDK文件夹复制到旧路径.targets

希望这会有所帮助。

答案 1 :(得分:1)

想出了这一点。 真正的帮助是将以下内容添加到.targets文件中,位于第1093行以下:

<Message Text="ServiceHostingSDKInstallDir = $(ServiceHostingSDKInstallDir)" />
<Message Text="ServiceHostingSDKBinDir = $(ServiceHostingSDKBinDir)" />
<Message Text="ServiceHostingSDKTaskPath = $(ServiceHostingSDKTaskPath)" />

这让我看到了它试图寻找的路径。在构建输出中,然后得到:

ServiceHostingSDKInstallDir = C:/Program Files/Microsoft SDKs/Azure/.NET SDK/
ServiceHostingSDKBinDir = C:/Program Files/Microsoft SDKs/Azure/.NET SDK/bin\
ServiceHostingSDKTaskPath = C:/Program Files/Microsoft SDKs/Azure/.NET SDK/bin\Microsoft.ServiceHosting.Tools.MSBuildTasks.dll

因此,路径C:/Program Files/Microsoft SDKs/Azure/.NET SDK/bin\不存在,因为它缺少版本号。事实证明,ActiveAzureSdkVersion参数仅在通过注册表获取路径时使用,因此在我的情况下,将其传递毫无意义。相反,我需要将完整路径传递给SDK,包括版本:

  

MSBuild.exe。\ EM.sln / p:ServiceHostingSDKInstallDir =“ C:/ Program   文件/ Microsoft SDK / Azure / .NET SDK / v2.9 /“

希望这对某人有帮助!