When I run msxsl.exe on my DBML file, it introduces carriage returns that mess up the final SQLMetal.exe step

167 Views Asked by At

I just upgraded from VS 2015 to VS 2019 (and Windows 7 to Windows 10). My project is using SQLMetal.exe and msxsl.exe in a batch file to create and modify the DBML in three steps:

  1. Generate the DataModel.dbml file with SQLMetal.exe.
  2. Add database transforms with msxsl.exe.
  3. Generate the DataModel.cs file with SQLMetal.exe.

When I ran this in the new environment, it gave me a strange error:

DataModel.dbml(0) : Error: DBML1112: Element 'Column" must be empty, but contains a node of type Whitespace named ''.

After much trial and error, I realized that the msxls.exe (that I just downloaded) adds carriage returns before the closing column and association tags in the DBML file. This seems to be what is causing the error on the final SQLMetal.exe step.

<Column Name="SortOrder" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false">
</Column>

I can actually open the DataModel.dbml file after step 2 and replace all on "\r\n < /Column>" to "< /Column>" and "\r\n< /Assocation>" to "< /Association>", and then Step 3 seems to work. Obviously, I don't want to have to do this every time, though.

So, what do I need to do to run msxsl.exe and not have it add the carriage returns before the closing Column and Association tags?

The msxls command is as follows:

"C:\VSBuild\msxsl.exe" "%~dp0DataModel.dbml" "%~dp0ModifyDbml.xslt" -o "%~dp0DataModel.dbml"

Does the version of msxsl matter?

0

There are 0 best solutions below