Categories
Uncategorized

Publishing a Visual Studio project to an SVN repository

Few weeks ago I was asked to implement a solution where a project is updated and published in production but the developers are not allowed access to the front end web server. To accomplish this task we need to simply add an SVN repository between the developers and the production server as shown on the below diagram: VS to SVN basic diagram Some technical details: Project is stored on a Team Foundation Server and developed in Visual Studio. It is then commited to an SVN Repository and later we update the production server from that repository. On the SVN Repository server we have Tortoise SVN installed. On the developer’s PC there are installed MS Visual Studio 2010 and Tortoise SVN Client. create svn repository 1. Creating an SVN repository In this example the repository server will be called SVN-REPO-01 and is running Windows Server 2003 Standard Edition. Log on to SVN-REPO-01 with a user that has administrative rights and create a new folder in the root directory: C:Repositories then open it up and create a sub folder for the new project. I called it “New Project”.Open it up and right click somewhere in the empty area, then choose -> “Tortoise SVN -> Create repository here” When the repository is created the following confirmation message will be displayed: create-svn-repo-2 Log-off the server and advance to the developer’s PC. 2. Set up a working copy for the SVN repository. On the developer’s PC, create create the same directory structure as on SVN-REPO-01. Note: The folder must be in the same location and with the same name on every developer’s PC due to the Team Foundation Server’s synchronization functionality. Open the folder and right click somewhere in the empty area, choose “SVN Checkout…” from the context menu. Tortoise Repo browser will pop-up. Enter the following URL for Repository: http://SVN-REPO-01/svn/new project and the “Check out directory” filed should already point to the folder that we just created. Click OK. Now the local folder is set up as a working copy of the project. repo-browser Repeat this step to each developer’s PC that is assigned to this project. 3. Setup Publishing for the Visual Studio Project to to the working SVN copy. In Visual Studio, open the appropriate project. Go to the project’s publishing properties and set them as in the screenshot below: project-publishing-prop The “Publishing Folder Locations” is the location where the binary files will be saved. This must be the working copy of the SVN repository (in the example, this is: “C:RepositoriesNew Project”. For the “Installation Folder URL” fill in the URL from where the end users will be downloading the installation files for your application. 4. Committing new files to the repository SVN-Commit When the project files are successfully published from inside the Visual Studio, open the Project’s publishing folder (C:RepositoriesNew Project) right click in an empty area and select “SVN Commit…” from the context menu as on the screenshot below. If there are changes made to the project, the lower part of the window will contain a list with all the changed files – “Changes made”. Select the files you want to commit and thick their check boxes. Click OK. You will now see the files synchronizing with the SVN repository. When complete click OK. 5. Publishing to production server. Open up an SSH session to the appropriate production server (in this example the server is PROD-SRV-01). Change the working directory to “/var/www/”

cd /var/www/

Create a folder for our new project and change its ownership as follows:

sudo mkdir newProject sudo chown www-data:www-data /var/www/newProject/

Note: After each of those commands you must confirm your identity by entering your password Change the current directory to /var/www/newProject/

cd /var/www/newProject/

Now we have to let the SVN repository know that this folder will be synchronized with it. Execute the following command:

sudo -u www-data svn checkout http://SVN-REPO-01/svn/new project/ . –username=

Where after “–username=” you must type in an account that has local access to the repository on SVN-REPO-01 (probably the account which you used to create the repository folders in the beginning). Follow the on-screen instructions to complete the checkout process. The SVN repository is now synchronized with our production server and the end users are able to download and install the latest version of our application from the following URL: http://PROD-SRV-01/newProject/publish.htm Every time an update needs to be published, use the following command from the project’s directory (var/www/newProject/):

sudo -u www-data svn up –username=

Again, the account which you used to create the repository folders in the beginning. Note: Visual Studio and Windows Server 2003 Standard Edition are registered trade marks of Microsoft Inc. For additional information about Tortoise SVN, please reffer to the project’s website: http://www.tortoisesvn.netFew weeks ago I was asked to implement a solution where a project is updated and published in production but the developers are not allowed access to the front end web server. To accomplish this task we need to simply add an SVN repository between the developers and the production server as shown on the below diagram: VS to SVN basic diagram Some technical details: Project is stored on a Team Foundation Server and developed in Visual Studio. It is then commited to an SVN Repository and later we update the production server from that repository. On the SVN Repository server we have Tortoise SVN installed. On the developer’s PC there are installed MS Visual Studio 2010 and Tortoise SVN Client. create svn repository 1. Creating an SVN repository In this example the repository server will be called SVN-REPO-01 and is running Windows Server 2003 Standard Edition. Log on to SVN-REPO-01 with a user that has administrative rights and create a new folder in the root directory: C:Repositories then open it up and create a sub folder for the new project. I called it “New Project”.Open it up and right click somewhere in the empty area, then choose -> “Tortoise SVN -> Create repository here” When the repository is created the following confirmation message will be displayed: create-svn-repo-2 Log-off the server and advance to the developer’s PC. 2. Set up a working copy for the SVN repository. On the developer’s PC, create create the same directory structure as on SVN-REPO-01. Note: The folder must be in the same location and with the same name on every developer’s PC due to the Team Foundation Server’s synchronization functionality. Open the folder and right click somewhere in the empty area, choose “SVN Checkout…” from the context menu. Tortoise Repo browser will pop-up. Enter the following URL for Repository: http://SVN-REPO-01/svn/new project and the “Check out directory” filed should already point to the folder that we just created. Click OK. Now the local folder is set up as a working copy of the project. repo-browser Repeat this step to each developer’s PC that is assigned to this project. 3. Setup Publishing for the Visual Studio Project to to the working SVN copy. In Visual Studio, open the appropriate project. Go to the project’s publishing properties and set them as in the screenshot below: project-publishing-prop The “Publishing Folder Locations” is the location where the binary files will be saved. This must be the working copy of the SVN repository (in the example, this is: “C:RepositoriesNew Project”. For the “Installation Folder URL” fill in the URL from where the end users will be downloading the installation files for your application. 4. Committing new files to the repository SVN-Commit When the project files are successfully published from inside the Visual Studio, open the Project’s publishing folder (C:RepositoriesNew Project) right click in an empty area and select “SVN Commit…” from the context menu as on the screenshot below. If there are changes made to the project, the lower part of the window will contain a list with all the changed files – “Changes made”. Select the files you want to commit and thick their check boxes. Click OK. You will now see the files synchronizing with the SVN repository. When complete click OK. 5. Publishing to production server. Open up an SSH session to the appropriate production server (in this example the server is PROD-SRV-01). Change the working directory to “/var/www/”

cd /var/www/

Create a folder for our new project and change its ownership as follows:

sudo mkdir newProject sudo chown www-data:www-data /var/www/newProject/

Note: After each of those commands you must confirm your identity by entering your password Change the current directory to /var/www/newProject/

cd /var/www/newProject/

Now we have to let the SVN repository know that this folder will be synchronized with it. Execute the following command:

sudo -u www-data svn checkout http://SVN-REPO-01/svn/new project/ . –username=

Where after “–username=” you must type in an account that has local access to the repository on SVN-REPO-01 (probably the account which you used to create the repository folders in the beginning). Follow the on-screen instructions to complete the checkout process. The SVN repository is now synchronized with our production server and the end users are able to download and install the latest version of our application from the following URL: http://PROD-SRV-01/newProject/publish.htm Every time an update needs to be published, use the following command from the project’s directory (var/www/newProject/):

sudo -u www-data svn up –username=

Again, the account which you used to create the repository folders in the beginning. Note: Visual Studio and Windows Server 2003 Standard Edition are registered trade marks of Microsoft Inc. For additional information about Tortoise SVN, please reffer to the project’s website: http://www.tortoisesvn.net