0

I'm trying to code something in an install.ps1 post-install script for a Nuget package that depends on the project type. If it's a web project type, I want to do something different after install. So I'm looking at the $project.Kind to determine this. The problem is that when I test with a WebApi project, this always returns the wrong project kind. If you look in a newly created C# WebApi project, it has two project types listed in the element (one for Web Application and one for general C#). The $project.Kind property is returning the C# identifier...I need to see if it's a web application, so I need the first one as well. I can't find the proper call to get the list of all project types from $project:

param($installPath, $toolsPath, $package, $project)

if($project.Kind -eq {guid goes here}){do my custom thing here...}

I've looked through the available accessors on the EnvDte Project object and can't find anything that looks promising.

https://msdn.microsoft.com/en-us/library/envdte.project.aspx

Any ideas?

4
  • 1
    Only thing I can see that may be unique are the <Import>s. Web projects appear to include Microsoft.WebApplication.targets. Could also look for web.config. Commented Jan 29, 2015 at 2:43
  • 1
    Might be some useful information you can use here: mztools.com/articles/2007/mz2007014.aspx Commented Jan 29, 2015 at 7:09
  • Thanks guys, these are both good ideas...will try them out. Commented Jan 29, 2015 at 15:25
  • @BradChristie if you want to put this as an answer...glad to give you the credit. Commented Jan 30, 2015 at 5:05

1 Answer 1

1

The solution I used was as Brad suggested...just took the low road and looked for a web config like such:

$webItem = $null;

try{
    $webItem = $project.ProjectItems.Item("Web.config")
}
catch
{
}

if($webItem -eq $null)
{
  --processing for non-web project.
}

Not very elegant, but it appears to work for my simple cases.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.