问题:子节点“2”过早退出。正在关闭。可以在“C:\Users\用户\AppData\Local\Temp找到诊断信息,打开MSBuild_*.failure.txt

本文详细描述了一种在Visual Studio中遇到的MSBuild子节点过早退出问题,探讨了多种尝试解决该问题的方法,最终确定问题源于控件资源文件的错误引用,并提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误问题描述:
子节点“2”过早退出。正在关闭。可以在“C:\Users\用户\AppData\Local\Temp找到诊断信息。。。打开MSBuild_*.failure.txt。。。设置环境。。。

解决过程:

1.百度找不到解决问题的答案,其中一条答案说是什么虚拟内存或者内存不足的原因,我不是很懂,并且仍然找不到解决办法。

2.再该目录的Temp文件夹里没有“MSBuild_*.failure.txt”文件。删除Temp文件夹的部分数据,重新生成,也未解决该问题。

2.选中项目,鼠标右键点击“清理”,或者重新生成解决方案,仍然解决不了问题。

3.关闭VS项目,并重新打开,再次编译,仍未解决。

4.重启计算机,再次编译,仍然报这个错。

问题已解决:
原因是最近在项目里新建了一个控件资源文件,由于该控件资源文件有误,我便删除了该文件,并且重新建立相同名称的控件资源文件,则就会报出以上的错误。

解决办法:把已经删除了的控件资源文件的名称复制粘贴(或者直接输入名称)到VS的搜索栏中选择搜索范围“整个解决方案”,进行查找到与新建过的文件相关的信息,在一条条信息中,选中跳转到另外文件记录下的新建过的文件名称之处,并删除之。再次编译程序,则成功通过。

 

自己给自己挖坑。。。

- 第二次在2020年2月19日又出现了同样的问题,原因是我把控件资源文件的位置修改到项目的另外文件夹里。坑,还要继续挖。

- 控件资源文件(通常指ResourceDictionary文件,其他文件类型目前还没有遇到相似的问题,不易定论)

我咋感觉 这次输入系统没反应呢?PS C:\Users\Administrator> function Get-CurlVersion { >> <# >> .SYNOPSIS >> 获取已安装curl的版本信息 >> >> .DESCRIPTION >> 返回curl的版本号、协议支持等详细信息 >> >> .EXAMPLE >> PS> Get-CurlVersion >> 7.88.1 >> #> >> [CmdletBinding()] >> param() >> >> try { >> if (-not $script:ModuleInitialized) { >> Initialize-Module | Out-Null >> } >> >> $curlExe = if ($script:CurlPath) { >> $exeName = if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" } >> Join-Path $script:CurlPath $exeName >> } else { >> throw "curl路径未配置" >> } >> >> if (-not (Test-Path $curlExe)) { >> throw "curl可执文件不存在: $curlExe" >> } >> >> # 执curl --version获取详细信息 >> $versionInfo = & $curlExe --version 2>&1 >> if ($LASTEXITCODE -ne 0) { >> throw "curl版本获取失败: $versionInfo" >> } >> >> # 解析版本号 >> $versionLine = $versionInfo | Select-Object -First 1 >> if ($versionLine -match 'curl\s+(\d+\.\d+\.\d+)') { >> $version = $matches[1] >> } else { >> $version = "未知版本" >> } >> >> return [PSCustomObject]@{ >> Version = $version >> FullInfo = $versionInfo -join "`n" >> Executable = $curlExe >> LastChecked = (Get-Date) >> } >> } catch { >> Write-Error "获取curl版本失败: $_" >> return $null >> } >> } >> PS C:\Users\Administrator> function Set-CurlPath { >> <# >> .SYNOPSIS >> 设置自定义curl路径 >> >> .DESCRIPTION >> 验证并设置新的curl安装路径 >> >> .EXAMPLE >> PS> Set-CurlPath -Path "C:\Program Files\curl\bin" >> #> >> [CmdletBinding()] >> param( >> [Parameter(Mandatory=$true)] >> [ValidateScript({ >> if (-not (Test-Path $_)) { >> throw "路径不存在: $_" >> } >> $exe = Join-Path $_ $(if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" }) >> if (-not (Test-Path $exe)) { >> throw "路径不包含curl可执文件: $exe" >> } >> $true >> })] >> [string]$Path >> ) >> >> try { >> if (-not $script:ModuleInitialized) { >> Initialize-Module | Out-Null >> } >> >> # 更新配置 >> $script:Config.CurlPath = $Path >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> >> # 重载路径 >> $script:CurlPath = $Path >> Write-Host "✅ curl路径更新为: $Path" -ForegroundColor Green >> >> # 验证新路径 >> $version = Get-CurlVersion >> if ($version) { >> Write-Host "当前curl版本: $($version.Version)" -ForegroundColor Cyan >> } >> >> return $true >> } catch { >> Write-Error "设置curl路径失败: $_" >> return $false >> } >> } >> PS C:\Users\Administrator> function Install-Curl { >> # ... 之前的安装代码 ... >> >> # 安装后添加版本验证 >> $exePath = Join-Path $installDir $(if ($platform -eq "Windows") { "curl.exe" } else { "curl" }) >> if (-not (Test-Path $exePath)) { >> throw "安装后curl可执文件不存在: $exePath" >> } >> >> # 验证版本 >> $versionInfo = & $exePath --version 2>&1 >> if ($LASTEXITCODE -ne 0) { >> throw "安装后curl验证失败: $versionInfo" >> } >> >> Write-Verbose "curl安装成功: $($versionInfo[0])" >> return $installDir >> } >> PS C:\Users\Administrator> # 模块主文件内容保持不变... >> >> # 初始化模块后添加版本检查 >> function Initialize-Module { >> try { >> # ... 之前的初始化代码 ... >> >> # 验证curl可执性 >> $exePath = Join-Path $script:CurlPath $(if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" }) >> if (-not (Test-Path $exePath)) { >> Write-Warning "配置的curl路径无效: $exePath" >> $script:Config.CurlPath = Find-CurlPath >> $script:CurlPath = $script:Config.CurlPath >> } >> >> # 测试curl基本功能 >> $null = Get-CurlVersion -ErrorAction Stop >> Write-Verbose "模块初始化完成, curl路径: $script:CurlPath" >> >> return $true >> } catch { >> Write-Warning "模块初始化失败: $_" >> return $false >> } >> } >> PS C:\Users\Administrator> # ... 之前的安装脚本 ... >> >> # ===== 保存所有公共函数 ===== >> # Get-CurlPath.ps1 (已存在) >> # Get-CurlVersion.ps1 >> $getCurlVersionContent = @' >> function Get-CurlVersion { >> # 上面的完整实现 >> } >> '@ >> Set-Content -Path "$publicDir\GetCurlVersion.ps1" -Value $getCurlVersionContent -Force >> >> # Set-CurlPath.ps1 >> $setCurlPathContent = @' >> function Set-CurlPath { >> # 上面的完整实现 >> } >> '@ >> Set-Content -Path "$publicDir\SetCurlPath.ps1" -Value $setCurlPathContent -Force >> >> # Invoke-SecureDownload.ps1 (已存在) >> >> # ===== 保存所有私有函数 ===== >> # InstallCurl.ps1 (已存在) >> # FindCurlPath.ps1 >> $findCurlPathContent = @' >> function Find-CurlPath { >> # 上面的完整实现 >> } >> '@ >> Set-Content -Path "$privateDir\FindCurlPath.ps1" -Value $findCurlPathContent -Force >> >> # GetPlatform.ps1 >> $getPlatformContent = @' >> function Get-Platform { >> # 从Initialize-Module移出的实现 >> } >> '@ >> Set-Content -Path "$privateDir\GetPlatform.ps1" -Value $getPlatformContent -Force >> >> # ... 其余安装脚本不变 ... >> PS C:\Users\Administrator> # 测试模块 >> if (Get-Module CurlTools) { >> Write-Host "✅ CurlTools 模块安装成功!" -ForegroundColor Green >> >> try { >> # 测试路径获取 >> $curlPath = Get-CurlPath >> Write-Host "Curl路径: $curlPath" >> >> # 测试版本获取 >> $version = Get-CurlVersion >> if ($version) { >> Write-Host "Curl版本: $($version.Version)" >> Write-Host "支持协议: $($version.FullInfo | Select-String 'Protocols:' | ForEach-Object { $_.ToString().Split(':')[1].Trim() })" >> } >> >> # 测试路径设置 >> $newPath = "C:\Program Files\Git\usr\bin" >> if (Test-Path $newPath) { >> Set-CurlPath -Path $newPath -Verbose >> } >> >> # 测试下载功能 >> $testUrl = "https://raw.githubusercontent.com/PowerShell/PowerShell/master/README.md" >> $outputPath = Join-Path $env:TEMP "PowerShell_README_$(Get-Date -Format 'yyyyMMddHHmmss').md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputPath >> Write-Host "✅ 测试下载成功: $outputPath" -ForegroundColor Green >> } >> catch { >> Write-Warning "⚠️ 测试失败: $_" >> } >> } >> PS C:\Users\Administrator>
最新发布
08-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值