Visual Studio and .NET Framework Home
Files using custom build rules are built even if excluded
5/22/2009 8:49:10 PM
User(s) can reproduce this bug
If a file in a C++ project uses a custom build rule from a rule file, it is built by the project system even if the Excluded From Build property is set to Yes and it shows the excluded icon in the Solution Explorer.
The Excluded From Project property does appear to work for C++ files and files using custom build rules declared directly in the file properties.
Visual Studio 2010 Beta 1
Windows 7 RC
Operating System Language
Steps to Reproduce
1) Create a C++ console application project.
2) Enable the MASM custom build rule on the project.
3) Add a new .asm file. It should show Masm Macro Assembler as the build tool in the file properties.
4) Set the Excluded From Build property on the .asm file to Yes.
5) Build Solution.
The .asm file is built.
The .asm file should be skipped.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 11/4/2009 at 9:53 AM
Thank you for investigating this. You are correct, there was another missing piece that was only fixed after Beta 2 was released. As a workaround, can you make the following changes in the <Program Files>\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\masm.targets:
Condition="'@(MASM)' != ''">
<Link Include="@(MASM->Metadata('ObjectFileName')->Distinct()->ClearMetadata())" Condition="'%(MASM.ExcludedFromBuild)' != 'true'"/>
<Lib Include="@(MASM->Metadata('ObjectFileName')->Distinct()->ClearMetadata())" Condition="'%(MASM.ExcludedFromBuild)' != 'true'"/>
Visual C++ Project & Build
on 10/29/2009 at 12:27 AM
Sorry, I was a bit sloppy in reopening this bug. I originally used the default MASM rule in the repro case for expediency, and although the issue still exists, the repro and behavior has changed slightly. A new repro is attached (vs2010-customnobuild.zip); this was made by making a VS2005 project with a clone of the VS2005 masm.rules file and then converting the project to VS2010b2.
In beta 2, the behavior is slightly different in that while the "Assembling..." banner is printed, the main2.asm file isn't actually assembled. If it were, MASM would report an error. However, the project is still busted because while the file isn't assembled, the main2.obj file it would produce is still passed to LINK and that breaks the build:
1>------ Build started: Project: vs2005-customnobuild, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'Debug\main2.obj'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The expected behavior is that Excluded From Build prevents the file from participating in either the build or the link step.
Currently, as a workaround I have to manually change custom built files to use Does Not Participate In Build as the build mode after conversion takes place. Unfortunately, this isn't viable since it can't be set on a per-platform or per-configuration basis, so I can only have either x86 or x64 buildable at a time.
on 10/28/2009 at 12:09 AM
I noticed that the project you attached is using MASM custom rule from $(VCInstallDir)VCProjectDefaults rather than $(VCTargetsPath)BuildCustomization. The VCProjectDefaults path may contain a stale version of the converted masm.rules (converted in Beta 1) that may not contain the logic around ExcludedFromBuild.
Can you check that this is the case? If yes, you might have $(VCInstallDir)VCProjectDefaults on the Build Customizations Search Path. You can remove the path in Tools > Options > VC++ Project Settings > Build Customizations Search Path.
In Beta 2, conversion should also detect that your project has a reference to the $(VCInstallDir)VCProjectDefaults .rules file and replace that with $(VCTargetsPath)BuildCustomization\<rulename>.targets, without performing a conversion of the .rules file. If this is different than what you are seeing, please let us know.
Visual C++ Project & Build
on 10/24/2009 at 1:04 AM
I have reopened this bug because I am still seeing it on beta 2 with the same repro and observed behavior. I created new project and solution files under beta 2 and excluded.asm still builds even though its Excluded From Build property is set to Yes and the stop sign is displayed on the file's icon in the Solution Explorer.
I uninstalled beta 1 completely before installing beta 2, but if there is a known problem where special steps need to be taken to clean old beta 1 components that could cause this problem, let me know so I can retry with a proper install.
on 6/2/2009 at 8:24 PM
Thanks for the bug report. This is an issue that we already know about from internal testing; however, we found it too late to fix for Beta 1. We should have it fixed for Beta 2.
Lead Software Design Engineer
Microsoft Visual Studio Platform Development
on 5/25/2009 at 9:20 PM
Thanks for your feedback.
We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
© 2013 Microsoft