Web.AppPool.Exists and Web.WebSite.Exists output parameters not set

May 9, 2008 at 8:15 PM
Hello,

I'm trying to use the tasks Web.AppPool.Exists and Web.WebSite.Exists, but it seems like the output parameters are not getting set correctly. Below are snippets from the target.

<Web.AppPool.Exists AppPoolName="MyAppPool">
<Output TaskParameter="DoesExist" PropertyName="AppPoolExists" />
</Web.AppPool.Exists>
<Message Text="$('AppPoolExists')" />
<Web.WebSite.Exists Description="MyWebSite">
<Output TaskParameter="DoesExist" PropertyName="WebSiteExists" />
</Web.WebSite.Exists>
<Message Text="$('WebSiteExists')" />

When the target is run, the Web.AppPool.Exists does not output anything suggesting that it even ran nor does the message task output anything. Web.WebSite.Exists on the other hand outputs "Checking for Existance website 'MyWebSite' on: localhost". But then the message task outputs nothing. Has anyone else successfully run these tasks?

Any help would be appreciated.
Developer
May 10, 2008 at 9:04 AM
CodePlex was updated last night and along with a few nice features, the ability to create a workitem from a discussion appears to have gone. Not nice... back to your problem:

If you just run your sample with normal diagnostics, the output is pretty basic:

Target Default:
Checking for Existance website 'MyWebSite' on: localhost

Behind the covers, a lot has actually happened, and this is where upping the diagnostics helps. Simply add /v:diag to your command line call:

...
Target "Default" in file "C:\a\Copy of SDCAppPool.proj":

 

  Using "Web.AppPool.Exists" task from assembly "C:\a\Microsoft.Sdc.Tasks.dll".

  Task "Web.AppPool.Exists"

  Done executing task "Web.AppPool.Exists".

  Using "Message" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Cu

lture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

  Task "Message"

  Done executing task "Message".

  Using "Web.WebSite.Exists" task from assembly "C:\a\Microsoft.Sdc.Tasks.dll".

  Task "Web.WebSite.Exists"

    Checking for Existance website 'MyWebSite' on: localhost

  Done executing task "Web.WebSite.Exists".

  Task "Message"

  Done executing task "Message".

Done building target "Default" in project "Copy of SDCAppPool.proj".

...

So as you can see, all the expected tasks are executing. There are two problems in this case.

 

  1. The first 'problem' is that the SDC task for checking the AppPool existence is not emitting any basic messages (I'll fix this in the next release).
  2. The second problem is in your code. You appear to have some apostrophes in your property names, simply remove those and you will get the boolean results out.

i.e.

<Message Text="$('AppPoolExists')" />
<Message Text="$('WebSiteExists')" />

should read

<Message Text="$(AppPoolExists)" />
<Message Text="$(WebSiteExists)" />


Running the corrected code on an updated build, I get:

Target Default:

    Checking whether AppPool: MyAppPool exists on: localhost

    True

    Checking for Existence website 'MyWebSite' on: localhost

    False

Hope that helps.





 

Developer
May 10, 2008 at 9:10 AM
Workitem: http://www.codeplex.com/sdctasks/WorkItem/View.aspx?WorkItemId=10162

Code: http://www.codeplex.com/sdctasks/SourceControl/DownloadSourceCode.aspx?changeSetId=18173
May 12, 2008 at 1:39 PM
I had been staring at this task for so long, I overlooked the apostrophes.  Thanks for your help.
Dec 24, 2008 at 4:15 PM
The property value is not available for access outside the target where it is set. For e.g.,

<

Target Name="CheckAppServerPoolExists">

 

<!--

Condition="$(AppServerPoolExists) == False"-->

 

 

<

Web.AppPool.Exists

 

 

AppPoolName="AppPool_1"

 

 

MachineName="SomeServer">

 

<

Output TaskParameter="DoesExist" PropertyName="AppServerPoolExists"/>

 

</

Web.AppPool.Exists>

 

<

Message Text="Exists: $(AppServerPoolExists)"/> <!--I'm getting the right value here which is false in my case-->

 

<

CallTarget Targets="CreateAppServerAppPool"/>

 

</

Target>

 

<

Target Name="CreateAppServerAppPool">

 

 

    <Message Text="Inside: $(AppServerPoolExists)"/> <!--I'm not getting the value of the property AppServerPoolExists here which is set in the target shown above..It is always empty here..Is this a scope issue?-->

 

</

Target>

Any help is appreciated!!!