$safeprojectname$ throwing errors in VSIX Package

1.5k Views Asked by At

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>
1

There are 1 best solutions below

2
On BEST ANSWER

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