Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Trying to load a project with Sdk.WindowDesktop fails.

Aperta
#120 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp
Ambito
build-system

Direzione di ricerca

Inizia con Microsoft.Build.Evaluation.Project e Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults(), confrontando il MSBuildPath selezionato in Net472 e NetCoreApp31. Riproduci l'errore MSB4236 con Microsoft.NET.Sdk.WindowsDesktop e determina cosa consente all'host NetCoreApp di caricare correttamente il progetto SDK.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I've been trying to load a csproj using new Microsoft.Build.Evaluation.Project("project.csproj", null, null"); and it throws this exception:

The specified SDK "Microsoft.NET.Sdk.WindowsDesktop" could not be found.
Source: Microsoft.Build
Error: MSB4236
MSBuild.CouldNotResolveSdk

The loaded csproj looks like this:

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

  <PropertyGroup>
    <TargetFramework>net471</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

And the host application registers the MSBuild location with:

Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults();

I've noticed different behavior depending on whether the host application is compiled against Net472 or against NetCoreApp31:

On Net472

  • The Microsoft.NET.Sdk.WindowsDesktop projects succeeds to load.
  • MSBuildPath of Locator Instance points to: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"

On NetCoreApp3.1

  • The Microsoft.NET.Sdk.WindowsDesktop projects throw an exception on load.
  • MSBuildPath of Locator instance points to: "C:\Program Files\dotnet\sdk\2.2.300"
    On Net4xx:

So I believe this is the reason because it works on Net4 and not on NetCore.

Is there a way to solve this issue and make the "Microsoft.NET.Sdk.WindowsDesktop" projects to load while the host app is NetCoreApp?

Lingua principale
C#
Stelle
262
Fork
91
Merge medio
11g 22h
PR unite (30g)
3

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/MSBuildLocator

Tutte le issue di microsoft/MSBuildLocator

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.