Script Class

MSBuild

Executes code contained within the task.


Namespace: MSBuild.Community.Tasks
Assembly: MSBuild.Community.Tasks (in MSBuild.Community.Tasks.dll)

Syntax

Visual Basic (Declaration)
Public Class Script
    Inherits Task
C#
public class Script : Task
C++
ref class Script : Task
J#
public class Script extends Task
JScript
public class Script extends Task

Example

Simple script that writes to the console

 Copy Code
<PropertyGroup>
    <HelloCode>
        <![CDATA[
        public static void ScriptMain() {
            Console.WriteLine("Hello MSBuild Community Scripting World.");
        }
        ]] >
    </HelloCode>
</PropertyGroup>
<Target Name="Hello">
    <Script Language="C#" Code="$(HelloCode)" Imports="System" />
</Target>

Script that returns a value.

 Copy Code
<PropertyGroup>
    <GetProgramFilesCode>
        <![CDATA[
        public static string ScriptMain() {
            return Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
        }
        ]] >
    </GetProgramFilesCode>
</PropertyGroup>
<Target Name="GetProgramFilesFolder">
    <Script Language="C#" Code="$(GetProgramFilesCode)">
        <Output TaskParameter="ReturnValue" PropertyName="ProgramFilesFolder" />
    </Script>
    <Message Text="Program files are in: $(ProgramFilesFolder)" />
</Target>

Inheritance Hierarchy

System.Object
   Microsoft.Build.Utilities.Task
      MSBuild.Community.Tasks.Script

Thread Safety

Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

See Also

Syntax based on .NET Framework version 2.0.
Documentation version 1.0.0.0.