Jenkins - Change destination of built project - c#

I have a C# web application that I have developed using Visual Studio 2010 and commit changes to a VisualSVN repository using the AnkhSVN plugin for Visual Studio.
I have created a Jenkins project that checks the repository every five minutes for new commits and then builds the web application, using the MSBuild plugin, if it sees a change.
This is working fine, however it is building the application to C:\Program Files (x86)\Jenkins\workspace\[Jenkins Project Name]\[Web Application Name] and I would like it to build to D:\Web\[Web Application Name] as this is the directory my IIS site is pointing at. (Both locations are on the same server)
Is there a setting in the Jenkins project where I can change this or do I have to add a build step that copies to a different location using a batch command or something similar?
Many thanks in advance.

You can specify a custom workspace for the Jenkins job to run in.
In your jenkins job look for a button on the right hand side that is labeled Advanced. On Jenkins 2.46.1 it is at the bottom of the General section just before the SCM section of the build job. Click on it and a new set of options will appear, one of them will be Use custom workspace. Check the box and put in the path to the folder you want to use. You should ensure the Jenkins user has permissions on this folder or bad things might happen.
Note that this will perform the entire build in this folder, so anything else that is also in the workspace folder for that build job will be in the new location.
If you want just the output files without all the source and other stuff you will indeed have to add another build step (batch is one option) to copy the relevant files from your build jobs workspace (which can be accessed in batch using the WORKSPACE variable jenkins defines for the job) to the desired destination folder.

Related

Deploy SQL scripts stored in a folder along with click once installer

I am working on a windows forms application in which I am using few SQL scripts and executing them in my server using the C# application. Everything is working fine. I am able to run the scripts in my application which in turn creates tables in the database specified.
However my issue is I want to ship these SQL scripts located in that folder along the clickonce installer while deploying. The installer does not include the SQL files while installing.
Below is my code.
lstInfo.Items.Add(Resources.domaintable_initialization);
var file = new FileInfo(Path.GetFullPath(Application.StartupPath + "/scripts/createtbl_script.sql"));
SScriptFile = file.OpenText().ReadToEnd();
SUpdateDBname = SScriptFile.Replace("db_project", database);
var sUpdateServer = new Server(new ServerConnection(sqlConnection));
sUpdateServer.ConnectionContext.ExecuteNonQuery(SUpdateDBname);
sqlConnection.Close();
lstInfo.Items.Add(Resources.domaintable_success);
I have added the scripts folder inside debug -> bin directory. However when I publish the package i am not able to call the scripts located in that path as that folder inside bin is not getting published and I am getting the error that the path is not valid and scripts not getting called once installed using the clickonce package.
Can anyone help me on how to achieve this? I want a path to which I will be able to add the SQL scripts and able to have the same scripts added to my deployment package once published.
You need to include these files in the visual studio project. Just right click on the project and add an already existing element.
Select your scripts and add them to the project.
After that right click on the script files an click on properties. Now you will see a property build or something like that. There you can use the dropbox and select 'Content'.
Below that you will find another dropbox which should read something like "Dont't copy". Set the value of that dropbox to "Always copy".
That should do the trick.

How do I use Jenkins s3 publish plugin to the same location for every build?

I am using Jenkins to build my application, which I then need to publish to s3. One of the outputs is an installation exe file that I then provide as a link to users of the application. Because of this I need this installer file to always be in the same place, for every build. However, no matter how I set up my S3 Publishing post-build step the the artifacts are uploaded to a separate folder for every build, like so
Is there a way for me to set up the publish to the root of the directory/bucket every time, overwriting the old file if neccesary? This would eliminate the jobs/TestTrayApp/{buildnumber} directories. This is my s3 publish post-build step setup:
I'm not sure I fully understand what exactly what you want, but based on what I could gather up,you have an .exe file which needs to be in a particular location before publishing to s3 ?
Why not add a another post build action before your actual post build(publishing to s3) copy .exe to the destination location and then initiate publish build.
wont that be easier :)
You simply need another build step that copies the published .exe artifact to the permanent location for users to download.
I think you are confusing "publishing an app to your production environment" and publishing build artifacts. I believe the intent of this Jenkins S3 publish plugin is not to be used for your final release production version but as a build step to archive build artifacts, archive might have the same meaning as publishing in this context regarding your build artifacts. See this article for why I am thinking the Jenkins S3 publish plugin is not meant to be used to actually publish the final release version of your application.
Use a Jenkins Pipeline or add another build step to your Freestyle to copy the exe from S3 build artifact archive to your final permanent storage container for users to download from your website/app.
Unselect both Manage artifacts and Flatten directories checkboxes. And as per the Source give the directory name followed by a / which contains your executable. For example:
This way your latest executable will always be placed in bucket/blahblahblah/executable/executable.exe location no matter how many times your job runs.

Link resource file to multiple projects

I have two projects A|B. A is a creator and B is a consumer of what A creates. Each project needs to use a global.txt file which has configurations. Each project has its own solution in TFS. Is there a way to link global.txt from a location in TFS into each project so that if someone edits the global.txt, then rebuilds project A it will contain the updated file without having to update it manually
When you configure the source repositories in the build definitions separately for two solutions, you could both include the global.txt file mapping.
At the beginning of the build process, the agent downloads files from your remote repository(on TFS) into a local sources directory(build agent).
Then set a CI trigger , the builds will run whenever some changes made to global.txt and checked in.

TFS update a project

I am a software developer working on a webshop. We are using nopCommerce 3.30 with custom plugins. The whole project is checked in on a TFS server. (Visual studio 2013, Team Foundation server 2012)
The problem is the following:
nopCommerce 3.40 was released, we downloaded the ZIP with the source code, but i am not sure how do i compare the diferences and check-in the new version. I can't just replace all files because i need to compare the folder structure / delete the files and folders that are not in 3.40 version.
Is there any compare function between 2 projects on either the client or server side ?
If you're using local workspaces, you can just delete all the code in your workspace, then copy the new code into the same workspace folder. Then examine the pending changes window. TFS will automatically detect all add/deletes/edits (you may have to promote some of the changes from the Excluded Changes section of the Pending Changes window).
extract the files to a local folder, you can then use the compare tool.
Map one side to the source location of the original package, map the other side to your local directory. this will show you differences in the folder structure, file names etc. you can repeat / drill down to do the same at the file level

how to deploy my application?

I want to deploy my application. i followed this step but i can't get the .exe file. steps:
Step I:
Create one Windows based application in VS.Net using any of the Languages i.e. C# or VB.Net.
Step II:
After your program is running and you are ready for the setup. To add setup to your existing application go to Go to File > Add Project > New Project.
After your program is running and you are ready for the setup. To add setup to your existing application go to Go to File > Add Project > New Project.
The window appears like below and you select the Project as Setup Project and give a Name and its Location.
Step III:
After creating setup project right click on project and than select view, it will show different possible operations, which you can perform with this setup project.
The options available are
File System
Registry
File Types
User interfaces
Custom Actions
Launch conditions
Step IV:
Click on File system, it is used to create file system on the target machine. Through this you can specify what details you want to provide at the target machine.
Step V:
Now in the new window, its time to add the files & folder’s used by the application.
First we add the Project Output file. Click on Project Output and a new popup appears. Select the appropriate choice. For a normal project we select as Primary Output File & Content Files.
it is used to create file system on the target machine. Through this you can specify what details you want to provide at the target machine.
To add Icons/Any specific folders, click on Add > Folder and Folder is added. Rename the folder as per your project requirements
After the Folder is create then add the files to the setup. These will be installed in the same fashion on the target machine
Step VI:
Now we are about to create the setup before that we will setup the program icon. To do it we will do this process :
When you click on Browse, a window gets popup. Now as the icons are already added into the application setup, just click on Browse to pint to that icon and click on ok.
Step VII:
Now final step is compile the setup project. After compilation you will notice that it has generated Setup.msi in the same location which you provided when you initially created the setup project.
You can supply this msi the target machine, when you run this msi at target machine it will create a virtual directory as well as create same folder structure, which you have specified in File System. This installer will also install the specified those libraries in the registry which are specified in the Registry.
Now you can browse that application at the target machine in same way as you have done at your own machine.
What I could understand is, you have got some problem with deploying the EXE file.
This is the best tutorial I have ever seen for creating EXE or MSI files:
http://balanagaraj.wordpress.com/2007/05/29/create-exe-or-setup-file-in-net-windows-application/

Categories

Resources