`MSBuildLocator.RegisterMSBuildPath()` not registering custom SDKs configured through `msbuild-sdks` in `globals.json`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- build-system
Research direction
Start with MSBuildLocator.RegisterMSBuildPath and the Microsoft.Build.Evaluation project-loading path, then compare how command-line MSBuild resolves the msbuild-sdks entries in global.json. Done means determining whether custom SDKs such as Microsoft.Build.NoTargets can be resolved in-process and documenting or reproducing the supported behavior.
Written by the indexing model from the issue text.
Description
I'm working in a code repository which configures several of the custom project SDK types provided by the MSBuildSdks repo, which are configured in the root global.json file of that repo:
{
"msbuild-sdks":
{
"Microsoft.Build.Traversal": "4.1.82",
"Microsoft.Build.NoTargets": "3.7.134"
}
}
In building a tool that uses the Microsoft.Build.Evaluation library to scan the projects in this repo, I am so far unable to get the in-process library to register these custom project types. When attempting to load a project that either uses one of these custom SDK types or which references another project via a <ProjectReference> which in turn uses one, it fails with an exception like the one below:
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.Build.NoTargets' specified could not be found. NoTargets.proj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1](IElementLocation elementLocation, String resourceName, T1 arg0)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ICollection`1 propertiesFromCommandLine, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, IDirectoryCacheFactory directoryCacheFactory, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext, IDirectoryCacheFactory directoryCacheFactory, Boolean interactive)
Building these projects that use the NoTargets SDK from the command line succeeds, so the command line MSBuild tool seems to be finding these custom project SDK types. And in other ways, the in-process Microsoft.Build.Evaluation library appears to be configured correctly as all other projects that don't reference these SDK types load just fine.
Is this a scenario that the MSBuildLocator supports? Is it possible to get the in-memory libraries to locate and use these custom SDKs when evaluating projects?
- Dominant language
- C#
- Stars
- 262
- Forks
- 91
- Avg merge
- 11d 22h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/MSBuildLocator
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
microsoft/MSBuildLocator#390 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 64/100
microsoft/MSBuildLocator#389 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
microsoft/MSBuildLocator#377 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/MSBuildLocator#371 · 1 comment ·
-
microsoft/MSBuildLocator#368 · 2 comments · 4 reactions · 1 assignee ·
All issues in microsoft/MSBuildLocator
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·