【问题标题】:Indirect dependency on the framework assembly on .Net core prerelease version对 .Net core 预发布版本的框架程序集的间接依赖
【发布时间】:2017-10-14 03:36:24
【问题描述】:

我正在使用 .Net Core 的预发布版本进行一些实验。

我正在使用 1.0.0-preview4-004071 版本的 .Net Core。 安装了 .NET Core SDK,在 C:\Program Files\dotnet\shared\Microsoft.NETCore.App 中创建了 1.0.3 文件夹,并为相同的构建版本添加了二进制文件(所有从https://github.com/dotnet/cli#installers-and-binaries下载)。

我的 *.csproj 文件是:

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

<PropertyGroup>
   <OutputType>Exe</OutputType>
   <TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
   <Compile Include="**\*.cs" />
   <EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
   <PackageReference Include="Microsoft.NETCore.App">
   <Version>1.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Sdk">
   <Version>1.0.0-alpha-20161104-2</Version>
   <PrivateAssets>All</PrivateAssets>
</PackageReference> 
</ItemGroup>        
<Reference Include="System.Collections.Specialized"/>
<Reference Include="System.Collections.NonGeneric">
   <SpecificVersion>False</SpecificVersion>
   <HintPath>Lib\System.Collections.NonGeneric.dll</HintPath>
</Reference>
<Reference Include="System.Resources.ResourceManager"> 
   <SpecificVersion>False</SpecificVersion>  
   <HintPath>Lib\System.Resources.ResourceManager.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

在 Lib 文件夹下,我有来自同一版本的 DLL 副本。

我正在尝试使用 System.Collections.Specialized 和 System.Collections.NonGeneric DLL(试图从默认路径和 Lib 文件夹中获取)但收到这样的警告:

C:\Program Files\dotnet\sdk\1.0.0-preview4-004071\Microsoft.Common.CurrentVersion.targets(1909,5): warning MSB3268: The primary reference "System.Collections.NonGeneric" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Collections.NonGeneric" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 

C:\Program Files\dotnet\sdk\1.0.0-preview4-004071\Microsoft.Common.CurrentVersion.targets(1909,5): warning MSB3268: The primary reference "System.Collections.NonGeneric" could not be resolved because it has an indirect dependency on the framework assembly "System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Collections.NonGeneric" or retarget your application to a framework version which contains "System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

如果我是正确的问题是 msbuild 找不到正确的程序集并查看不正确的路径。

如何修复程序集路径查找?

【问题讨论】:

    标签: .net asp.net-core .net-core


    【解决方案1】:

    对 .Net Core 的引用必须作为包添加,而不是像这样的 DLL:

    <PackageReference Include="System.Reflection.Emit">
      <Version>4.0.1</Version>
    </PackageReference>
    

    【讨论】:

      猜你喜欢
      • 2012-03-12
      • 2018-02-10
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多