Reputation: 5718
Is there a way to target .NET Compact Framework 3.5 with the new .csproj
file format? I want to be able to target the following frameworks:
<TargetFrameworks>netstandard2.0;netstandard1.0;net45;net40;net35;net35-cf</TargetFrameworks>
What I've done so far is based on this GitHub gist - in detail, I've done the following:
$(MSBuildBinPath)
with C:\Windows\Microsoft.NET\Framework\v3.5
in file C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CompactFramework.CSharp.targets
C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE
to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\CompactFramework
Created file RedistList\FrameworkList.xml
in the above folder with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<FileList Redist="Net35-CF" Name=".NET Compact Framework 3.5">
</FileList>
Added registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v3.5,Profile=CompactFramework
(just key, no value)
TargetFrameworks
and added conditional property groups for 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>
However, when I try to compile my code, I get the following error message:
It seems that the general compilation is working, but the AssemblyFileVersionAttribute
is not part of the compact framework?
Update 1: when the net35-cf
TFM is removed, the project compiles just fine.
Thanks for your help in advance!
Upvotes: 1
Views: 1605
Reputation: 56849
You can disable generation of AssemblyFileVersionAttribute
and AssemblyVersionAttribute
by specifying so in the .csproj
file.
<PropertyGroup "'$(TargetFramework)' == 'net35-cf'">
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>
Reference: Equivalent to AssemblyInfo in dotnet core/csproj
Upvotes: 1