.Net 核心预发布版本上框架程序集的间接依赖
Indirect dependency on the framework assembly on .Net core prerelease version
我正在用 .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.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.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 Core 的引用添加为包而不是像这样的 DLL:
<PackageReference Include="System.Reflection.Emit">
<Version>4.0.1</Version>
</PackageReference>
我正在用 .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.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.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 Core 的引用添加为包而不是像这样的 DLL:
<PackageReference Include="System.Reflection.Emit">
<Version>4.0.1</Version>
</PackageReference>