Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Access ISharePointProjectService from T4 Text Template

$
0
0

I have a Visual Studio 2013 SharePoint solution/project in which I set the "Site URL" to which I want to deploy the project (standard functionality). I would like to consume the project's "Site URL" property in a T4 Text Template.  However, it appears that this may not be possible because T4 is (apparently) not running as a Visual Studio add-in.  (Seehttp://msdn.microsoft.com/en-us/library/ee471432.aspx.)

In other words, I want to do something like this in a T4 (.tt) file (rookie code):

<# IServiceProvider serviceProvider = (IServiceProvider)this.Host;
   EnvDTE.DTE dte = (EnvDTE.DTE) serviceProvider.GetService(typeof(EnvDTE.DTE));
   EnvDTE80.DTE2 dte2 = (DTE2)dte;
   ServiceProvider serviceProvider2 = new Microsoft.VisualStudio.Shell.ServiceProvider(dte2 as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
   Microsoft.VisualStudio.SharePoint.ISharePointProjectService projectService = serviceProvider2.GetService(typeof(Microsoft.VisualStudio.SharePoint.ISharePointProjectService)) as Microsoft.VisualStudio.SharePoint.ISharePointProjectService;

When I run this example, the projectService comes back as null.  (The other code returns valid objects.)

Does anyone know if this is possible and, if so, how to do it?

Thanks!  John


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>