Home Dashboard Directory Help
Search

Unexpected exception when setting CommandLine property of VCCustomBuildTool by fnqbruce


Status: 

Closed
 as Won't Fix Help for as Won't Fix


1
0
Sign in
to vote
Type: Bug
ID: 776854
Opened: 1/17/2013 5:57:26 PM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

In a custom VC++ project wizard, immediately after setting a file's ItemType to 'CustomBuild', any attempt to set any of the properties of the CustomBuildTool will result in an exception: "Mismatched PageRule with the wrong ItemType."

For example, in the code below, the last line will usually cause the exception:

        var config = proj.Object.Configurations('Debug');
        var file = proj.Object.Files('Sample.txt');
        var projectTool = config.Tools('VCCustomBuildTool');
        file.ItemType = 'CustomBuild';
        var fileConfig = file.FileConfigurations('Debug');
        var tool = fileConfig.Tool;
        tool.CommandLine = 'ECHO Custom build...';

A variety of techniques may prevent the exception, including:

- Using the debugger
- Adding a sleep between setting file.ItemType and setting the CommandLine property
- Creating a log file using FileSystemObject and writing to it before setting the CommandLine property

However, only using the debugger reliably prevents the exception.

Please note that this problem does not occur in Visual Studio 2010.
Details
Sign in to post a comment.
Posted by Microsoft on 7/9/2013 at 11:38 AM
Hi,

Thank you for taking the time to provide your feedback. After reviewing your reported issue, in the context of all the issues reported to us, we have decided not to take any action on this feedback at this time.

If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance.
For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.

Thanks,
Bogdan Mihalcea
VC++ Team
Posted by Microsoft on 1/18/2013 at 2:35 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 1/17/2013 at 6:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by fnqbruce on 1/19/2013 at 11:48 PM
// A work-around is available as follows.


function CustomFileSettings(proj) {
    try
    {
        var config = proj.Object.Configurations('Debug');
        var file = proj.Object.Files('Sample.txt');
        var projectTool = config.Tools('VCCustomBuildTool');
        file.ItemType = 'CustomBuild';
        
        // Save, close and reopen the project
        proj.Save();
        var prjPath = proj.FullName;
        dte.Solution.Remove(proj);
        proj = dte.Solution.AddFromFile(prjPath, false);
        
        // Reinitialize all object model handles, since they are no longer valid
        file = proj.Object.Files('Sample.txt');
        var fileConfig = file.FileConfigurations('Debug');
        var tool = fileConfig.Tool;
        tool.CommandLine = 'ECHO Custom build...';
    }
    catch(e)
    {
        throw e;
    }

    // Return the new project reference, for use by the calling function
    return proj;
}
File Name Submitted By Submitted On File Size  
default_js.zip 1/17/2013 1 KB