簡體   English   中英

我想發布項目時無法恢復 csproj 文件

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

我正在嘗試制作 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 => Options => Package sources => 啟用nuget.org

此外,為了使您的項目獨立於您的 VS 設置,可以將其添加到.csproj

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

PS 我在標簽中看到了Visual studio 2017 ,但是您只能使用 2022 一個來構建 .NET 6 個應用程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM