Issues that cause a solution to rebuild although dependencies are unchanged (326946)
The information in this article applies to:
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
This article was previously published under Q326946 SYMPTOMS When you build a solution in Visual C++ .NET, if none of
the project dependencies have changed since the previous build, the Visual C++
.NET environment displays the message "up-to-date" in the output window without
compiling any of the project source files.
This article discusses
three issues that can cause projects to build every time, although no
dependencies have changed. STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
This bug was corrected in Microsoft Visual Studio .NET 2003.
MORE INFORMATIONResource File Dependencies Are Not Updated In the dependency scan of a resource file, the current directory
is set to the directory that contains the resource file. Every time you build
your solution, the Resource Compiler compiles the resource file if the
following conditions are true:
- A secondary resource file is included in the main resource
file.
- The secondary resource file is in a different directory
than the main project is in.
- The secondary resource file includes header files that are
not in the same directory as the secondary resource file.
Steps to Reproduce the Behavior- Create a new Visual C++ Win32 Project.
- In the project directory, use Windows Explorer to create a
new folder named Res.
- In the res folder, use a text editor such as Notepad to create a second
resource file named Test.rc.
- In Res\Test.rc, include the project Resource.h file by
using the #includes statement as follows:
#include "resource.h"
NOTE: Make sure to include a carriage return after the #include line, otherwise or you receive a resource compiler error
"RC1004:unexpected end of file found" when you build the main .rc
file. - Open the main project resource (.rc) file in a text editor
such as Notepad.
For example, in Visual C++ .NET, on the View menu, click Open With, and then select Notepad. - Immediately below the #include statement for the Resource.h file, add an #include statement for the resource file that you just created:
#include "resource.h"
#include "res\test.rc"
- Build the solution.
- Build the solution a second time.
In the output
window, messages from the Resource Compiler and the Linker appear, which
indicate that both tools ran, although no dependencies have changed since the
previous build.
Workaround To work around this problem, add the IDE path macro to the
appropriate property, as follows:
- In the Solution Explorer window, right-click the project,
and then click Properties.
- In the left pane, click Resources, and then click General.
- In the right pane, in the Additional Include Directories box, type $(ProjectDir), and then click OK.
This causes the dependency checker to scan the main
project directory (where resource.h resides) when it checks
dependencies.
Alternatively, in the Test.rc file, change the #include statement to directly reference the Resource.h file in the lower
directory as follows:
#include "..\resource.h"
IDL File Dependencies Are Not Updated Similar to the issue where resource file dependencies are not
updated, this issue occurs with interface definition language (IDL) files
instead of with resource files. If all of the following conditions
exist, the IDL file always rebuilds even if no dependencies have changed:
- An IDL file is present in your project.
- The IDL file is not in the main directory of your project.
- The IDL file imports the main project IDL file.
Steps to Reproduce the Behavior- Create a new Visual C++ ATL project named IDLTest and
accept all project defaults.
- In the new IDLTest project, use the ATL Simple Object template to add a new class.
- Name the new class MyClass.
- Build the project to generate the IDL (.idl) file.
The .idl file is given the project name with a prepended underscore
(for example, _IDLTest.idl). - To add a new .idl file, follow these steps:
- On the Add New Item menu, click Project, and then select the Midl File (.idl) template.
- In the Name box, type Test.
- In the Location box, append IDL to the path string so that the new .idl file is created in a new
sub-directory named IDL.
- In the new .idl file, append the following import statement and simple IDL code. The import statement imports the .idl file that was created in the main
project folder:
import "_IDLTest.idl";
[
uuid(9131019F-FECA-4141-88AC-55FD1DD42527)
]
library test
{
importlib("stdole2.tlb");
};
- Build the solution.
- Build the solution a second time.
Messages from
the MIDL Compiler appear in the output window. These messages indicate that the
tool ran, although no dependencies have changed since the previous
build.
Workaround To work around this problem, add the IDE path macro to the
appropriate property, as follows:
- In the Solution Explorer window, right-click the project,
and then click Properties.
- In the left pane, click MIDL, and then click General.
- In the right pane, in the Additional Include Directories box, type $(ProjectDir).
This
causes the dependency checker to scan the main project directory (where
_IDLTest.idl resides) when it checks dependencies.
Alternatively, you can hard code the path to the main project
.idl file in the import statement in Test.idl. However, the import statement
does not support relative paths, therefore, this solution will fail if you move
the project to a different directory. Custom Resource with External File set to FalseSteps to Reproduce the Behavior- Create a new C++ Win32 application.
- Open the .rc file of the new project in Resource Editor.
- On the Project menu, click Add Resource, and then click Custom.
- Name the new resource item AVI.
- Expand the new AVI node in the Resource View window.
- Select the new AVI resource item, and in the Properties
window, set the External File property to False.
- Type some binary data for the new resource item:
01 02 03 04 67.
- Build the solution.
- Build the solution a second time.
Messages from
the Resource Compiler and the Linker appear in the output window. These
messages indicate that both tools ran, although no dependencies have changed
since the previous build.
The Resource compiler and the Linker run during the second
build although no dependencies have been changed. Workaround To work around this problem, reset the External File property for the custom resource to True.
Modification Type: | Minor | Last Reviewed: | 11/21/2005 |
---|
Keywords: | kbvs2002sp1sweep kbbug kbDevStudio KB326946 |
---|
|