因此,您可以通过一些 csproj 调整在 VS2012 中构建 CF 3.5。首先安装 NETCFSetupv35.msi 和 NETCFv35PowerToys.msi。您可能需要使用以下 reg hack 来修复 x64 位内容。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0]
"Language"="1033"
"Version"="3.5.7283"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\InstallRoot]
@="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\PocketPC]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\PocketPC\AsmmetaBinder]
"TypeName"="Microsoft.CompactFramework.Build.PocketPC.BindingService, Microsoft.CompactFramework.Build.Tasks, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\PocketPC\AsmmetaBinder\4118C335-430C-497f-BE48-11C3316B135E]
"TypeName"="Microsoft.CompactFramework.Build.WM50PocketPC.BindingService, Microsoft.CompactFramework.Build.Tasks, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\PocketPC\AssemblyFoldersEx]
@="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\WindowsCE\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\PowerToys]
"Language"="1033"
"Version"="3.5.7338"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\PowerToys\InstallRoot]
@="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\Smartphone]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\Smartphone\AsmmetaBinder]
"TypeName"="Microsoft.CompactFramework.Build.SmartPhone.BindingService, Microsoft.CompactFramework.Build.Tasks, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\Smartphone\AsmmetaBinder\BD0CC567-F6FD-4ca3-99D2-063EFDFC0A39]
"TypeName"="Microsoft.CompactFramework.Build.WM50SmartPhone.BindingService, Microsoft.CompactFramework.Build.Tasks, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\Smartphone\AssemblyFoldersEx]
@="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\WindowsCE\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\WindowsCE]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\WindowsCE\AsmmetaBinder]
"TypeName"="Microsoft.CompactFramework.Build.WindowsCE.BindingService, Microsoft.CompactFramework.Build.Tasks, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetCompactFramework\v3.5.0.0\WindowsCE\AssemblyFoldersEx]
@="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\CompactFramework\\v3.5\\WindowsCE\\"
然后,您将需要创建一个与此类似的新 .target 文件。
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(BuildForWinCE)' == 'true'">
<MSBuildBinPathCF>C:\Windows\Microsoft.NET\Framework\v3.5</MSBuildBinPathCF>
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
<IntermediateOutputPath>obj\WinCE</IntermediateOutputPath>
<OutputPath>bin\WinCE</OutputPath>
<FrameworkRegistryBase>Software\Microsoft\.NETCompactFramework</FrameworkRegistryBase>
<AssemblyFoldersSuffix>$(PlatformFamilyName)\AssemblyFoldersEx</AssemblyFoldersSuffix>
<AssemblyFoldersExConditions>,OSVersion=$(OSVersion):Platform=$(PlatformID)</AssemblyFoldersExConditions>
<TargetCompactFramework>true</TargetCompactFramework>
<DefineConstants>$(DefineConstants);WindowsCE</DefineConstants>
<NoStdLib>false</NoStdLib>
</PropertyGroup>
</Project>
然后你可以在你的 csproj 中包含你的新目标文件和条件紧凑框架目标
<Import Project="Compact.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Condition="'$(BuildForWinCE)' == 'true'" Project="$(MSBuildBinPathCF)\Microsoft.CompactFramework.Common.targets" />
当您要为 WinCE 构建时,只需设置以下参数。
BuildForWinCE=true