Microsoft KB Archive/326946

From BetaArchive Wiki

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 "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.

STATUS

Microsoft 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 INFORMATION

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

  1. Create a new Visual C++ Win32 Project.
  2. In the project directory, use Windows Explorer to create a new folder named Res.
  3. In the res folder, use a text editor such as Notepad to create a second resource file named Test.rc.
  4. 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.

  5. 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.
  6. 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"
                        
  7. Build the solution.
  8. 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:

  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:

#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

  1. Create a new Visual C++ ATL project named IDLTest and accept all project defaults.
  2. In the new IDLTest project, use the ATL Simple Object template to add a new class.
  3. Name the new class MyClass.
  4. 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).
  5. To add a new .idl file, follow these steps:
    1. On the Add New Item menu, click Project, and then select the Midl File (.idl) template.
    2. In the Name box, type Test.
    3. 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.
  6. 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");
    };
                        
  7. Build the solution.
  8. 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:

  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.

Custom Resource with External File set to False

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