dotnet / dotnet/msbuild

MSBuild uses wrong order when Cleaning, causing unregistration of COM components to fail.

Open
#1,230 9 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

When having the "Register for COM interop" checked in C# projects, where there are multiple projects that may have dependencies on each other, the order in which the projects are cleaned when running MSBuild on the solution is incorrect.

Attached is a simple solution containing three projects, ComRegTest, ComRegTest2, and ComRegTest3.
The ComRegTest2 project references both of the others. When building the projects the build order is correct:
1. ComRegTest
2. ComRegTest3
3. ComRegTest2

But when running `msbuild ComRegTest.sln /t:Clean /m:1` the order in which the projects are cleaned are:
1. ComRegTest3
2. ComRegTest2
3. ComRegTest1

This causes an error to occur when cleaning ComRegTest2, saying:

```
error MSB3395: Cannot unregister asse mbly "D:\Projects\ComRegTest\bin\ComRegTest2.dll". Could not load file or assembly 'ComRegTest3, Version=1.0.0.0, Culture=neut ral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
```

This problem does not occur when cleaning from within Visual Studio 2015.

[ComRegTest.zip](https://github.com/Microsoft/msbuild/files/544987/ComRegTest.zip)

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.