简体   繁体   English

我想发布项目时无法恢复 csproj 文件

[英]Failed to restore csproj file while i want to publish project

I am trying to make exe file of C# code and I used this settings to create it in one file.我正在尝试制作 C# 代码的 exe 文件,并使用此设置在一个文件中创建它。 However, it Failed while it restoring csproj and it return this error message:但是,它在恢复 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 ==========

This csproj file:这个 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>

This is settings of publisher这是发布者的设置
在此处输入图像描述 在此处输入图像描述

Please ensure the Nuget base source is enabled, as according to your logs it's only searching packages offline.请确保 Nuget 基本源已启用,因为根据您的日志,它仅离线搜索包。

Visual Studio Menu: Tools => Options => Package sources => enable nuget.org Visual Studio 菜单: Tools => Options => Package sources => 启用nuget.org

Also, to make your project independent from your VS settings this could be added to the .csproj :此外,为了使您的项目独立于您的 VS 设置,可以将其添加到.csproj

   <RestoreAdditionalProjectSources>
      https://api.nuget.org/v3/index.json
    </RestoreAdditionalProjectSources>

PS I see Visual studio 2017 in tags, but you can only use 2022 one to build .NET 6 apps PS 我在标签中看到了Visual studio 2017 ,但是您只能使用 2022 一个来构建 .NET 6 个应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么发布解决方案时csproj文件会更改? - Why is my csproj File Changing When I Publish a Solution? 每次我重新加载项目时,统一的 Csproj 文件都会更改 - Csproj file in unity changes everytime i reload the project 当我想发布项目时:“指定的路径、文件名或两者都太长” - When I want publish Project : “the specified path, file name, or both are too long” .CSProj文件中没有项目类型向导 - No project Type Guid in .CSProj file 我想用 MSBuild 为 .csproj 创建 ChooseElement 如何? - I want to create ChooseElement for .csproj with MSBuild How? 如何从复制恢复或安装 Nuget 包然后粘贴到 *.csproj 文件? - How to restore or install Nuget packages from copy then paste to *.csproj file? 生成 swagger 文件时无法在 Azure 应用服务上发布 - Failed to publish on Azure App Service while Generating swagger file 在C#中重置我的项目.csproj文件 - reset my project .csproj file in c# 是否可以将ReferencePath信息从.vbproj.user(或.csproj.user)文件移动到相应的项目文件中? - Can I move ReferencePath information from a .vbproj.user (or .csproj.user) file into the corresponding project file? 在.csproj中存储项目引用路径,而不是用户文件? - Store project reference paths in .csproj, not user file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM