dotnet / dotnet/msbuild

BuildSubmission.ExecuteAsync() returns null BuildResult.ProjectStateAfterBuild with exception MSB4188: Build was canceled.

Open
#3,388 0 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Steps to reproduce

When passing a RequestedProjectState with null ItemFilters to PendBuildRequest, BuildSubmission.ExecuteAsync() returns null BuildResult.ProjectStateAfterBuild with exception MSB4188: Build was canceled.

Below code snippet repro's the issue on 15.8; or ping me for the repro project

```c#
var requestedProjectState = new RequestedProjectState();

// property to return
requestedProjectState.PropertyFilters = new List() { "TargetPlatformIdentifier" };

// set ItemFilters as null will result in BuildResultCode.Failure with exception MSB4188: Build was canceled.
requestedProjectState.ItemFilters = null;

//requestedProjectState.ItemFilters = new Dictionary>();

BuildRequestData requestData =
new BuildRequestData(projectFile, props, null, targetsToBuild, null, BuildRequestDataFlags.ProvideSubsetOfStateAfterBuild, requestedProjectState);

BuildResult br = null;
var buildSubm = msbuildMgr.PendBuildRequest(requestData);

var tcs = new TaskCompletionSource();
try
{
buildSubm.ExecuteAsync(CompleteCallback, tcs);
br = await tcs.Task;
}
catch (Exception ex)
{
var exception = ex.ToString();
}

if (br.ProjectStateAfterBuild != null)
{
var property = br.ProjectStateAfterBuild.GetProperty("TargetPlatformIdentifier");
}
else
{
var res = br.OverallResult.ToString();
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.