Publish WebApplication Using NAnt

Is it possible to publish (as in Visual Studio publishing in a Web Application project) by a solution using NAnt? I just can't find a solution.

+4
source share
4 answers

They should use the built-in target "_CopyWebApplication".

That's what I'm doing

<target name="compile" description="Compiles the project."> <exec basedir="." program="${DotNetPath}msbuild.exe" commandline=" src/MyProject.Web/MyProject.Web.csproj /nologo /t:Rebuild /t:ResolveReferences;_CopyWebApplication /p:OutDir=../../output/build/bin/ /p:WebProjectOutputDir=../../output/build/ /p:Debug=${debug} /p:Configuration=${configuration} /v:m" workingdir="." failonerror="true" /> </target> 

with structural structure:

 /project.build /src/myprojct.sln /src/myporject.web/myproject.web.csproj /output 

Edit: I also use this to use YUI compression to compress my css and js

 <target name="compress-js"> <foreach item="File" property="filename"> <in> <items basedir="output/build/assets/javascript/"> <include name="/**/*.js" /> <exclude name="/**/*.min.js" /> <exclude name="/**/*.pack.js" /> </items> </in> <do> <exec basedir="." program="${JavaPath}java" commandline=" -jar S:\yuicompressor-2.4.1\build\yuicompressor-2.4.1.jar --type js --charset utf-8 -o &quot;${filename}&quot; &quot;${filename}&quot;" failonerror="true" /> </do> </foreach> </target> <target name="compress-css" depends="combine-css"> <foreach item="File" property="filename"> <in> <items basedir="output/build/assets/css/"> <include name="/**/*.css" /> <exclude name="/**/*.min.css" /> <exclude name="/**/*.pack.css" /> </items> </in> <do> <exec basedir="." program="S:\Java\jdk1.6.0_11\bin\java" commandline=" -jar S:\yuicompressor-2.4.1\build\yuicompressor-2.4.1.jar --type css --charset utf-8 -o &quot;${filename}&quot; &quot;${filename}&quot;" failonerror="true" /> </do> </foreach> </target> 
+7
source

Using MSBuild aims to use NAnt, NAnt is what replaces MSbuild, use below to make a clean compilation of NAnt projects, as in VS 2003/2005/2008.

It works for me!

 <?xml version="1.0"?> <project name="MyTest" default="run"> <property name="basename" value="MyTest1x"/> <property name="debug" value="false"/> <property name="copytarget" value="c:\temp"/> <target name="clean"> <delete> <fileset basedir="${copytarget}"> <include name="bin/${basename}.dll"/> <include name="**/*.???x"/> <include name="Web.config"/> </fileset> </delete> </target> <target name="build"> <mkdir dir="${copytarget}/bin" /> <csc target="library" output="${copytarget}/bin/${basename}.dll" > <sources> <include name="*.cs"/> </sources> </csc> </target> <target name="run" depends="clean,build"> <copy todir="${copytarget}" overwrite="true"> <fileset basedir="."> <include name="**/*.???x" /> <include name="Web.config" /> </fileset> </copy> </target> </project> 
+5
source

I know this is an old question, but I just learned something, so I decided that I would share it: although it is 100% true that the target "_CopyWebApplication" exists and works, with .NET 4.0 it was replaced using the " _WPPCopyWebApplication "in Microsoft.Web.Publishing.targets, which supports new features such as web.config conversion syntax, etc.

(repetition of all equally worded questions, so don't vote for it :))

+3
source

Here's how you can do this using the MSBUILD task for nant:

 <property name="debug" value="AutomatedDebug" /> <property name="configuration" value="Debug;TargetFrameworkVersion=v3.5" /> <msbuild project="src\WebApplication1\WebApplication1.csproj" failonerror="true"> <arg value="/nologo" /> <arg value="/t:Rebuild" /> <arg value="/t:ResolveReferences;_CopyWebApplication" /> <arg value="/p:OutDir=../../build/Debug/WebApplication/" /> <arg value="/p:WebProjectOutputDir=../../build/Debug/WebApplication-Deploy/" /> <arg value="/p:Debug=${debug}" /> <arg value="/p:Configuration=${configuration}" /> <arg value="/v:m" /> </msbuild> 

This compiles WebApplication to the deployment folder, just like using the Publish function in Visual Studio.

+2
source

Source: https://habr.com/ru/post/886440/


All Articles