次の方法で共有


How to: Deploy the XML schema describing the serialization of your DSL?

The problem

If you build a DSL and deploy it on a different machine by double-clicking on a VSIX, everything should be fine, except that you will get warnings "Cannot find a schema..." each time you open an instance of your DSL. This is because the XML schema file generated by the DSL tools cannot be deployed with a VSIX yet

The 3 following cannot be deployed with a VSIX, in fact:

  • Provide an icon to identify our type of DSL file in Windows Explorer and Solution Explorer.
    (This is not the same as the VSIX icon, which appears in Extension Manager.)
  • Associate our type of DSL file with Visual Studio, so that users can double-click a file in Windows, and have the file open in Visual Studio.
  • Install an XSD so that the XML syntax of the DSL files is recognised by Visual Studio.

The solution

Since these cannot be achieved with a VSIX, you will need to create an MSI (setup file) that can do these things, and can have the VSIX embedded within it.

This is not too difficult to do, and is explained in details in the Chapter 5 of the DslToolsLab (https://code.msdn.microsoft.com/DSLToolsLab/Release/ProjectReleases.aspx?ReleaseId=4207) in the paragraph "Deploying the VSIX in an MSI"

Comments

  • Anonymous
    May 10, 2010
    Hi Jean-Marc, I saw your post hear on your blog after i posted my reply on the MSDN forum (http://social.msdn.microsoft.com/Forums/en-US/dslvsarchx/thread/c47f518e-8d42-4842-b807-22773478aa9f/#7396b6b0-8a33-4961-9351-fa7ad114f702) and decided to ask you a question on this post. I have an issue when i run my DSL project i dont see my Toolbox items for my DSL. Recheck that everything is configured correctly. Even tried to replicate in VS 2008 and it was working. Seems that this is only happening in VS 2010. Seen other blogs that they mention it was a bug in beta but i have the latest version downloaded from MSDN. Version 10.0.30319.1 RTMRel. Even tried clearing out my expHive's cache toolbox files. Tried reseting the exphive and the devenv. Even create a MSI for my DSL as described in the DslToolsLab and tried installing it on VM's with fresh installs of VS 2010...also not working. Could you maybe point me in a direction...

  • Anonymous
    July 29, 2010
    Hi, I got the following code that can do the job (copying the schema to Schemas directory), but I don't know where to add it to be executed each time the extension is loaded. Any idea ? [code] IVsExtensionManager extensionManager = this.GetService(typeof(SVsExtensionManager)) as IVsExtensionManager; XmlLanguageService xls = (XmlLanguageService)this.GetService(typeof(XmlLanguageService)); string schemasPath = xls.XmlPrefs.SchemaCacheLocation; IVsShell shell = this.GetService(typeof(SVsShell)) as IVsShell; object obj2; shell.GetProperty((int)__VSSPROPID2.VSSPROPID_InstallRootDir, out obj2); if (obj2 != null) {    string str = obj2.ToString();    if (str != null)    {        if (str.EndsWith(new string(Path.DirectorySeparatorChar, 1)))        {            str = str.Substring(0, str.Length - 1);        }        schemasPath = schemasPath.ToLowerInvariant().Replace("%vsinstalldir%", str);    } } IInstalledExtension extension = extensionManager.GetInstalledExtension(GuidList.guidPackagePkgString); File.Copy(    Path.Combine(extension.InstallPath, @"SchemasmySchema.xsd"),    Path.Combine(schemasPath, "mySchema.xsd")); [/code]

  • Anonymous
    August 19, 2012
    How do we do this in VS2012 since setup projects are no more?