我正在尝试创建C代码的exe文件,并使用此设置在一个文件中创建它。但是,它在恢复csproj时失败,并返回此错误消息:
Build started...
1>------ Build started: Project: Email-gen, Configuration: Release Any CPU ------
1>Email-gen -> C:\Users\Mohammed\source\repos\Email-gen\Email-gen\bin\Release\net6.0\Email-gen.dll
2>------ Publish started: Project: Email-gen, Configuration: Release Any CPU ------
2>Determining projects to restore...
2>Unable to find package Microsoft.NETCore.App.Runtime.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
2>Unable to find package Microsoft.WindowsDesktop.App.Runtime.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
2>Unable to find package Microsoft.AspNetCore.App.Runtime.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
2>Failed to restore C:\Users\Mohammed\source\repos\Email-gen\Email-gen\Email-gen.csproj (in 774 ms).
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
这个csproj文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Email_gen</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
请确保启用了Nuget基本源,因为根据您的日志,它仅在脱机搜索包。
Visual Studio菜单:Tools
=
此外,为了使您的项目独立于您的VS设置,这可以添加到. csproj
中:
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json
</RestoreAdditionalProjectSources>
另外,我在标签中看到了Visual studio 2017
,但您只能使用2022 one来构建。NET6应用程序