使用Visual Studio 2022发布Photino Blazor应用到Linux x64失败
问题场景
首次构建Photino Blazor应用并发布到Linux环境,使用官方示例代码后,发布过程中触发以下错误:
'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/tryphotino/b45daa6f-eacf-476b-a99e-56768f5ea55d/_packaging/c61f04ae-4aea-4fce-97a1-e4f3e91b26f3/nuget/v3/flat2/microsoft.netcore.app.host.linux-x64/index.json'.
1>Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.netcore.app.host.linux-x64'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: E7D3E76A-84FE-41B8-9F30-57349A52AC91)).
发布配置选项如下:
问题原因
项目文件夹中存在的Nuget.config文件内容如下:
<packageSources> <clear /> <add key="PhotinoPackages" value="https://pkgs.dev.azure.com/tryphotino/Photino.Native/_packaging/PhotinoPackages/nuget/v3/index.json" /> </packageSources>
其中<clear />指令会清除所有默认的NuGet源(包括微软官方NuGet源),导致发布所需的microsoft.netcore.app.host.linux-x64包只能从Photino的私有源查找。但该源并不包含此.NET运行时包,且未提供对应访问权限,因此触发401未授权错误。
解决方案
直接删除项目文件夹中的Nuget.config文件,让系统使用默认的NuGet源列表。此时发布过程既能正常拉取Photino相关依赖包,也能从微软官方源获取所需的.NET运行时包,发布即可恢复正常。
内容的提问来源于stack exchange,提问作者EvaHHHH

