dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.22k stars 1.35k forks source link

Imported projitems with Content always fails dependency check #2496

Open jccaulfield opened 7 years ago

jccaulfield commented 7 years ago

If you Import a shared project (projitems) which contains Content (set to PreserveNewest in this case) then msbuild always thinks the content files are missing in the output folder, even when they are present.

It seems that the dependency check thinks the content output should be in the wrong location. The actual Copy task does the right thing (i.e., copies the shared project content to the output folder of the project with the dependency).

I have verified this behaviour on a minimal C# UWP app created with Visual Studio 2017. See attached project - every time you hit "run" it will build. If you remove the csproj's dependency on the shared project, then successive runs will skip the build step.

SharedContentTest.zip

asterius1 commented 7 years ago

Have very similar issue: Using netcore2.0.

<ItemGroup>
  <Content Include="..\extra_files\*.txt">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

using config above in my .csproj makes it rebuild every time. Using Visual Studio options: Projects and Solutions -> .Net Core -> Logging Level: Verbose. Build logs say Output file 'bin\Debug\netcoreapp2.0\myfile.txt' does not exist. (BugPreserveNewest) and therefore it decides its not up to date and rebuilds every time. But this exact file does exist (after running first build)!

Included isolated reproduction. BugPreserveNewest.zip