我当时正在开发一个工具,一切都运行得很好.能够出版.然而,在最近更新到Visual Studio 17.7.1之后,我得到了各种没有任何意义的问题.例如,最近,它开始输出以下内容:

1&>assets资源 文件 ‘C:\Users\username\source\repos\vpr\vpr\obj\project.assets.json’ 没有‘net7.0’的目标.确保已运行恢复并 您已在TargetFrameworks中为您的 项目.

但这个项目有以下csproj个文件:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
        <TargetFrameworks>net7.0</TargetFrameworks>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

</Project>

有时它也会抱怨其他项目也是如此,但他们有net7.0套.有时还有其他错误,但没有一个是真正有意义的.

  1. 我已try 将其设置为TrueFalse:

    enter image description here

  2. 我还试图从所有的项目中删除所有的binobj,并使用Clean解决方案,每个项目,然后Rebuild没有成功.

  3. 我也试过跑dotnet restore -r win-x86米和dotnet restore -r win-x64米.

  4. 我还try 重新安装了Visual Studio.因此,目前我无法回滚到以前版本的Visual Studio.

我的应用程序在DebugRelease中运行得很好,但发布却搞砸了.我不记得在Visual Studio更新前后有什么重要的更改.有没有其他人在最近的Visual Studio更新中遇到同样的问题,还有其他 Select 可以try 吗?

推荐答案

我也try 在Windows和Android平台上发布.NET Maui应用程序.但我也没能用Visual Studio做到这一点.我所做的是我忽略了Visual Studio,遵循了微软提供的publish .NET MAUI apps using CLI指南

这是我从CLI到publish .NET MAUI Application for Android平台的教程

我相信您将从这些指导方针中准确地解决您的问题,因为这对我的几个.NET Maui项目都有效.

以下是用于Windows自动版本控制和发布的PowerShell脚本

$FilePath = "Platforms/Windows/Package.appxmanifest"


#Load XML Content
$xml = [xml](Get-Content $FilePath)



# Get identity Element
$IdentityElement = $xml.Package.Identity

echo "Your Current Version"
$IdentityElement.Version
echo "________________________"

# Get the current version Number
$version = $IdentityElement.Version.Split(".") | ForEach-Object { [int]$_ }

# Increment values

$response = Read-Host "Do you Update Major Version ? (Y / N) "

if($response -eq "y" -or $response -eq "Y"){
    $version[0]++
}

$response = Read-Host "Do you Update Minor Version ? (Y / N) "

if($response -eq "y" -or $response -eq "Y"){
    $version[1]++
}
$response = Read-Host "Do you Update Build Number ? (Y / N) "

if($response -eq "y" -or $response -eq "Y"){
    $version[2]++
}
$response = Read-Host "Do you Update Revision Number ? (Y / N) "

if($response -eq "y" -or $response -eq "Y"){
    $version[3]++
}

# Update version with new one
$IdentityElement.Version = "$($version[0]).$($version[1]).$($version[2]).$($version[3])"

$CLoc = Get-Location


$combined = Join-Path $CLoc $FilePath


# Save the updated xml files
$xml.Save($combined)

$resp = Read-Host "Do you want to build now? (Y/N)"

if($resp -eq "Y" -or $resp -eq "y"){
    dotnet publish -f net7.0-windows10.0.19041.0 -c Release
}

Pause

这是适用于Android的PowerShell脚本

$FilePath = "Platforms/Android/AndroidManifest.xml"

$xml = [xml](Get-Content $FilePath)

$currentVersion = $xml.manifest.'versionCode'

$re = Read-Host "Do you wish to increment version number ? (Y / N)";

if($re -eq "Y" -or $re -eq "y"){
    $newVersion = [int]$currentVersion + 1
    $versionName = Read-Host "Give Version Name : "
    $xml.manifest.'versionCode' = $newVersion.ToString()
    $xml.manifest.versionName = $versionName.ToString()
}

$CLoc = Get-Location


$combined = Join-Path $CLoc $FilePath


# Save the updated xml files
$xml.Save($combined)

$resp = Read-Host "Do you want to build now? (Y/N)"

if($resp -eq "Y" -or $resp -eq "y"){
    dotnet publish -f:net7.0-android -c:Release /p:AndroidSigningKeyPass=[your_pwd] /p:AndroidSigningStorePass=[your_pwd]
}

Pause

Csharp相关问答推荐

C# uwp中的Win11启动屏幕剪辑工作方式不同

ASP.NET MVC购物车数量更新并从购物车中删除项目

程序集.加载从exe的异常

读取配置文件(mytest. exe. config)

为什么Blazor值在更改后没有立即呈现?

如果存在对CodeAnalysis.CSharp的引用,则不能引用netStandard2.0库

如何注册接口类型,类型<>

从ASP.NET Core中的枚举字段填充 Select 选项时,将默认的第一个选项添加为 Select 元素

为什么EventInfo.EventHandlerType返回可为空的Type值?

用C#从Word文档中删除重复的节控件和文本内容控件

单行上的ReSharper数据标注

使用泛型可空类实现接口

Linux Docker上的.NET6在某个时间抛出后,在加密操作期间发生System.Security.Cryptography.CryptographicException:错误

无法将生产环境的AppDbContext设置替换为用于集成测试的内存数据库

链接到字典字符串.拆分为(.Key,.Value)

我什么时候应该在Dapper中使用Connection.OpenAsync?

正在从最小API-InvocationConext.Arguments中检索参数的FromBodyAttribute

将C#类导入到PowerShell

使DefaultIfEmpty返回空

C#-如何将int引用获取到byte[]