dotnet / dotnet/msbuild

msbuild clean wrong files during compilation

Open
#11,364 5 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

### Issue Description

We have below structure in repository. When we are compiling individual folder solutions separately everything works correctly. We have also combined solution which contains all projects from all folders. If we will compile that solution everything works correctly. However, if we will compile combined solution first (compile correctly), and then we will compile just project2 (some code changes), msbuild will delete files which are part of the project1 from output directory even if project1 was not compiled at all. It seems that project2 FileListAbsolute.txt in obj compilation folder contain list of files from Project1 (probably generated when combined solution was compiled ?). As files which are not part of compiled solution are deleted from target location application will not start anymore. We have to go back and recompile Folder1 solution again. This is affecting productivity a lot and if people are not aware about this, they even spend lot of time investigating why those files are disappearing.

Please see attached binary log from compilation. Im not able to attach projects\solutions for reproducibility as those are protected IP.

![Image](https://github.com/user-attachments/assets/dc2a6782-b288-40d8-b753-397c480bf53f)

[msbuild.DeletingWrongFiles.zip](https://github.com/user-attachments/files/18622090/msbuild.DeletingWrongFiles.zip)

[MI.Biz.Plugin.Registration.csproj.FileListAbsolute.txt](https://github.com/user-attachments/files/18622099/MI.Biz.Plugin.Registration.csproj.FileListAbsolute.txt)

Folder1
- projects1
- xml files in output dir
- solution for Folder1

Folder2
- projects2
- dependency on project1
- solution for Folder2

CombinedSolution (Folder1\Folder2)

### Steps to Reproduce

Compile combined solution first. Compile individual projects afterwards.

### Expected Behavior

Files which are not related\owned by compiled project\solution should not be deleted from compilation output directory.

### Actual Behavior

Files which are not part of compiled project\solution are deleted from compilation output directory.

### Analysis

_No response_

### Versions & Configurations

MSBuild version 17.12.12+1cce77968 for .NET Framework
17.12.12.57101

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.