繁体   English   中英

使用新的.csproj格式的.NET Compact Framework 3.5的多目标?

[英]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要点 -详细而言,我已完成以下操作:

  1. 已安装.NET CF 3.5和Power Toys
  2. 更换$(MSBuildBinPath)C:\\Windows\\Microsoft.NET\\Framework\\v3.5在文件C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\Microsoft.CompactFramework.CSharp.targets
  3. 从复制了所有文件
    • C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\WindowsCE
    • C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v3.5\\Profile\\CompactFramework
  4. 在上述文件夹中创建的文件RedistList\\FrameworkList.xml具有以下内容:

    <?xml version="1.0" encoding="utf-8"?> <FileList Redist="Net35-CF" Name=".NET Compact Framework 3.5"> </FileList>

  5. 添加了注册表项HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v3.5,Profile=CompactFramework (只是键,没有值)

  6. 创建新项目,设置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>

但是,当我尝试编译代码时,出现以下错误消息:

新的csproj的net35-cf错误

看来一般的编译工作正常,但是AssemblyFileVersionAttribute不是紧凑框架的一部分吗?

更新1 :删除net35-cf TFM时,项目编译正常。

谢谢您的帮助!

您可以通过在.csproj文件中指定so来禁用AssemblyFileVersionAttributeAssemblyVersionAttribute的生成。

<PropertyGroup "'$(TargetFramework)' == 'net35-cf'">
    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>

参考: 等效于dotnet core / csproj中的AssemblyInfo

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM