简体   繁体   中英

Try to Automate the Build Process for C# Solution through user click

I tried to establish a process through a click button where I can do following activities.

Objective

  1. Download the latest code from SVN.
  2. Build 2 set of Codes to create dlls and exe- (a)Web application in Release mode (b)Standalone application in debug mode
  3. Then Replace some values of keys inside config files.
  4. Then Place them to particular location.

Steps followed so far

Created demo.bat file which will build exe and dlls for Standalone as shown below


REM * ============================Starting Setup for Standalone======================================
SET Folder= C:\Automating\Application\Source\StandaloneApp\

cd %Folder%App1
msbuild /property:Configuration=Debug App1.csproj /t:clean /t:build

cd %Folder%App2
msbuild /property:Configuration=Debug App2.csproj /t:clean /t:build

del /F /S /Q /A %Folder%Setup\*.*

XCOPY %Folder%App1\bin\Debug\*.* %Folder%Setup\*.* /S /Y /F /Q
XCOPY %Folder%App2\bin\Debug\*.* %Folder%Setup\*.* /S /Y /F /Q

Created Another bat file demo1.bat to change command prompt to VS2010 cmd prompt


%comspec% /k ""c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
%comspec% /k ""C:\Automating\BuildAuto\BuildAutomation\demo.bat""

Created one more cmd files to download from svn


TortoiseProc.exe /command:export /URL:[URL path] /Path:"C:/Automating/Demo"

Finally A web application where from user can click button to download as per svnExport.bat and build the downloaded code as per demo1.bat .


protected void Button2_Click(object sender, EventArgs e) {
 ProcessStartInfo psi = new ProcessStartInfo(@"C:\AutomatingPOC\BuildAuto\BuildAutomation\demo1.bat");
            psi.UseShellExecute = false;
            psi.RedirectStandardOutput = false;
            psi.CreateNoWindow = false;
            Process.Start(psi);
}

Downloading event is working correctly, but build is not working. I need help on how can I build the code

Why reinventing the wheel? Use available tools, such as TeamCity and msbuild (there are plenty other alternatives as well). I found Eugene made a really nice introduction here .

People spent man-years developing and polishing build automation tools. If I were you, I would stop right there and had a look around.

if you set psi.UserShellExecute to false, then you will need to specify that the command to execute is actually "cmd.exe" and that the batch file is an argument. You'll also have to manages the delay between the time that the request is made and the time the build is actually completed.

automating a task like this can be done easily with Auto Hot Key. also to automatically download you can use the start command and the type of browser of your choice IE Firefox iexplore chrome ~ then you can automate the download. but do note that with some websites page number may change IE.This address has a specified page code:

Try to Automate the Build Process for C# Solution through user click

so instead of putting the regular address in the batch or what ever you chose to use you can put in

https://stackoverflow.com/questions/ ********

allowing it to find the information

or you can use a mouse/key-board recorder to automate the task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM