How to automate repetitive tasks after assembly?

I am running an ASP.NET website solution with several other projects. I knew that MSBuild projects are capable of this, but is this the best way? Are they easy to create? Is nAnt, CruiseControl.NET or any other solution better?

When I create a site (using Web Deployment Projects ), can I automate part of the assembly so that it does not copy specific folders from the project to the Release folder? For example, I have folders with local search indexes, images, and another part of the contents of the folder, but I never need or load them when I deploy the project.

I also look at this type of solution to automatically increase build and version numbers.

+4
source share
7 answers

Here is an example web deployment project that scripts this task in a .wdproj file:

<Target Name="AfterBuild"> <!-- ============================ Script Compression============================ --> <MakeDir Directories="$(OutputPath)\compressed" /> <Exec Command="java -jar c:\yuicompressor-2.2.5\build\yuicompressor-2.2.5.jar --charset UTF-8 styles.css -o compressed/styles.css" WorkingDirectory="$(OutputPath)" /> <Exec Command="move /Y .\compressed\* .\" WorkingDirectory="$(OutputPath)" /> <RemoveDir Directories="$(OutputPath)\sql" /> <Exec Command="c:\7zip-4.4.2\7za.exe a $(ZipName).zip $(OutputPath)\*" /> </Target> 

This will allow you to delete the folder.

(I suspect that if you do not want to copy the folder at all, the solution file will be the place to indicate this, although I should not have used this.)

+8
source

MaseBase, you can use Web Deployment Projects to create and package websites. We do this all the time for projects with the web application aspect. After you have assigned WDP to the website, you can open the .wdproj file as an XML text file. At the end, you see the MSBuild task section, which represents the sequence of events that fire during the build process.

 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.WebDeployment.targets. <Target Name="BeforeBuild"> </Target> <Target Name="BeforeMerge"> </Target> <Target Name="AfterMerge"> </Target> <Target Name="AfterBuild"> </Target> --> 

You can uncomment your desired goals (for example, "AfterBuild") and insert the necessary tasks there to perform repetitive actions after assembly.

+4
source

You can set the Build Action / Copy to Output Directory property to individual files (select a file and press F4 to open the properties window) to control what happens to them during build, but not for folders. This can probably be automated with the (pre) build task if you don't want to do it manually.

Alternatively, you can exclude these folders from the project (right-click and “exclude from project”); they will still be present ("show all files" in the solution explorer), but they will not be included when creating the project.

+2
source

CruiseControl.NET solves another problem (continuous integration) ... however, I have had great success with NAnt specifically for what you ask. There is a learning curve there, but as soon as you get comfortable, you will be amazed how you ever interacted with it.

+1
source

In addition to @Fredrik’s hint about setting project elements to “Copy to output directory”, you can also specify the post-build action in the project properties on the “Assembly” tab and enable CMD commands such as copy.exe and move.exe.

+1
source

We use FinalBuilder to automate many post-build / pre-build tasks. There is also a web interface so that you can run assemblies (or click websites) by logging into the website and clicking a button.

http://www.finalbuilder.com/

+1
source

Can you edit the MSBuild file for your web deployment project so that it does what you need?

+1
source

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


All Articles