Overcoming BimlScript Copy and Paste Issues in Visual Studio

gravatar

Paul S. Waters

When a new Biml file is added to Visual Studio, the editor assumes that all of the code being entered is XML. Since BimlScript is not XML, the editor does not know how to handle it. This will show you have to remedy this issue.

published 09.26.12

last updated 09.27.12


Share

Tags

  • Copy/Paste

When a new Biml file is added to Visual Studio, the editor assumes that all of the code being entered is XML. This is great if you are using just Biml with no BimlScript. Since BimlScript is not just XML, the editor does not know how to handle it. This is very apparent when BimlScript is pasted into the editor. To see what happens, copy the following code:

<Biml xmlns="http://schemas.varigence.com/biml.xsd">  
    <Packages>  
        <# for(int i = 1; i <= 5; i++) { #> 
        <Package Name="MyPackage<#=i#>" ConstraintMode="Linear">  
            <Tasks>  
                <Dataflow Name="My Dataflow">  
                </Dataflow>  
            </Tasks>  
        </Package>  
        <# } #> 
    </Packages>  
</Biml>

Now paste it into a newly created Biml file in Visual Studio. Most likely you will have the following in your editor:

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Packages>
        <# for(int i = 1; i <= 5; i++) { #>
        <Package Name="MyPackage"
            <#=i#>" ConstraintMode="Linear">
            <Tasks>
                <Dataflow Name="My Dataflow">
                </Dataflow>
            </Tasks>
        </Package>
        <# } #>
    </Packages>
</Biml>

Notice the difference between the Package Name attributes in the two code blocks. There are two ways to handle this. One requires changing default settings in Visual Studio and the other does not.

No Visual Studio setting changes required

After you paste your code into the Visual Studio editor, press ctrl-z. This will undo the changes Visual Studio makes in an attempt to convert your BimlScript to XML.

Change Visual Studio default settings

To stop Visual Studio from altering your BimlScript when you paste it into the editor, do the following:
1. Click Tools -> Options...
2. In the tree in the dialog that comes up, go to Text Editor -> XML -> Formatting
3. Uncheck "On Paste from clipboard"
4. Consider also unchecking "On completion of end tag"

You are not authorized to comment. A verification email has been sent to your email address. Please verify your account.

Comments

There are no comments yet.