Dav*_*ans 1 .net c# csproj project.json .net-standard
在project.json项目系统下,我能够指定每个框架的框架程序集依赖关系。dotnet 文档(现已过时)显示了以下示例。
{
"frameworks":{
"net20":{
"frameworkAssemblies":{
"System.Net":""
}
},
"net35":{
"frameworkAssemblies":{
"System.Net":""
}
},
"net40":{
"frameworkAssemblies":{
"System.Net":""
}
},
"net45":{
"frameworkAssemblies":{
"System.Net.Http":"",
"System.Threading.Tasks":""
}
},
".NETPortable,Version=v4.5,Profile=Profile259": {
"buildOptions": {
"define": [ "PORTABLE" ]
},
"frameworkAssemblies":{
"mscorlib":"",
"System":"",
"System.Core":"",
"System.Net.Http":""
}
},
"netstandard16":{
"dependencies":{
"NETStandard.Library":"1.6.0",
"System.Net.Http":"4.0.1",
"System.Threading.Tasks":"4.0.11"
}
},
}
}
Run Code Online (Sandbox Code Playgroud)
对于更新后的 dotnet sdk v1.1.1,如何在 csproj 下执行此操作?我想引用 net40 的 System.Configuration,但不引用 netstandard 1.6。
谢谢 Pankaj - 我接受了你的建议的修改版本。关键是使用 Reference 元素。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net40</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
<PackageReference Include="Microsoft.Extensions.Options" Version="1.1.0" />
<PackageReference Include="Common.Logging" Version="3.4.0-Beta2" />
<PackageReference Include="NLog" Version="5.0.0-beta06" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
<PackageReference Include="Common.Logging" Version="3.3.0" />
<PackageReference Include="NLog" Version="4.1.1" />
<PackageReference Include="Common.Logging.NLog40" Version="3.3.0" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<Folder Include="Console\" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1450 次 |
最近记录: |