解决 .net core 发布项目提示 [响应状态代码不指示成功: 401 (Unauthorized)。] 的问题

环境:Visual Studio 2017,.NET Core 2.2,控制台项目


因为项目要到其他项目拿数据,他们给过来的接口是webservice。

按照一般做法,我添加webservice引用,然后就可以愉快的跑起来了。。。

然后在发布的时候就出问题了,报401错误 [响应状态代码不指示成功: 401 (Unauthorized)。]

原因是添加webservice引用的时候自动添加的几个程序集,如下

发布提示错误截图如下

解决办法 

在项目目录中创建一个包含以下内容的NuGet.config文件: 

扫描二维码关注公众号,回复: 12883139 查看本文章

在 NuGet.config文件中添加下面配置信息:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<packageSources>
		<!--To inherit the global NuGet package sources remove the <clear/> line below -->
		<clear />
		<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
		<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
	</packageSources>
</configuration>

 这样就能解决发布提示401的问题了。


感谢这位老哥 https://github.com/dotnet/sdk/issues/6295

猜你喜欢

转载自blog.csdn.net/u012835032/article/details/114256032