代码之家  ›  专栏  ›  技术社区  ›  tmaj

引用Windows SDK winmd文件和vs team services build

  •  1
  • tmaj  · 技术社区  · 7 年前

    我创建了一个C.NET标准库,它引用了两个Windows SDK库。

    参考文献是

      >代码> C:\程序文件(x86)\ Windows工具包\ 10 \引用\\0.0.1629 .0\Windows .Fase.基础合同\3.0.0.0\Windows .Fase.基础合同. WINMD >代码> C:\程序文件(x86)\ Windows工具包\\\\\\\0.0.1695.0\Windows .Funtual.UnvialSalpCopaTy[5.0.0.0\WINDOWS .BuffelalSalpCouSouth.WINMD

    这在我的本地dev机器上工作。

    vs team services build first显示以下警告:

    2018-06-13t01:17:22.3393846Z[警告]C:\Program Files(x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\microsoft.common.currentversion.targets(2106,5):警告:无法解析此引用。无法找到程序集“Windows .Fase.基础合同”。检查以确保磁盘上存在程序集。如果代码需要此引用,则可能会出现编译错误。

    稍后失败,错误如下:

    错误CS0246:找不到类型或命名空间名称“windows”(是否缺少using指令或程序集引用?)

    天真地,我认为我只需要在Visual Studio中将copy local设置为true,一切都会好起来。我错了。

    问题

    如何在vsts中构建引用sdk winmd files的项目?

    参考文献是

    • C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd
    • C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.UniversalApiContract\5.0.0.0\Windows.Foundation.UniversalApiContract.winmd

    这在我的本地dev机器上工作。

    vs team services build first显示以下警告:

    2018-06-13T01:17:22.3393846Z ##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Windows.Foundation.FoundationContract". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

    稍后失败,错误如下:

    Error CS0246: The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)

    天真地,我认为我只需要在Visual Studio中将copy local设置为true,一切都会好起来。我错了。

    问题

    如何在VSTS中构建引用SDK的项目 winmd 文件夹?

    1 回复  |  直到 6 年前
        1
  •  4
  •   starian chen-MSFT    7 年前

    请参考以下步骤处理此问题:

    1. 右键单击Visual Studio中的项目>编辑项目名称
    2. 将这些程序集的相对路径替换为绝对路径

    样本代码:

    <ItemGroup>
        <Reference Include="Windows.Foundation.FoundationContract">
          <HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd</HintPath>
          <IsWinMDFile>true</IsWinMDFile>
        </Reference>
        <Reference Include="Windows.Foundation.UniversalApiContract">
          <HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.UniversalApiContract\5.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath>
          <IsWinMDFile>true</IsWinMDFile>
        </Reference>
      </ItemGroup>