[英]Multi-target with .NET Compact Framework 3.5 using new .csproj format?
是否可以使用新的.csproj
文件格式定位.NET Compact Framework 3.5? 我希望能够针对以下框架:
<TargetFrameworks>netstandard2.0;netstandard1.0;net45;net40;net35;net35-cf</TargetFrameworks>
到目前为止,我所做的工作基于此GitHub要点 -详细而言,我已完成以下操作:
$(MSBuildBinPath)
与C:\\Windows\\Microsoft.NET\\Framework\\v3.5
在文件C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\Microsoft.CompactFramework.CSharp.targets
C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\WindowsCE
到 C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v3.5\\Profile\\CompactFramework
在上述文件夹中创建的文件RedistList\\FrameworkList.xml
具有以下内容:
<?xml version="1.0" encoding="utf-8"?> <FileList Redist="Net35-CF" Name=".NET Compact Framework 3.5"> </FileList>
添加了注册表项HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v3.5,Profile=CompactFramework
(只是键,没有值)
TargetFrameworks
并为net35-cf
添加条件属性组: <PropertyGroup Condition="'$(TargetFramework)' == 'net35-cf'">
<!-- inference fails for this TFM, so specify it by hand -->
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>CompactFramework</TargetFrameworkProfile>
<!-- define compilation constants by hand too -->
<DefineConstants>NET35_CF;WindowsCE</DefineConstants>
<!-- disable implicit references, these are specified by hand, below -->
<DisableImplicitFrameworkReferences>True</DisableImplicitFrameworkReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net35-cf' ">
<NoStdLib>True</NoStdLib>
<NoConfig>true</NoConfig>
<FileAlignment>512</FileAlignment>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net35-cf' ">
<Reference Include="mscorlib, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
<Reference Include="System, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
<Reference Include="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
</ItemGroup>
但是,当我尝试编译代码时,出现以下错误消息:
看来一般的编译工作正常,但是AssemblyFileVersionAttribute
不是紧凑框架的一部分吗?
更新1 :删除net35-cf
TFM时,项目编译正常。
谢谢您的帮助!
您可以通过在.csproj
文件中指定so来禁用AssemblyFileVersionAttribute
和AssemblyVersionAttribute
的生成。
<PropertyGroup "'$(TargetFramework)' == 'net35-cf'">
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.