Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 发布自包含的EXE时出现问题(Nuget时出现问题)_C#_Visual Studio_Windows 7_Nuget_Visual Studio 2019 - Fatal编程技术网

C# 发布自包含的EXE时出现问题(Nuget时出现问题)

C# 发布自包含的EXE时出现问题(Nuget时出现问题),c#,visual-studio,windows-7,nuget,visual-studio-2019,C#,Visual Studio,Windows 7,Nuget,Visual Studio 2019,我已经使用visual studio 2019在c#中创建了一个应用程序。当我发布它时,一切都很好,但exe在文件夹中还有另外两个文件。我希望只有一个exe可以自己运行,在它的位置上没有任何额外的文件,所以我尝试了“发布设置”中的“自包含”选项。但它没有起作用。我只得到一个“出错”弹出窗口,上面写着: Publish has encountered an error. Publish has encountered an error. We were unable to determine th

我已经使用visual studio 2019在c#中创建了一个应用程序。当我发布它时,一切都很好,但exe在文件夹中还有另外两个文件。我希望只有一个exe可以自己运行,在它的位置上没有任何额外的文件,所以我尝试了“发布设置”中的“自包含”选项。但它没有起作用。我只得到一个“出错”弹出窗口,上面写着:

Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 

A diagnostic log has been written to the following location:
"C:\Users\***\AppData\Local\Temp\tmp4E17.tmp"
在下面的输出框中,我得到:

1>Determining projects to restore...
1>Unable to load the service index for source 
https://api.nuget.org/v3/index.json.
1>  An error occurred while sending the request.
1>  The request was aborted: Could not create SSL/TLS secure 
channel.
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped 
==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
现在,我已经看到了一些类似的问题,人们发布了关于这一点和一些可能的修复,但没有任何工作为我。我已经在regedit中将tls1.3->Client->DisabledByDefault值更新为1,但仍然没有解决问题


我正在使用systemWindows7(32位)。我期待任何可能的修复,提前谢谢。

首先,请检查问题是否与网络或VS IDE有关

请输入链接
https://api.nuget.org/v3/index.json
在网站上,如果您无法打开网站,我认为问题与您的互联网有关,您应该检查您的互联网,确保没有其他东西破坏它

如果不是,我认为这个问题与VSIDE有关。您应该尝试以下步骤:

1)扩展下禁用任何第三方vs安装的扩展-->
管理扩展以检查是否存在导致此问题的扩展原因

2)或删除
C:\Users\xxx(当前用户)\.nuget\packages下的所有缓存文件

3)仅启用nuget.org nuget包源,禁用其他源

进入工具-->选项-->Nuget软件包管理器-->软件包源

取消选中其他包源,只保留
nuget.org

除了,您还可以将
nuget.org
包源更改为
http://packages.nuget.org/v1/FeedService.svc/
https://nuget.org/api/v2/
测试它是否可以重新解析nuget软件包

4)关闭VS,删除
C:\Users\xxx(当前用户)\AppData\Roaming\nuget
下的全局
nuget.config
文件。然后,重新启动VS以重新生成文件,再次测试

5)在CMD下运行这些命令(以管理员身份运行)


6)或将其更新为最新版本

我也有同样的问题-Visual Studio 2019,但Windows 7 64位。我无法在Visual Studio下使用自包含部署模式发布。我没有找到解决方案,但解决方案是可用的

解决方法

从命令行发布。在第一次运行期间,nuget将下载到本地缓存中,因此在此之后,在VisualStudio下发布也将起作用。例如:

dotnet publish ProjectName.csproj /p:PublishProfile=YourPublishProfileName
其他可能的解决方法


使用Windows10。我用同样的VisualStudio将项目移动到PC上,但使用的是Windows10。从Visual Studio works无问题发布。

能否与我们共享您使用的nuget名称?有关此问题的任何更新?请检查我的回答是否有助于您处理此问题?如果我的回答有助于你处理这个问题,请不要忘记。如果没有,请让我们知道您的任何担忧,您将进一步帮助您。我有与OP相同的问题。Nuget恢复每天都工作良好。问题仅在以选项“自包含”作为部署模式发布时可见。运行时.NET核心3.1和.NET 5。
dotnet publish ProjectName.csproj /p:PublishProfile=YourPublishProfileName