- 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'.
Thanks for the amazing article. I have successfully built a dll from a project I used to have to work on in Visual Studio 2008.
I am having some difficulty getting my compiled dll to get apparently get built with the same toolchain as in Visual studio 2008. My embedded device requires that the dlls used be signed and valid in a "Sandbox" - and System.Threading.Interlocked isn't allowed. Building the project with Visual Studio 2008 produces different output when viewed with DnSpy:
The problem is with multicast delegates, ie:
this.RecoverNotificationEvent += new DelegateNoParametersEvent(this.RecoverNotificationEventHandler);
2008 happily outputs this, which is a-OK:
Whereas vs2019 does this to the compiled output, which utilizes Interlocked which is not sandbox compatible:
My .csproj:
Any pointers/comments? I've been trying different methods throughout the last couple of days and I can't seem to get over this hurdle any way I go about it. I know what I'm hoping to do can be done, as someone I know in the same industry has no problem using Jetbrains Rider to specify the version of MSBuild and point at the CompactFrameWork.CSharp.targets file and get what he needs.