dotnet / dotnet/msbuild

CopyToOutputDirectory from referenced Web project is not copied when the referencing project is not up-to-date, but the referenced project is

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

Description

Repro: [CopyFromRefProj.zip](https://github.com/Microsoft/msbuild/files/2946683/CopyFromRefProj.zip)

The *ConsoleApp* project is a .NET Core 2.1 console EXE that contains a file, *content.xt*, which is copied to the output directory. The *ReferencesConsoleApp* project references *ConsoleApp*. When I build *ReferencesConsoleApp* the *content.txt* file from *ConsoleApp* gets copied to the output directory of *ReferencesConsoleApp*, as expected.

However, in the same setup with a web project - *ReferencesWebApp* references *WebApp*, which contains *content.txt* - the file is only copied to the output directory if *WebApp* is not up-to-date. If a file in *ReferencesWebApp* is modified and the project is built, but *WebApp* is up-to-date then *content.txt* is not copied to the output directory of *ReferencesWebApp* and is deleted from there if it already exists.

I've only been able to reproduce this when building in VS 2017 (15.9.7), not with msbuild directly nor with `dotnet build`.

### Steps to reproduce

1. Build the solution in VS 2017.
2. Observe that ReferencesWebApp\bin\Debug\netcoreapp2.1\content.txt exists.
3. Modify ReferencesWebApp\Program.cs.
4. Build (not rebuild) the solution again.
5. Observe that ReferencesWebApp\bin\Debug\netcoreapp2.1\content.txt has been deleted.

### Expected behavior

ReferencesWebApp\bin\Debug\netcoreapp2.1\content.txt exists

### Actual behavior

ReferencesWebApp\bin\Debug\netcoreapp2.1\content.txt is deleted

### Environment data
`msbuild /version` output:
```
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

15.9.21.664
```

OS info: Windows 7 SP1 x64

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc): VS 2017 v15.9.7.

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.