【问题标题】:Adding .targets file to .NET framework nuget won't import properly in .Net Core project将 .targets 文件添加到 .NET 框架 nuget 不会在 .Net Core 项目中正确导入
【发布时间】:2022-01-19 02:49:17
【问题描述】:

我有一个创建 nuget (RawDataConverter.nuget) 的项目。框架类型为 .NET Framework 4.5.2。

我有一个项目,我将 RawDataConverter.nuget 导入 (GeoApp)。 GeoApp 的框架类型是 .NET Core 2.1。我从来没有遇到过将 RawDataConverter.nuget 导入 GeoApp 的问题。

我最近向 RawDataConverter.nuget 添加了一个 .targets 文件,突然 GeoApp 抛出了与 nuget 相关的错误。我收到了几个 "The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?" 错误,好像 nuget 根本没有导入一样。

这是 .targets 文件:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <NativeLibs Include="$(MSBuildThisFileDirectory)\..\runtimes\win10-x64\native\*.dll" />
    <None Include="@(NativeLibs)">
      <Link>%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>

以前有人见过这种行为吗?由于这个 .targets 文件,我猜 nuget 没有在 GeoApp 中正确导入,但我不知道为什么。

【问题讨论】:

    标签: c# .net-core nuget target


    【解决方案1】:

    想通了。必须将此行添加到 nuspec 文件中:

    <file src="..\Release64\Miw.Mshdf.Net.dll" target="lib\netcoreapp2.1"/>
    

    关于不同库的信息:https://docs.microsoft.com/en-us/nuget/reference/target-frameworks

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-04
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 2021-12-07
      相关资源
      最近更新 更多