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"
}
}
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)
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.jsonfile of that repo:In building a tool that uses the
Microsoft.Build.Evaluationlibrary 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:Building these projects that use the
NoTargetsSDK 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-processMicrosoft.Build.Evaluationlibrary 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
MSBuildLocatorsupports? Is it possible to get the in-memory libraries to locate and use these custom SDKs when evaluating projects?