Losing format & intellisense when using C# code in BIML Script

Jun 21, 2013 at 8:07 PM
Edited Jun 21, 2013 at 10:05 PM

When I use .net code in my BIML script the xml obviously gets corrupt, because the brackets are not opening and closing one after the other:
<ExecutePackage  Name="EPT - <#=row["name"]#>">
And when I reopen the script in visual studio the format is all gone and the intellisense isn't working any more. Any suggestions on how to solve this?

Version info:

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.0.30319 SP1Rel

Installed Version: IDE Standard

Microsoft Visual Basic 2010 01011-532-2002361-70238
Microsoft Visual Basic 2010

Microsoft Visual C# 2010 01011-532-2002361-70238
Microsoft Visual C# 2010

Microsoft Visual Studio Tools for Applications 3.0 01011-532-2002361-70238
Microsoft Visual Studio Tools for Applications 3.0

Microsoft Visual Web Developer 2010 01011-532-2002361-70238
Microsoft Visual Web Developer 2010

SQL Server Analysis Services
Microsoft SQL Server Analysis Services Designer
Version 11.0.3000.0

SQL Server Integration Services
Microsoft SQL Server Integration Services Designer
Version 11.0.2100.60

SQL Server Reporting Services
Microsoft SQL Server Reporting Services Designers
Version 11.0.3000.0

Visual Studio 2010 Shell (Integrated) - ENU Service Pack 1 (KB983509) KB983509
This service pack is for Visual Studio 2010 Shell (Integrated) - ENU.
If you later install a more recent service pack, this service pack will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/983509.

BIDS Helper 2012 - An add-in to extend SQL Server Data Tools - Business Intelligence (SSDTBI formerly BI Development Studio)
(c) 2013 Version

Need something like the online BIML editor:
Jun 21, 2013 at 9:18 PM
This is the built-in Visual Studio XML editor being too aggressive. You essentially have 3 options:
  1. Improve the Visual Studio experience. The Visual Studio XML editor chooses it's editor type based on examining the beginning of the file. When you first add Biml tags, it has already chosen the type as XML,and does not change it. When you reopen the file, it sees the tags and defaults to text. There are some tricks to work around this:
    • Change XML editor settings to keep it from autoformatting. Here is an article that goes into a bit more detail. There is also a setting for disabling autoformat on open: http://bimlscript.com/Walkthrough/Details/45
    • You can also force the editor to use XML settings by right-clicking the biml file, selecting open with, and selecting XML editor. I don't know of a way to turn off Visual Studio's file inspection in the double-click case.
    • You can also work around this by putting your directive tags (the ones with <#@ ... #> format) at the bottom of the file. When VS inspects the file, it will see an XML tag at the beginning and be satisfied.
  2. Instead use the free browser-based editor on BimlScript.com. http://www.bimlscript.com/Develop. This adds a bit of friction as you need to copy/paste to build your code, but you may prefer this, depending on how much code you need to look at.
  3. The Mist editor has full code coloring, formatting, and intellisense (both for tags and code blocks). That costs money, and it also has many other neat features.
Marked as answer by furmangg on 3/17/2015 at 6:16 PM
Jun 21, 2013 at 10:02 PM
Edited Jun 21, 2013 at 10:05 PM
Thanks will check that!
Jun 21, 2013 at 10:11 PM
Thanks for including the picture of the online Biml editor in your edit. I'll point out a couple of neat features.

The zoom slider in the bottom left is great if you're doing a code review on a projector or presenting a local SQL Saturday (http://www.sqlsaturday.com/ - free weekend training events).

Export HTML provides a ready-made html snippet that you can add to your blog or other forum with syntax highlighting, etc.

Something that's already happening, and we'd like to see more of, is publication of BimlScript snippets to solve lots of common problems. That way, people can google a problem/task, e.g. "BimlScript twitter", and find a snippet on the first page of results that gets them 80%+ of the way to integrating Twitter data into their BI solution. If there are other features we could add to the online editor to facilitate that, please let us know!
Jun 22, 2013 at 7:48 AM
Found a workaround. Right click the biml script and then choose Open With... and then select the XML (Tekst) Editor. Setting it as default didn't work.
Marked as answer by furmangg on 3/17/2015 at 6:15 PM