Files using custom build rules are built even if excluded - by Avery Lee

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 456563 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 5/22/2009 8:49:10 PM
Access Restriction Public

Description

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.
Sign in to post a comment.
Posted by Microsoft on 11/4/2009 at 9:53 AM
Hi Phaeron,

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:

<Target
    Name="ComputeMASMOutput"
    Condition="'@(MASM)' != ''">
    <ItemGroup>
     <Link Include="@(MASM->Metadata('ObjectFileName')->Distinct()->ClearMetadata())" Condition="'%(MASM.ExcludedFromBuild)' != 'true'"/>
     <Lib Include="@(MASM->Metadata('ObjectFileName')->Distinct()->ClearMetadata())" Condition="'%(MASM.ExcludedFromBuild)' != 'true'"/>
    </ItemGroup>
</Target>

Thanks,
Marian Luparu
Visual C++ Project & Build
Posted by Avery Lee 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> Assembling...
1> main.cpp
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.


Posted by Microsoft on 10/28/2009 at 12:09 AM
Hi Phaeron,

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.

Thanks,
Marian Luparu
Visual C++ Project & Build
Posted by Avery Lee 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.
Posted by Microsoft on 6/2/2009 at 8:24 PM
Hi -

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.

Thanks,
-- Izzy

Izzy Gryko
Lead Software Design Engineer
Microsoft Visual Studio Platform Development
izzyg@microsoft.com
Posted by Microsoft 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.

Thank you,
Visual Studio Product Team