Skip to content

WPF Application Always Rebuilds In Visual Studio #4228

@aolszowka

Description

@aolszowka

Background

In attempting to reproduce the issue for #4217 I attempted to create a fresh WPF Project to see if I could reproduce it; in doing this I encountered a similar (but I do not believe identical) issue wherein the MainWindow.g.cs was always regenerated.

Steps to reproduce

Please find an attached zip file that contains the project that demonstrates this behavior: WpfAppAlwaysRebuilds.zip

This project was created by:

  1. Creating a new WPF Application within Visual Studio
  2. Modifying the CSPROJ To contain the work around for GenerateCompiledExpressionsTempFile does not clean up the files it creates #1648 as follows
  <Target Name="GenerateCompiledExpressionsTempFile">
    <!--This is a no-op to overwrite the existing target that ships with MSBuild. When we upgrade to Visual Studio 2019 (MSBuild 16.0) we can remove this. See https://github.com/Microsoft/msbuild/issues/1648-->
  </Target>

To reproduce the issue on the command line build the project

msbuild WpfAppAlwaysRebuilds.sln /t:Build

Then launch the Solution in Visual Studio and build you will see this in diganostic verbosity:

Project 'WpfAppAlwaysRebuilds' is not up to date. Input file 's:\temp\markupbug\wpfappalwaysrebuilds\wpfappalwaysrebuilds\obj\debug\mainwindow.g.cs' is modified after output file ''.
------ Build started: Project: WpfAppAlwaysRebuilds, Configuration: Debug Any CPU ------

Note that in order to repeat it a second time you MUST delete the contents of the /obj/ folder to start "clean" again. Once it has built in Visual Studio once MSBuild will happily report that it is up to date.

Expected behavior

The expected behavior is that this project will report as "up-to-date"

Actual behavior

The project rebuilds because it determines that it is not "up-to-date"

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 Server 2012 R2

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
Visual Studio 15.9.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions