Skip to content

Run the task analyzer in every Tasks build - #15223

Draft
AR-May wants to merge 3 commits into
dotnet:mainfrom
AR-May:ar-may-analyzer-coverage-check
Draft

AR-May wants to merge 3 commits into
dotnet:mainfrom
AR-May:ar-may-analyzer-coverage-check

Conversation

@AR-May

@AR-May AR-May commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Partially fixes #15208

Summary

Run the task analyzer in all Microsoft.Build.Tasks builds instead of only when BuildAnalyzer=true.
Existing findings are suppressed at the individual call site with either:

Testing

.\build.cmd -v quiet -msbuildEngine dotnet — passed with 0 warnings and 0 errors.

Copilot AI and others added 3 commits October 7, 2026 10:54
Reference the in-repository analyzer unconditionally, keep all-task migration
mode explicitly false, and remove warning demotion. Update CI and documentation
without modifying the analyzer implementation or its tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use narrow pragmas for verified safe exclusions in RAR, file, URL, launcher, manifest, archive, XML, and redist paths. Explain the fully-qualified-path, absolute-path, temporary-file ownership, or unreachable-branch invariant at each call site without changing runtime behavior. Include bare AbsolutePath.Value uses not yet recognized by the unchanged analyzer.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Suppress the nine remaining sites individually. Document the remaining path-resolution and shared-logging risks without changing runtime behavior or claiming that the suppressions establish safety.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
global_level = 100

msbuild_task_analyzer.run_mt_analyzers_on_all_tasks = true
msbuild_task_analyzer.run_mt_analyzers_on_all_tasks = false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a bug to turn this on?

Comment thread src/Tasks/TarDirectory.cs
Comment on lines +139 to +144
#pragma warning disable MSBuildTask0003 // TaskEnvironment supplies a fully qualified source directory.
_sourceDirectory = new DirectoryInfo(TaskEnvironment.GetAbsolutePath(SourceDirectory.ItemSpec).Value);
#pragma warning restore MSBuildTask0003
#pragma warning disable MSBuildTask0003 // TaskEnvironment supplies a fully qualified destination path.
_destinationFile = new FileInfo(TaskEnvironment.GetAbsolutePath(DestinationFile.ItemSpec).Value);
#pragma warning restore MSBuildTask0003

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused by these -- they're using GetAbsolutePath. Is that not enough?

Comment thread src/Tasks/PiaReference.cs
}
else
{
#pragma warning disable MSBuildTask0005 // ResolveComReference loads PIAs in its per-invocation AppDomain, isolated from other tasks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are CWD and thus relative paths AppDomain isolated?

Comment thread src/Tasks/Untar.cs
{
#pragma warning disable MSBuildTask0003 // destinationFolderPath is fully qualified by TaskEnvironment.
destinationDirectory = Directory.CreateDirectory(destinationFolderPath);
#pragma warning restore MSBuildTask0003

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one could just be fixed?

Suggested change
#pragma warning restore MSBuildTask0003
AbsolutePath destinationFolderPath = TaskEnvironment.GetAbsolutePath(DestinationFolder.ItemSpec);
try
{
destinationDirectory = Directory.CreateDirectory(destinationFolderPath);

Comment thread src/Tasks/Untar.cs
Comment on lines +134 to +136
#pragma warning disable MSBuildTask0003 // TaskEnvironment supplies a fully qualified archive path.
FileInfo sourceFile = new FileInfo(TaskEnvironment.GetAbsolutePath(sourceItem.ItemSpec).Value);
#pragma warning restore MSBuildTask0003

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#pragma warning disable MSBuildTask0003 // TaskEnvironment supplies a fully qualified archive path.
FileInfo sourceFile = new FileInfo(TaskEnvironment.GetAbsolutePath(sourceItem.ItemSpec).Value);
#pragma warning restore MSBuildTask0003
FileInfo sourceFile = new FileInfo(TaskEnvironment.GetAbsolutePath(sourceItem.ItemSpec));

Comment thread src/Tasks/RedistList.cs
if (FileSystems.Default.DirectoryExists(redistDirectory))
{
// RAR supplies resolved framework directories under Wave18_13; other callers use framework installation paths.
#pragma warning disable MSBuildTask0005

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this firing here instead of on the DirectoryExists call above?

Comment thread src/Tasks/RedistList.cs
try
{
var readerSettings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, CloseInput = true };
#pragma warning disable MSBuildTask0005 // AssemblyTableInfo validates that Path is fully qualified.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- string path = assemblyTableInfo.Path.Value;
+ AbsolutePath path = assemblyTableInfo.Path;

then?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable the task-authoring analyzer in the VMR

3 participants