- Enable Windows Feature named '.NET Framework 3.5 (includes .NET 2.0 and 3.0)'.
- .NET Compact Framework 3.5 Redistributable: https://www.microsoft.com/en-us/download/details.aspx?id=65
- Power Toys for .NET Compact Framework 3.5: https://www.microsoft.com/en-us/download/details.aspx?id=13442
- Copy files and directories from 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\*' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5';
- Copy files from 'C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\Debugger\BCL\*' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\CompactFramework' directory;
- Create 'RedistList' directory inside created 'CompactFramework' directory;
- Create 'FrameworkList.xml' inside 'RedistList' directory and type the following:
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>
If do not care to add a dependency to the project to support 'net35-cf' build, configure the project as follows:
project.csproj
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net35-cf</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NETStandard.WindowsCE" Version="1.4.0" />
</ItemGroup>
Otherwise, if do not want to use any support package. You must to configure the project as follows:
project.csproj
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net35-cf</TargetFrameworks>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net35-cf'">
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>CompactFramework</TargetFrameworkProfile>
<DefineConstants>$(DefineConstants);NET35_CF;WindowsCE</DefineConstants>
<DisableImplicitFrameworkReferences>True</DisableImplicitFrameworkReferences>
<NoStdLib>True</NoStdLib>
<NoConfig>true</NoConfig>
<FileAlignment>512</FileAlignment>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
<Optimize>False</Optimize>
</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" />
<Reference Include="System.Data, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
<Reference Include="System.Runtime.Serialization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
<Reference Include="System.Xml, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
<Reference Include="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" />
</ItemGroup>
- Use 'net35-cf' or '.NETFramework,Version=v3.5,Profile=CompactFramework' TFM.
project.json
{
"frameworks": {
"net35-cf": {
"frameworkAssemblies": {
"mscorlib": "",
"System": "",
"System.Core": ""
}
}
}
}
PropertyGroup
<NoStdLib>True</NoStdLib>
<NoConfig>true</NoConfig>
<FileAlignment>512</FileAlignment>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
ItemGroup
<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" />
Project
<Import Project="$(SolutionDir)Microsoft.CompactFramework.CSharp.targets" />
- Path: C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
- On 'C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CompactFramework.CSharp.targets' file replace '$(MSBuildBinPath)' by 'C:\Windows\Microsoft.NET\Framework\v3.5'.
- On .CSPROJ file, replace '$(MSBuildBinPath)' by 'C:\Windows\Microsoft.NET\Framework\v3.5'.
I came up with the following solution.
This at least saves you the trouble of manually installing deps off MS website. We push this build env image to our Docker Registry, and the use it for running CF-specific builds as usual. Maybe we can also tackle the second approach (compiling with modern MSBuild), that's just a few steps away.