有没有办法以新的.csproj
文件格式定位.NET Compact Framework 3.5?我希望能够定位以下框架:
<TargetFrameworks>netstandard2.0;netstandard1.0;net45;net40;net35;net35-cf</TargetFrameworks>
到目前为止我所做的是基于这个GitHub gist - 详细地说,我做了以下事情:
$(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后,项目编译得很好。
提前感谢您的帮助!
答案 0 :(得分:1)
您可以通过在AssemblyFileVersionAttribute
文件中指定生成AssemblyVersionAttribute
和.csproj
来停用。
<PropertyGroup "'$(TargetFramework)' == 'net35-cf'">
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>