2016-11-10 41 views
0

我正在做一些prerelase版本的.Net核心實驗。間接依賴於.Net核心預發佈版本上的框架程序集

我正在使用1.0.0-preview4-004071版本的.Net Core。 安裝.NET核心SDK,在的C創建1.0.3夾:\ Program Files文件\ DOTNET \共享\ Microsoft.NETCore.App以及在同一構建版本添加的二進制文件(全部來自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.SpecializedSystem.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無法找到正確的程序集並查看錯誤的路徑。

如何修復裝配路徑查找?

回答

1

引用到.NET的核心必須添加爲軟件包,而不是像這樣的DLL:

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