使用PowerShell v7.3.1安装Google.Apis.Calendar.v3遇错,求正确方法
正确安装Google.Apis.Calendar.v3的步骤(PowerShell 7.3.1环境)
先修复PowerShellGet和NuGet源配置:
- 卸载所有旧版PowerShellGet:
Uninstall-Module PowerShellGet -AllVersions -Force - 安装最新版并允许覆盖现有模块:
Install-Module PowerShellGet -Force -AllowClobber - 注册官方NuGet源并标记为可信:
Register-PackageSource -Name NuGet -Location https://api.nuget.org/v3/index.json -ProviderName NuGet -Trusted - 执行
Get-PackageSource检查,确保NuGet源状态为Trusted且Enabled
- 卸载所有旧版PowerShellGet:
换用.NET CLI安装(PowerShell的
Install-Package对部分NuGet包支持存在兼容性问题):- 先安装匹配版本的.NET SDK(推荐.NET 6或7,与PowerShell 7.3.1的运行环境一致)
- 运行安装命令:
dotnet add package Google.Apis.Calendar.v3 - 若需在PowerShell脚本中引用,直接加载对应dll:
Add-Type -Path "你的包安装路径\Google.Apis.Calendar.v3.dll"
手动安装兜底方案:
- 到NuGet官网搜索Google.Apis.Calendar.v3,下载对应的.nupkg包
- 解压包到本地目录,找到
lib文件夹下适配.NET Standard或.NET Core版本的dll文件(比如netstandard2.0目录下的文件) - 在PowerShell中加载dll:
Add-Type -Path "C:\解压后的路径\lib\netstandard2.0\Google.Apis.Calendar.v3.dll"
环境兼容性检查:
- 执行
$PSVersionTable查看运行环境,确认PowerShell 7.3.1基于.NET 6+运行,不要仅依赖.NET Framework 4.8.1
- 执行
内容的提问来源于stack exchange,提问作者aristosv
相关产品推荐
相关产品推荐

