2

I'm attempting to create a VSIX package to deploy for some common application layouts that I use, however when I create the Project Template then put the template files in my VSIX package and build it, I get a lot of Unexpected character '$' messages in some of my C# classes on the namespace. According to the documentation, this should be the proper format.

This is one of the classes throwing the error

using System.Web.Optimization;

namespace $safeprojectname$ {
    public class BundleConfig {
        public static void Register(BundleCollection bundles) {
            bundles.Add(new StyleBundle("~/styles/site")
                .IncludeDirectory("~/assets/styles", "*.css"));

            bundles.Add(new ScriptBundle("~/scripts/libs")
                .IncludeDirectory("~/assets/libs/jquery", "*.js")
                .IncludeDirectory("~/assets/libs/bootstrap", "*.js")
                .Include("~/assets/libs/angular/angular.js")
                .Include("~/assets/libs/angular/angular-sanitize.js")
                .Include("~/assets/libs/angular/angular-animate.js")
                .IncludeDirectory("~/assets/libs/angular-ui", "*.js")
                .IncludeDirectory("~/assets/scripts", "*.js"));

            bundles.Add(new ScriptBundle("~/scripts/app")
                //.IncludeDirectory("~/common/directives", "*.js")
                //.IncludeDirectory("~/common/filters", "*.js")
                //.IncludeDirectory("~/common/services", "*.js")
                .Include("~/app/home/app.home.js")
                .IncludeDirectory("~/app/home/controllers", "*.js")
                .Include("~/app/app.js"));
        }
    }
}

I checked my vstemplate file and this is what it has for that file/folder

<Folder Name="startup" TargetFolderName="startup">
    <ProjectItem ReplaceParameters="true" TargetFileName="BundleConfig.cs">BundleConfig.cs</ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="WebApiConfig.cs">WebApiConfig.cs</ProjectItem>
</Folder>
Ben Black
  • 3,751
  • 2
  • 25
  • 43

1 Answers1

6

The class that gives you an error, is a template content. The idea of template content is to be a simple "txt" file, which will be later processed by vsix infrastructure to replace all the parameters, such as $safeprojectname$.

What you're doing right now, is that you're trying to compile your class, but you should not do it. Click on that file, "Build Action -> None".

enter image description here

Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78
  • 1
    I am still getting same error with global.asax file and controllers. – Pankaj Sharma Apr 24 '15 at 07:32
  • Setting build action to None does unfortunately not help in VS 2017 (15.9.1). It build everything correctly and the extension works, but the error are shown which is quite confusing – Creepin Nov 16 '18 at 20:18