dotnet / dotnet/msbuild

Custom Build Tool always rebuilds when Additional Dependency is in AppData/Local

Open
#12,681 3 comments 0 reactions 1 assignee Assigned to @SimaTian View on GitHub
needs-investigation
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

When running MsBuild from the command-line, a Custom Build Tool which depends on a file in the user's `AppData\Local` directory is always re-run, even if no dependencies have changed.

### Steps to Reproduce

A solution to reproduce the issue is attached: [reproduce.zip](https://github.com/user-attachments/files/23002573/reproduce.zip)
It defines a static C++ library which contains two files with a Custom Build Tool. One depends on a file in local appdata, one depends on a file above this; they are otherwise identical.
1. Before building the solution, run the `init.bat` provided. Alternatively, manually create two files named `rebuild-repro.txt`, one in your `%LOCALAPPDATA%` directory and one in the directory directly above it (i.e. `C:\Users\username\AppData`).
2. Build the solution using MsBuild command line: `msbuild Solution1.sln -t:Build -p:Configuration=Debug`
* Both custom build tools build, and this is expected
3. Build the solution again using the exact same command line
* The custom build tool which depends on the file in `AppData/Local` is run again, even though none of its inputs changed. This is **not** expected.
Note that builds run from Visual Studio using "Build Solution" do not demonstrate this behaviour; only MsBuil builds from command-line do.

### Expected Behavior

In a `Build` action, Custom Build Tool only runs if its output does not exist or if its dependencies have changed.

### Actual Behavior

In a `Build` action, a Custom Build Tool which depends on a file in `AppData/Local` always runs, even if its output exists and its inputs haven't changed since last build. This only happens when running MsBuild from the command line, not when building from Visual Studio.

### Analysis

_No response_

### Versions & Configurations

MSBuild version 17.13.19+0d9f5a35a for .NET Framework
17.13.19.12613

Windows 11

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.