使用vs2022和windows11来编译squirrel window
编译条件
- vs2022
- winodws 11
下载代码
git clone https://github.com/squirrel/squirrel.windows
cd squirrel.windows
git submodule update --init --recursive ## THIS IS THE PART YOU PROBABLY FORGOT
编译运行
开发运行的命令
devbuild.cmd
release发布的命令
./src/build_official.cmd
错误汇总
nuget命令找不到
安装nuget,可以通过scoop install nuget
,或者直接下载https://nuget.org/nuget.exe, 然后添加到PATH里面。
msbuild命令找不到
安装完vs2022后,应该是默认带了msbuild命令,但是不在PATH里面,需要手动添加,如下图
nuget下载不到不了依赖包
具体的错误信息如下:
Errors in packages.config projects
Unable to find version '1.26.0' of package 'ILRepack'.
C:\Users\payne\.nuget\packages\: Package 'ILRepack.1.26.0' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'ILRepack.1.26.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'Microsoft.Data.Edm'.
C:\Users\payne\.nuget\packages\: Package 'Microsoft.Data.Edm.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.Data.Edm.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'Microsoft.Data.Services.Client'.
C:\Users\payne\.nuget\packages\: Package 'Microsoft.Data.Services.Client.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.Data.Services.Client.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'Microsoft.Data.OData'.
C:\Users\payne\.nuget\packages\: Package 'Microsoft.Data.OData.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.Data.OData.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'System.Spatial'.
C:\Users\payne\.nuget\packages\: Package 'System.Spatial.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'System.Spatial.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '1.26.0' of package 'ILRepack'.
C:\Users\payne\.nuget\packages\: Package 'ILRepack.1.26.0' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'ILRepack.1.26.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'Microsoft.Data.OData'.
C:\Users\payne\.nuget\packages\: Package 'Microsoft.Data.OData.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.Data.OData.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'System.Spatial'.
C:\Users\payne\.nuget\packages\: Package 'System.Spatial.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'System.Spatial.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'Microsoft.Data.Services.Client'.
C:\Users\payne\.nuget\packages\: Package 'Microsoft.Data.Services.Client.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.Data.Services.Client.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Unable to find version '5.6.1' of package 'Microsoft.Data.Edm'.
C:\Users\payne\.nuget\packages\: Package 'Microsoft.Data.Edm.5.6.1' is not found on source 'C:\Users\payne\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.Data.Edm.5.6.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Errors in C:\Users\payne\Code\Squirrel.Windows\src\Update\Update.csproj
NU1101: Unable to find package ILRepack. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.NETFramework.ReferenceAssemblies. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.SourceLink.GitHub. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Nerdbank.GitVersioning. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package WpfAnimatedGif. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.CSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.Web.Xdt. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Mono.Cecil. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package SharpCompress. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package System.Net.Http. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
Errors in C:\Users\payne\Code\Squirrel.Windows\src\Update\Update-Mono.csproj
NU1101: Unable to find package ILRepack. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.NETFramework.ReferenceAssemblies. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.SourceLink.GitHub. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Nerdbank.GitVersioning. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package WpfAnimatedGif. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.CSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.Web.Xdt. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Mono.Cecil. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package SharpCompress. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package System.Net.Http. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
Errors in C:\Users\payne\Code\Squirrel.Windows\src\SyncReleases\SyncReleases.csproj
NU1101: Unable to find package ILRepack. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.NETFramework.ReferenceAssemblies. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.SourceLink.GitHub. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Nerdbank.GitVersioning. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Octokit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.CSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.Web.Xdt. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Mono.Cecil. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package SharpCompress. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package System.Net.Http. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
Errors in C:\Users\payne\Code\Squirrel.Windows\test\Squirrel.Tests\Squirrel.Tests.csproj
NU1103: Unable to find a stable package Microsoft.NET.Test.Sdk with version (>= 15.8.0)
- Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 17.10.0-preview-24080-01 ]
NU1101: Unable to find package Microsoft.NETFramework.ReferenceAssemblies. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.SourceLink.GitHub. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Nerdbank.GitVersioning. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package xunit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package xunit.runner.visualstudio. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.CSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.Web.Xdt. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Mono.Cecil. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package SharpCompress. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package System.Net.Http. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
Errors in C:\Users\payne\Code\Squirrel.Windows\src\Squirrel\Squirrel.csproj
NU1101: Unable to find package Microsoft.CSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.NETFramework.ReferenceAssemblies. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.SourceLink.GitHub. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.Web.Xdt. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Mono.Cecil. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Nerdbank.GitVersioning. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package SharpCompress. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package System.Net.Http. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package Microsoft.Win32.Registry. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
NU1101: Unable to find package NETStandard.Library. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
解决方法,就是添加nuget的源就可以了。通过dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
添加就可以解决了。
vc 142版本找不到
squirrel windows项目里面配置是vc 142, 是2019的版本,而vs2022默认带的是vc 143的,这两个是不匹配的。 不过可以直接在vs installer里面安装vc 142, 如下图。安装完成后就不会再报这个错误了。
.NETFramework 4.5找不到
vs2022已经默认不带4.5了,具体报错如下:
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1259,5)
: error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Develope
r Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer
Packs at https://aka.ms/msbuild/developerpacks [C:\Users\payne\Code\Squirrel.Windows\vendor\nuget\src\Core\Core.csproj]
4.5 net在vs2022里面已经没有了,需要手动安装。 从nuget下载net 4.5的,下载地址: Microsoft.NETFramework.ReferenceAssemblies.net45.
然后将下载的net45解压,并将里面的4.5(microsoft.netframework.referenceassemblies.net45.1.0.3\build.NETFramework\v4.5)复制到 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
就可以解决这个错误了。
https://thomaslevesque.com/2021/11/12/building-a-project-that-target-net-45-in-visual-studio-2022/
stdafx找不到的错误
C:\Users\payne\Code\Squirrel.Windows\src\Setup\stdafx.h(27,10): fatal error C1083: 无法打开包括文件: “atlbase.h”: No such file or dire
ctory [C:\Users\payne\Code\Squirrel.Windows\src\Setup\Setup.vcxproj]
在 Visual Studio 2022 中,ATL 和 MFC 不再是默认安装的组件,需要通过 Visual Studio Installer 单独添加。
上面的错误都解决了,devbuild终于通过了,可以编译成功了。
StartDeveloperCommandPrompt错误
运行./src/build_official.cmd的时候,直接报下面的错误
The system cannot find the batch label specified - StartDeveloperCommandPrompt
需要将这个脚本里面的的lf换成crlf.
net3.5找不到的错误
运行./src/build-official.cmd的时候会报下面的错误,主要是net3.5没有安装导致的。
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5
933,5): error MSB3073: The command " [C:\Users\payne\Code\Squirrel.Windows\src\SyncReleases\SyncReleases.csproj]
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5
933,5): error MSB3073: cd "C:\Users\payne\Code\Squirrel.Windows\build\Release\net45\" [C:\Users\payne\Code\Squirrel.Wind
ows\src\SyncReleases\SyncReleases.csproj]
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5
933,5): error MSB3073: "C:\Users\payne\.nuget\packages\ilrepack\1.26.0\tools\ILRepack.exe" /internalize /out:SyncRelease
s.exe.tmp SyncReleases.exe SharpCompress.dll Microsoft.Web.XmlTransform.dll Squirrel.dll Octokit.dll NuGet.Squirrel.dll [C:\Us
ers\payne\Code\Squirrel.Windows\src\SyncReleases\SyncReleases.csproj]
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5
933,5): error MSB3073: del "SyncReleases.exe" [C:\Users\payne\Code\Squirrel.Windows\src\SyncReleases\SyncReleases.csproj
]
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5
933,5): error MSB3073: ren "SyncReleases.exe.tmp" "SyncReleases.exe" [C:\Users\payne\Code\Squirrel.Windows\src\SyncRelea
ses\SyncReleases.csproj]
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5
933,5): error MSB3073: " exited with code 1. [C:\Users\payne\Code\Squirrel.Windows\src\SyncReleases\SyncReleases.csproj]
这个会弹出安装.net3.5的界面,点击安装,等安装完成net3.5后,重启程序,重新编译。
发布
运行./src/build_official.cmd
命令,没有任何错误后,如下图。就可以在build/release下面找到发布的产物了。