<regasm assembly="myAssembly.dll" />
NAnt.Core.Task
(from the NAnt.Core.dll
library). To write your own task, open Visual Studio, create a new Class Library
project, add a link to NAnt.Core.dll
and create something like this: [TaskName("my-task")] public class MyTask : NAnt.Core.Task { protected override void ExecuteTask() { // TODO: System.IO.File.WriteAllText("file.txt", "Hello, world!"); } }
NAnt.Core.Task
is an abstract class, all the descendants of which must contain their own implementation of the abstract method void ExecuteTask()
- it is in it that the actions are performed for which the task is intended. In order to set the name of the XML tag, which will then be used in build scripts, you need to mark the created class with the attribute TaskName
.TaskAttribute
attribute. At run time, these properties will contain the values specified in the task parameters in the build script.System.IO.FileInfo
, rather than string
, to pass in the file path parameters. [TaskAttribute("path", Required = true)] public string Path { get; set; }
Log
method from the base class. Log(Level.Warning, " ");
loadtasks
, and then call the necessary task using the name specified in the TaskName
attribute. <loadtasks assembly="MyLibrary.dll" /> <my-task path="D:\temp" />
System.Diagnostics.Debugger.Launch()
and build the library in Debug mode. When you run the task via NAnt in the specified location, the script execution will stop and you will be asked to start Visual Studio for debugging. <createDatabase database="dbname" instance="." integratedSecurity="true" />
<!-- integrated security --> <backupDatabase database="dbname" instance="." integratedSecurity="true" backupFileName="d:\test.bak" /> <!-- user & password --> <backupDatabase database="dbname" instance="." user="sa" password="123" backupFileName="d:\test.bak" />
<addDatabaseUsers database="dbname" instance="." integratedSecurity="true"> <user login="IIS APPPOOL\test" isWindowsUser="true" /> <user login="test1" password="123" /> <user login="test2" password="qwert" /> </addDatabaseUsers>
<minify-js obfuscate-js="true" with-line-breaks="true" disable-optimizations="true"> <files> <include name="test2.js" /> <include name="test.js" /> </files> </minify-js> <minify-css compression-type="hybrid" with-line-breaks="true"> <files> <include name="*.css" /> </files> </minify-css>
<compile-less file="D:\projects\ecm7milk\milk.less" result="D:\milk.min.css" />
<createIISWebSite websiteName="xxx3.ru" fileSystemPath="d:\xxx3.ru" appPool="xxx3.ru"> <bindings> <add host="localhost" port="4898" protocol="http" /> <add host="xxx3.ru" /> </bindings> </createIISWebSite>
<createIISApplication websiteName="xxx3.ru" virtualPath="/admin" fileSystemPath="d:/admin" /> <createIISDirectory websiteName="xxx3.ru" applicationVirtualPath="/admin" virtualPath="/images" fileSystemPath="d:/images" />
<xdt target="test.xml"> <transformation> <moo1 xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <moo2 xdt:Transform="Insert">123</moo2> <rewrite xdt:Transform="Insert"> <a1>456!</a1> </rewrite> </moo1> </transformation> </xdt>
<!-- - --> <xdt target="test.xml"> <transformation refid="mimimi" /> </xdt> ... <raw-xml id="mimimi"> <moo1 xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <moo2 xdt:Transform="Insert">123!</moo2> <rewrite xdt:Transform="Insert" xxx2="${test.property}" aaa="bbbb"> <a1 xxx1="${test.property}">456!</a1> </rewrite> </moo1> </raw-xml> <!-- --> <xdt target="test.xml"> <transformation file="transform.xml" /> </xdt>
Note that inside the files with the transformation description you can use NAnt expressions.Source: https://habr.com/ru/post/189190/
All Articles