'MSBuild Fails On C# WPF Application Project

I have been stumped for about 3 days now trying to solve a MSBuild problem I have been having. In my solution I have 10 projects. 9 Projects are C# Class projects and 1 project which is the main EXE is a C# WPF Application project.

I created a gated MSBuild that gets triggered on a check in into the TFS server. Up to now only the 9 C# Class Projects have been included in the MSBuild because the C# WPF Application project was still being built. The C# WPF Application project is now done and fully working (run time and compile time) on multiple computers without issue.

I changed the build to include the new C# WPF Application project so that it could be checked in. The problem is with this C# WPF Application project now included, MSBuild fails with the following two errors:

 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.WinFX.targets (269): File 'Properties\DesignTimeResources.xaml' cannot be found.
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.WinFX.targets (269): The project file contains a property value that is not valid.

Considering the entire solution builds and works on multiple computers it seems strange that the MSBuild is failing because of that. If I remove the C# WPF Application project from the MSBuild, everything is fine again so there is something weird with the C# WPF Application project that causes the MSBuild to fail.

I am getting desperate here, so any help is greatly appreciated. Thank you in advance for any help or insight you can give!



Solution 1:[1]

MS Expression Blend likes to add the Properties\DesignTimeResources.xaml file into your project so that it knows where to find common resources like your global styles.xaml file.

If you open a project in Expression Blend, it will add this file to the project but it may not add the file to source code control. The fix back in Visual Studio is to go the solution explorer, navigate to Properties then right click DesignTimeResources.xaml. If you won't use Blend again then just delete the file, otherwise add it to source code control.

Solution 2:[2]

I was having a similar error (BG1002: File not found) with a VS2017 WPF project which won't built because a certain icon file was missing despite the fact that I was no longer using that icon. I resolved this by manually editing the csproj file to rename the reference in notepad.

Solution 3:[3]

I run into this in a VS2017 WPF project with newest git 2.36. A collegues commit (other branch) a new file in a commit which I never checked out and somehow was just the project file changed to this commit I never used. Also git didn't noticed the change in first place in project file (I believe).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RichardU
Solution 2 kmxr
Solution 3 Trivalik