Microsoft KB Archive/326946

= Issues that cause a solution to rebuild although dependencies are unchanged =

Article ID: 326946

Article Last Modified on 11/21/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * 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 &quot;up-to-date&quot; 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.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section. This bug was corrected in Microsoft Visual Studio .NET 2003.



Resource 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:
 * 1) include &quot;resource.h&quot;

NOTE: Make sure to include a carriage return after the #include line, otherwise or you receive a resource compiler error &quot;RC1004:unexpected end of file found&quot; 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: </li> Build the solution.</li> Build the solution a second time.
 * 1) include &quot;resource.h&quot;
 * 2) include &quot;res\test.rc&quot;

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.</li></ol>

Workaround
To work around this problem, add the IDE path macro to the appropriate property, as follows:
 * 1) In the Solution Explorer window, right-click the project, and then click Properties.
 * 2) In the left pane, click Resources, and then click General.
 * 3) 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:
 * 1) include &quot;..\resource.h&quot;

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
<ol> Create a new Visual C++ ATL project named IDLTest and accept all project defaults.</li> In the new IDLTest project, use the ATL Simple Object template to add a new class.</li> Name the new class MyClass.</li> 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).</li> To add a new .idl file, follow these steps: <ol style="list-style-type: lower-alpha;"> On the Add New Item menu, click Project, and then select the Midl File (.idl) template.</li> In the Name box, type Test .</li> 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.</li></ol> </li>  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 &quot;_IDLTest.idl&quot;; [   uuid(9131019F-FECA-4141-88AC-55FD1DD42527) ] library test {   importlib(&quot;stdole2.tlb&quot;); };                   </li> Build the solution.</li> 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.</li></ol>

Workaround
To work around this problem, add the IDE path macro to the appropriate property, as follows:
 * 1) In the Solution Explorer window, right-click the project, and then click Properties.
 * 2) In the left pane, click MIDL, and then click General.
 * 3) 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.

Steps to Reproduce the Behavior

 * 1) Create a new C++ Win32 application.
 * 2) Open the .rc file of the new project in Resource Editor.
 * 3) On the Project menu, click Add Resource, and then click Custom.
 * 4) Name the new resource item AVI.
 * 5) Expand the new AVI node in the Resource View window.
 * 6) Select the new AVI resource item, and in the Properties window, set the External File property to False.
 * 7) Type some binary data for the new resource item: 01 02 03 04 67.
 * 8) Build the solution.
 * 9) 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.

Additional query words: rebuild

Keywords: kbbug kbdevstudio kbvs2002sp1sweep KB326946

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.