Setup of Development Environment for Windows: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
 
(97 intermediate revisions by 9 users not shown)
Line 13: Line 13:
* The faster the processor, the better.
* The faster the processor, the better.
** When compiling, it all comes down to processor speed, number of cores of the processor, and the architecture of the processor.  
** When compiling, it all comes down to processor speed, number of cores of the processor, and the architecture of the processor.  
*** We have seen quite a boost in compilation speed with the new "i" series of Intel processors.
*** We have seen quite a boost in compilation speed with the "i" series (i3, i5, i7) of Intel processors.
* A multi-processor PC has its advantages.
* A multi-processor PC has its advantages.
** The SharpDevelop IDE can do parallel compilations of Projects that aren't interdependent - that can speed up compilation notably (we saw an average of 20%-40% speed gain when comparing compilation of all the Client Projects on two processor cores compared to compiling on one processor core).  We have verified this to scale very well on up to four processors (we don't have PC's with more processors than that...).
** Both the SharpDevelop IDE and the Visual Studio IDE's can do parallel compilations of Projects that aren't interdependent - that can speed up compilation notably (we saw an average of 20%-40% speed gain when comparing compilation of all the Client Projects on two processor cores compared to compiling on one processor core).  We have verified this to scale very well on up to four processors (we don't have PC's with more processors than that...).
** NAnt (our build system) can do parallel compilations of Projects that aren't interdependent - that can speed up compilation notably. We have verified this to scale very well on up to four processors (we don't have PC's with more processors than that...).
** NAnt (our build system) can do parallel compilations of Projects that aren't interdependent - that can speed up compilation notably. We have verified this to scale very well on up to four processors (we don't have PC's with more processors than that...).
* A 64-bit Operating System (e.g. Windows 7 64-bit) has no advantages for the purposes of developing openPETRA.
* A 64-bit Operating System (e.g. Windows 7 64-bit) has no advantages for the purposes of developing openPETRA.
* Disk space needed: at least 1 GB
** about 300 MB of this will be needed for the source code and compiled binaries of openPETRA;
** about 200 MB will be needed for development environment software tools;
** roughly 500 MB [+/- 300 MB…] will be needed for the .NET 4 Redistributable and the corresponding SDK).


== Time required for setting up an openPETRA development environment ==
== Time required for setting up an openPETRA development environment ==
Depending on the speed of your PC, and of course the speed of your Internet connection and the speed of the respective download servers, the setting of up of a development environment for openPETRA on Windows can take something between 40-80 minutes. Usually, there is only restart of the PC required (after installing TortoiseGit).
Depending on the speed of your PC, and of course the speed of your Internet connection and the speed of the respective download servers, the setting of up of a development environment for openPETRA on Windows can take something between one and two hours.


= Required software =
= Required software =


== Microsoft .NET 3.5==
== Microsoft .NET Framework 4 and Windows 10 ==
Download and install the two Microsoft .NET dependencies. They allow execution of and development for .NET applications (such as openPETRA).


* Free downloads from Microsoft
Download and install the Windows Software Development Kit (SDK) for Windows 10. This allows development of Windows applications incl. .NET applications (such as OpenPetra).
** '''Microsoft .NET 3.5 SP1 Redistributable'''
*** http://www.microsoft.com/downloads/details.aspx?familyid=AB99342F-5D1A-413D-8319-81DA479AB0D7&displaylang=en
**** Follow the 'Instructions' section on that web page and read the 'Important' section.
*** This is ''not needed'' (and will indeed not work!) if you are installing on ''Windows 7'', because the .NET Redistributable is already pre-installed (or even the Microsoft .NET 4 Redistributable, which will also work).
** '''Windows Software Development Kit (SDK), .NET 3.5 SP1'''
*** http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505
*** There is no need to install all the components that are available - many involve huge further downloads! Only ".NET Development Tools" and "Debugging Tools for Windows" are needed for developing openPETRA.


Microsoft recommends to run 'Windows Update' ''before'' installing those two dependencies. It might also be a good idea to run 'Windows Update' ''after'' installing those two dependencies to check whether any updates or security patches are available.
Note: If you attempt to install the 'Windows Software Development Kit (SDK) for Windows 7 and .NET Framework 4' on Windows 10 you will receive the cryptical message 'Some Windows SDK components require the RTM .NET Framework 4. Setup detected a pre-release version of the .NET Framework 4. If you continue with Setup, these components will not be installed. If you want to install these components, click Cancel, then install the .NET Framework 4 from http://go.microsoft.com/fwlink/?LinkID=187668 and then rerun Setup.'! Following that advice leads to nowhere - you must install 'Windows Software Development Kit (SDK) for Windows 10'!!!


Note: Both the Redistributable '''and''' the SDK are needed! (We currently only use .NET 2.0 for openPETRA, but the SharpDevelop IDE requires .NET 3.5 SP1 Redistributable and SDK)
* '''Windows Software Development Kit (SDK) for Windows 10'''
** https://dev.windows.com/en-us/downloads/windows-10-sdk
* '''.NET Framework 4.7.2 Developer Pack'''
** https://dotnet.microsoft.com/download/thank-you/net472-developer-pack


Once the setup has finished it suggests to run 'Windows Update' to check whether any updates or security patches are available.


== SharpDevelop 3 ==
Note: Both the Redistributable '''and''' the SDK are needed!
 
== Microsoft Visual C++ Redistributable Version 2015 ==
This might be installed by default already. But for some situations, you might only have older versions of "Microsoft Visual C++ Redistributable" installed. You need version 2015 for libsodium dlls to be loaded (see https://github.com/openpetra/openpetra/issues/174).
 
* Download at https://www.microsoft.com/download/details.aspx?id=48145
 
== SharpDevelop ==
SharpDevelop is the IDE (Integrated Development Environment) we use for developing openPETRA.
SharpDevelop is the IDE (Integrated Development Environment) we use for developing openPETRA.


* Free download: http://www.icsharpcode.net/OpenSource/SD/Download/
* [http://www.icsharpcode.net/OpenSource/SD/Download/ Free download]
* We currently use the latest SharpDevelop 3.2 build (Build 5777). (We ''don't'' recommend using the Beta version of SharpDevelop 4!)
** We currently use SharpDevelop 5.1 RC1, from 14 July 2015.
*** SharpDevelop has got a dependency on the [http://www.microsoft.com/en-us/download/details.aspx?id=5582 Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)]!
*** You will need to install this first (the SharpDevelop Installer will tell you that in case it isn't installed on your machine yet and not go ahead with the install).
 
* Developers ''within OM'' that need to open ''legacy Petra 2.x C# Solutions and Projects'' will also need to install SharpDevelop 3.2.1 to avoid the need of converting these to newer SharpDevelop Solution and Project formats every time they get opened:
** http://www.icsharpcode.net/OpenSource/SD/Download/GetFile.aspx?What=Setup&Release=Montferrer
*** SharpDevelop 3.2.1 has got a dependency on .NET 3.5 SP 1!
*** You will need to install this first (the SharpDevelop Installer will tell you that in case it isn't installed on your machine yet and not go ahead with the install).
*** To get that installed on Windows 10, do the following: Go to Control Panel / Programs and Features / Turn Windows features on or off and tick ".NET Framework 3.5 (includes .NET 2.0 and 3.0)" - Windows 10 will install it and tell you once it is finished. Then install SharpDevelop 3.2.1.


* Modifying Text Editor options
** The [[Coding Standard and Guidelines#White_Spaces | openPETRA Coding Standard and Guidelines]] specify that identation needs to be with <SPACE> characters and not <TAB> characters. To set up SharpDevelop to adhere to that standard, change the following setting: Menu 'Tools' -> 'Options…', then 'Text Edior' -> 'Behaviour', 'Tabs' GroupBox. Make sure that 'Convert Tabs to Spaces' is ticked and that 'Tab size' and 'Indentation size' are both set to '4'.


==PuTTY / Plink==
==PuTTY / Pageant==
[http://www.putty.org/ PuTTY] is a SSH and telnet client for the Windows platform. Plink is a command-line interface to the PuTTY back ends, which is used by Git and TortoiseGit (see below).
[http://www.putty.org/ PuTTY] is a SSH and telnet client for the Windows platform. Pageant comes with PuTTY and is used to load a Private SSH Key; it is used by TortoiseGit (see below) and Bazaar (within OM, see below).


PuTTY and Plink are needed for 'developer access' only, i.e. if you intend to feed your changes back to the openPETRA Git source code repository at some point. They are not needed for 'anonymous access'.
Pageant is needed for 'developer access' only, i.e. if you intend to feed your changes back to the openPETRA Github source code repository at some point. PuTTY and Pageant are ''not'' needed for 'anonymous access'.


Free download: [http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html PuTTY Download Page]
* In the section 'Package files', choose the installer under the heading 'MSI (Windows Installer)', e.g. [https://the.earth.li/~sgtatham/putty/latest/w32/putty-0.68-installer.msi putty-0.68-installer.msi]
* Since version 0.68 there is also a 64-bit release. If you run a 64-bit Windows then this is fine to use, it yields slightly better performance than the 32-bit version.
* Run the installer.


Free download: [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY Download Page]
Load your private key (a .ppk file if generated from putty) with pageant. See [https://wiki.openpetra.org/index.php/Submitting_patches_and_features Submitting Patches And Features ].
* In the section 'Binaries', choose the installer under the heading 'A Windows installer for everything except PuTTYtel', e.g. [http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.60-installer.exe putty-0.60-installer.exe]
For extra information on how to generate a private key you can refer to this tutorial - [https://winscp.net/eng/docs/ui_puttygen Generating Keys]
* Run the installer and remember the path where you install PuTTY into - you need to specify the path during the installation of Git and TortoiseGit (the installers need to be pointed to the file 'plink.exe' in that directory when they ask for it).


== Open Source OpenPetra Developers: Git/TortoiseGit ==
* Install TortoiseGit from https://code.google.com/p/tortoisegit/wiki/Download
* After that, install Git for Windows: https://git-for-windows.github.io/
** Please use the option: Checkout Windows-style, commit Unix-style line endings ("core.autocrlf" is set to "true")


== Git and TortoiseGit ==
Please follow the instructions at [[How to work with git on the command line]] or [[How to work with git through the GUI on Windows]] to get the latest version of the code.
The [http://code.google.com/p/msysgit/ Git Source Code Management System] is a distributed source code versioning system (as opposed to central source code versioning systems, such as CVS and SVN).
We use Git for the maintenance of the openPETRA source code repository.


[http://code.google.com/p/tortoisegit/ TortoiseGit] is a Windows client for Git which integrates nicely into the context menu of the Windows Explorer.
== OM-OpenPetra Developers: Bazaar ==
See [[Notes about Bazaar]]


== WinMerge ==
[http://winmerge.org/downloads/ WinMerge] is a very good tool on Windows to compare single files but also complete source code trees. See the [[WinMerge HowTo]] page for more information.


===Git on Windows===
== Uncrustify ==
Free download: [http://code.google.com/p/msysgit/ Git on Windows]
We use Uncrustify to automatically format the code so that it looks more the same.


Note: use the official git installer from that site, eg. [http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.0.2-preview20100309.exe Git-1.7.0.2-preview20100309.exe], labelled 'Full installer for official Git', not the packages that have 'fullinstall' or 'netinstall' in their name, or any other packages.
Speaking of formatting code, please have a look at [[Coding Standard and Guidelines]] too.


'''Installation options'''
We are currently using version 0.56, and it is best that all developers use the same version.
* 'Select Components' page of the installer: leave everything as it is.
* 'Adjusting your PATH environment' page of the installer: leave the radio button on 'Use Git Bash only'.
* 'Choosing the SSH executable' page of the installer: Set the radio button to 'Use (Tortoise)Plink' and specify the path to the 'plink.exe' executable by using the '...' button (this is the path that you installed PuTTY into).
* 'Configuring the line ending conversions' page of the installer: leave the radio button on 'Checkout Windows-style, commit Unix-style line endings'.


===TortoiseGit===
Please use our own installer for Uncrustify, from http://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/Uncrustify-Setup-0.56.exe/download
* Free download: [http://code.google.com/p/tortoisegit/downloads/list TortoiseGit]
** Note: There are installers for 32bit and 64bit Windows. Choose the correct one according to your operating system architecture.
** TortoiseGit is still work in progress, but works fine on Windows (we have encountered some minor hiccups, though).
** ''Please install "Git on Windows" ''before'' installing TortoiseGit (see above)!''


'''Installation options'''
For more details see [[Uncrustify]]
* 'SSH Configuration' page of the installer: Choose 'Use TortoisePLink coming from Putty, which integrates better with Windows'.


===Alternative Windows Client===
== NUnit ==
You also might want to have a look at [http://code.google.com/p/gitextensions Git Extensions], which is also a fully functional git GUI for Windows.
We use NUnit (http://www.nunit.org/, or https://launchpad.net/nunitv2/) for running automated tests.


At the moment we are using version ''3.5.0''. (Our friends at ICT need to still use version 2.6.1 for compatibility.)


===Setting up the Git repository===
Please note: it is better not to use a newer version of NUnit than NAnt supports. You might run into this problem: [http://stackoverflow.com/questions/16393665/unit-testing-with-roslyn-services-workspace-results-in-a-securityexception-while]
''After installing Git and TortoiseGit (or Git Extensions), please follow our [[Notes about Git]] to configure your local git repository for openPETRA use!''
 
System.Security.SecurityException : Type System.Runtime.Remoting.ObjRef and the types derived from it (such as System.Runtime.Remoting.ObjRef) are not permitted to be deserialized at this security level.
 
See also [[Working with NUnit tests]]


== NAnt ==
== NAnt ==
NAnt is our build system. It is used for ongoing compilation, for creation of Builds/Releases of openPETRA, and for the automation of quite a few tasks in the development lifecycle of openPETRA - including auto-generation of source code and Forms.
NAnt is our build system. It is used for ongoing compilation, for creation of Builds/Releases of openPETRA, and for the automation of quite a few tasks in the development lifecycle of openPETRA - including auto-generation of source code and Forms.


* download [https://sourceforge.net/projects/nant/files/nant/0.90-alpha1/nant-0.90-alpha1-bin.zip/download NAnt 0.90-alpha1]
* Use our own NAnt Installer for Windows, which already includes the NAntContrib files.
** please use ''this'' version as it works for us. Some of the released alpha or beta versions do not work (Example: [http://sourceforge.net/project/showfiles.php?group_id=31650&package_id=23704&release_id=560184 0.86-beta1]; it breaks with message: Property 'sdkInstallRoot' has not been set.)
** it is available here: http://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/NAnt-Setup-0.92.exe/download
* unzip the files to e.g. <code>c:\program files\nant</code>
* open a Text Editor (e.g. Notepad, Notepad++) and create a new file with the file name <code>c:\windows\nant.bat</code>. It needs to have the following content:
@echo off
"C:\Program Files\NAnt\bin\NAnt.exe" %* -t:net-2.0
* [http://nant.sourceforge.net/release/0.90-alpha1/releasenotes.html Release Notes for NAnt 0.90-alpha1]


See also our [[Notes about NAnt]].
See also our [[Notes about NAnt]].
Another possible error while trying to compile with nant is the following:
generateFrameworkPath
the path for the .NET Framework could not be found
Then you need to install ''Microsoft .NET Framework 4 SDK''


== Database systems ==
== Database systems ==
Line 112: Line 132:
** '''SQLite''': no installation effort at all is required! See [[Notes about SQLite]]
** '''SQLite''': no installation effort at all is required! See [[Notes about SQLite]]
** '''PostgreSQL ''(recommended)'''''. See [[Notes about PostgreSQL]]
** '''PostgreSQL ''(recommended)'''''. See [[Notes about PostgreSQL]]
*** get the latest version from http://www.postgresql.org/download/windows. The one click installer works fine for me.
*** Get version 9.3 from http://www.postgresql.org/download/windows. The one click installer works fine for me.
*** You need to add a Postgresql user/role in pgAdmin with your windows username. Give permissions to create roles and databases to that user.
*** In order to see the OpenPetra tables with pgAdmin go to "Server" -> "PostgreSQL" or "localhost" -> "Database" -> "petra" -> "Schemas" -> "public" -> "tables" - or use the Search function by right-clicking on the database-name.
** '''MySQL'''. See [[Notes about MySQL]]
** '''MySQL'''. See [[Notes about MySQL]]
*** get the latest Windows version from http://dev.mysql.com/downloads/mysql/. It is called MySQL Community Server. The MSI essential package works fine for me.
*** get the latest Windows version from http://dev.mysql.com/downloads/mysql/. It is called MySQL Community Server. The MSI essential package works fine for me.


If you want to switch from SQLite to PostgreSQL which we recommend for serious development, please follow the instructions at [[Setup_of_Development_environment#Use_another_database_system]].


= Optional Software =
= Optional Software =
Line 123: Line 146:
*** Menu 'Settings' -> 'Style Configurator'. Select 'YAML' in the 'Language' list and enter 'yaml' in the 'User ext.' field. Choose 'Save & Close'. (You might need to close and re-open any .yaml file that you already have open to get the syntax highlighting working.)
*** Menu 'Settings' -> 'Style Configurator'. Select 'YAML' in the 'Language' list and enter 'yaml' in the 'User ext.' field. Choose 'Save & Close'. (You might need to close and re-open any .yaml file that you already have open to get the syntax highlighting working.)
* The following pieces of software are only required when you want to build releases of OpenPetra:
* The following pieces of software are only required when you want to build releases of OpenPetra:
** Poedit (for translation, generating the .mo file from the .po file): http://www.poedit.net/download.php
** Poedit (for translation, generating the .mo file from the .po file): http://www.poedit.net/download.php (alternative: direct .mo file download from launchpad)
** Inno Setup 5 for building setup files: http://www.jrsoftware.org/isdl.php
** Inno Setup 5 for building setup files: http://www.jrsoftware.org/isdl.php
 
= Downloading of source code and configuring the build environment =
 
= Configuration of the development environment and downloading of source code =
The recommended way of installing OpenPetra.org for development is to somewhere map a 'fake' network drive, using the DOS command <code>subst</code>.
 
Open a Command Window (a.k.a 'DOS Box') and enter for example:
mkdir c:\development
subst u: c:\development
 
The Git repository should be 'Cloned' into the 'u:\openpetraorg\' directory by following one of the steps mentioned below. After cloning, that directory will contain the .git subdirectory, the OpenPetra.build NAnt script (U:\openpetraorg\OpenPetra.build) and a few more files. All the source code of openPETRA will be placed in various subdirectories.


== Get the source code ==
== Get the source code ==
===Open Source OpenPetra: Git===
The source code is managed with the Git source code versioning system.  
The source code is managed with the Git source code versioning system.  


Please understand that we will provide write permissions only to the core members of the development team, just to keep the project on one track (refered to as '' 'developer access' '' below). We very much need your contributions though, and we will aim to quickly deal with submitted patches and code. Please see our document on [[submitting patches and features]]!
You should have got the source code already if you followed the instructions at [[How to work with git on the command line]] or [[How to work with git through the GUI on Windows]].


You can get the openPETRA source code in several ways:
Especially when using Windows 7 it is recommended to checkout into a local directory (e.g. on C:) and not one on the network as otherwise compiling with NAnt can give problems. Compiling from a network drive gave the following error on Windows 7:
* see the [https://sourceforge.net/scm/?type=git&group_id=260632 Git instructions at Sourceforge]
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, ... failed
** that page describes how you can download from the openPETRA Git repository on sourceforge
* you can also browse the [http://git.openpetra.org Git repository online], and you can download a tar.gz snapshot of each version there
* ''for developer access'': more detailed instructions how to create the SSH key with the puttygen.exe program and where to upload it to Sourceforge: https://sourceforge.net/apps/trac/sourceforge/wiki/SSH%20keys
* '''The recommended way for 'cloning' the openPETRA source code repository on Windows is by using TortoiseGit (see next section)!'''


== Making a local 'Clone' of the openPETRA Git Repository ==
Please have a look at the following page: [[Submitting patches and features]]!
We illustrate the necessary steps for TortoiseGit. If you use another Git client, you will need to figure out how to do similar steps for yourself. (See [[Notes about Git]] for how to do it with the Git Bash.)
 
=== Configuring TortoiseGit for first time use ===
* Right-click the U: drive in Windows Explorer and choose 'TortoiseGit'->'Settings'.
* Click on the 'Check now' button in the 'MSysGit' section of the 'General' settings to ensure that TortoiseGit is configured correctly to use your Git installation. If this is correct, the MSysGit version will be displayed left of the 'Check now' button.
* If you want to Clone the openPETRA repository using 'developer access' (as opposed to 'anonymous access'), enter your username and email address in the 'Git' -> 'Config' settings.
** Also, in the 'Network' settings, check that the 'SSH Client' setting is pointing to your PuTTY plink.exe (or TortoisePlink.exe) file.
* Close the 'Settings' dialog by choosing 'OK'.
 
=== Cloning the openPETRA Git repository ===
* Right-click the U: drive in Windows Explorer and choose 'Git Clone...'.
* In the 'Url' field you need to enter one of the following two URLs:
* for anonymous access, you can use this URL to clone the repository with TortoiseGit:
git://openpetraorg.git.sourceforge.net/gitroot/openpetraorg/openpetraorg
 
* for developer access (with write permissions), use this URL to clone the repository with TortoiseGit:
ssh://USERNAME@openpetraorg.git.sourceforge.net/gitroot/openpetraorg/openpetraorg
- replacing USERNAME with your sourceforge username.
* In 'Directory', the value 'U:\\openpetraorg' should be left as it is.
* If you are cloning the Git repository with developer access, ensure that the 'Load Putty Key' checkbox is checked and select your Putty Key (this is the SSH key you used for creating developer access earlier on).
* If you are cloning the Git repository with anonymous access, ensure that the 'Load Putty Key' checkbox is ''not'' checked.
* Choose 'OK'.
* If you are Cloning the openPETRA repository using 'developer access', you will be asked to enter the passphrase for your SSH Key (unless you are using pageant and the key is aleardy loaded there).
* The Clone process will start. Depending on the speed of your internet connection and the speed of the sourceforge Git repository, this might take some time. Initially no progress bar will be shown, but after a while a progress bar shows the cloning process.
 
== Creating a local Git Branch ==
For development, we ''strongly'' recommend that you create a local branch, and switch to it. Then you pull updates from the server ("master") into your local branch, and push your updates up to the server in the master branch. Otherwise you get all sorts of problems with pushing and pulling, so don't commit to master at all. See also [[Notes about Git]].
 
We illustrate the necessary steps for TortoiseGit. If you use another Git client, you will need to figure out how to do similar steps for yourself. (See [[Notes about Git]] for how to do it with the Git Bash.)
 
=== Creating a local Git Branch with TortoiseGit ===
''Immediately'' after the Cloning is finished, you will need to perform the following steps:
* Open the U: drive in Windows Explorer.
* Right-click the 'openpetraorg' folder and choose 'TortoiseGit' -> 'Create Branch...'.
* Enter any name for your branch that is meaningful to you.
* Leave the radio button in GroupBox 'Base On' on the 'HEAD (master)' setting.
* Tick 'Switch to local branch' in the 'Options' GroupBox.
* Choose 'OK'.
 
 
== Creating the OpenPetra.build.config file ==
* Make a copy of the file OpenPetra.build-sample-windows.config and call it OpenPetra.build.config, for example by using the Command Prompt (a.k.a. 'DOS Box'):
U:
cd U:\openpetraorg
copy OpenPetra.build-sample-win.config OpenPetra.build.config
 
Please check your OpenPetra.build.config file and make sure the paths are all adjusted to your system and the version numbers in the paths are correct.


= Finally: Building openPETRA with NAnt =
= Finally: Building openPETRA with NAnt =
Line 202: Line 166:
We have a central NAnt script that is able to build openPETRA, to generate a lot of code and is able to do all automated tasks in the openPETRA project.
We have a central NAnt script that is able to build openPETRA, to generate a lot of code and is able to do all automated tasks in the openPETRA project.


Please go to [[Setup_of_Development_environment#NAnt_script|OpenPetra NAnt script]] for finishing your openPETRA development setup.
Please go to [[Setup_of_Development_environment#Source_Code_and_Database_Configuration_Architecture|Source Code and Database Configuration Architecture]] for finishing your openPETRA development setup.
 
If you want to switch from SQLite to PostgreSQL which we recommend for serious development, please follow the instructions at [[Setup_of_Development_environment#Use_another_database_system]].

Latest revision as of 04:44, 16 March 2023

Overview

All the development tools we use are open source themselves, so developers do not need to spend money to be able to partly or fully join the openPETRA development!

If you already have some or all of the software installed that is listed here, please make sure it is the same version that we specify before skipping the relevant section on this page!


Development Hardware Needed

Any PC that you would otherwise use for serious software development should suffice.

  • As a rough guide, a PC with a processor speed of more than 2GHz and at least 1 GB of RAM should be OK.
    • If your PC is below that specification, development will probably be possible, but rather slow and cumbersome.
    • On the other hand: Timotheus works with a Acer One Netbook, N280 CPU 1.6 Ghz, 2 GB RAM; speed is fine.
  • More than 2GB of RAM is not necessary if the only applications that you run simultaneously are the ones which are used for developing openPETRA.
  • The faster the processor, the better.
    • When compiling, it all comes down to processor speed, number of cores of the processor, and the architecture of the processor.
      • We have seen quite a boost in compilation speed with the "i" series (i3, i5, i7) of Intel processors.
  • A multi-processor PC has its advantages.
    • Both the SharpDevelop IDE and the Visual Studio IDE's can do parallel compilations of Projects that aren't interdependent - that can speed up compilation notably (we saw an average of 20%-40% speed gain when comparing compilation of all the Client Projects on two processor cores compared to compiling on one processor core). We have verified this to scale very well on up to four processors (we don't have PC's with more processors than that...).
    • NAnt (our build system) can do parallel compilations of Projects that aren't interdependent - that can speed up compilation notably. We have verified this to scale very well on up to four processors (we don't have PC's with more processors than that...).
  • A 64-bit Operating System (e.g. Windows 7 64-bit) has no advantages for the purposes of developing openPETRA.
  • Disk space needed: at least 1 GB
    • about 300 MB of this will be needed for the source code and compiled binaries of openPETRA;
    • about 200 MB will be needed for development environment software tools;
    • roughly 500 MB [+/- 300 MB…] will be needed for the .NET 4 Redistributable and the corresponding SDK).

Time required for setting up an openPETRA development environment

Depending on the speed of your PC, and of course the speed of your Internet connection and the speed of the respective download servers, the setting of up of a development environment for openPETRA on Windows can take something between one and two hours.

Required software

Microsoft .NET Framework 4 and Windows 10

Download and install the Windows Software Development Kit (SDK) for Windows 10. This allows development of Windows applications incl. .NET applications (such as OpenPetra).

Note: If you attempt to install the 'Windows Software Development Kit (SDK) for Windows 7 and .NET Framework 4' on Windows 10 you will receive the cryptical message 'Some Windows SDK components require the RTM .NET Framework 4. Setup detected a pre-release version of the .NET Framework 4. If you continue with Setup, these components will not be installed. If you want to install these components, click Cancel, then install the .NET Framework 4 from http://go.microsoft.com/fwlink/?LinkID=187668 and then rerun Setup.'! Following that advice leads to nowhere - you must install 'Windows Software Development Kit (SDK) for Windows 10'!!!

Once the setup has finished it suggests to run 'Windows Update' to check whether any updates or security patches are available.

Note: Both the Redistributable and the SDK are needed!

Microsoft Visual C++ Redistributable Version 2015

This might be installed by default already. But for some situations, you might only have older versions of "Microsoft Visual C++ Redistributable" installed. You need version 2015 for libsodium dlls to be loaded (see https://github.com/openpetra/openpetra/issues/174).

SharpDevelop

SharpDevelop is the IDE (Integrated Development Environment) we use for developing openPETRA.

  • Developers within OM that need to open legacy Petra 2.x C# Solutions and Projects will also need to install SharpDevelop 3.2.1 to avoid the need of converting these to newer SharpDevelop Solution and Project formats every time they get opened:
    • http://www.icsharpcode.net/OpenSource/SD/Download/GetFile.aspx?What=Setup&Release=Montferrer
      • SharpDevelop 3.2.1 has got a dependency on .NET 3.5 SP 1!
      • You will need to install this first (the SharpDevelop Installer will tell you that in case it isn't installed on your machine yet and not go ahead with the install).
      • To get that installed on Windows 10, do the following: Go to Control Panel / Programs and Features / Turn Windows features on or off and tick ".NET Framework 3.5 (includes .NET 2.0 and 3.0)" - Windows 10 will install it and tell you once it is finished. Then install SharpDevelop 3.2.1.
  • Modifying Text Editor options
    • The openPETRA Coding Standard and Guidelines specify that identation needs to be with <SPACE> characters and not <TAB> characters. To set up SharpDevelop to adhere to that standard, change the following setting: Menu 'Tools' -> 'Options…', then 'Text Edior' -> 'Behaviour', 'Tabs' GroupBox. Make sure that 'Convert Tabs to Spaces' is ticked and that 'Tab size' and 'Indentation size' are both set to '4'.

PuTTY / Pageant

PuTTY is a SSH and telnet client for the Windows platform. Pageant comes with PuTTY and is used to load a Private SSH Key; it is used by TortoiseGit (see below) and Bazaar (within OM, see below).

Pageant is needed for 'developer access' only, i.e. if you intend to feed your changes back to the openPETRA Github source code repository at some point. PuTTY and Pageant are not needed for 'anonymous access'.

Free download: PuTTY Download Page

  • In the section 'Package files', choose the installer under the heading 'MSI (Windows Installer)', e.g. putty-0.68-installer.msi
  • Since version 0.68 there is also a 64-bit release. If you run a 64-bit Windows then this is fine to use, it yields slightly better performance than the 32-bit version.
  • Run the installer.

Load your private key (a .ppk file if generated from putty) with pageant. See Submitting Patches And Features . For extra information on how to generate a private key you can refer to this tutorial - Generating Keys

Open Source OpenPetra Developers: Git/TortoiseGit

Please follow the instructions at How to work with git on the command line or How to work with git through the GUI on Windows to get the latest version of the code.

OM-OpenPetra Developers: Bazaar

See Notes about Bazaar

WinMerge

WinMerge is a very good tool on Windows to compare single files but also complete source code trees. See the WinMerge HowTo page for more information.

Uncrustify

We use Uncrustify to automatically format the code so that it looks more the same.

Speaking of formatting code, please have a look at Coding Standard and Guidelines too.

We are currently using version 0.56, and it is best that all developers use the same version.

Please use our own installer for Uncrustify, from http://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/Uncrustify-Setup-0.56.exe/download

For more details see Uncrustify

NUnit

We use NUnit (http://www.nunit.org/, or https://launchpad.net/nunitv2/) for running automated tests.

At the moment we are using version 3.5.0. (Our friends at ICT need to still use version 2.6.1 for compatibility.)

Please note: it is better not to use a newer version of NUnit than NAnt supports. You might run into this problem: [1]

System.Security.SecurityException : Type System.Runtime.Remoting.ObjRef and the types derived from it (such as System.Runtime.Remoting.ObjRef) are not permitted to be deserialized at this security level.

See also Working with NUnit tests

NAnt

NAnt is our build system. It is used for ongoing compilation, for creation of Builds/Releases of openPETRA, and for the automation of quite a few tasks in the development lifecycle of openPETRA - including auto-generation of source code and Forms.

See also our Notes about NAnt.

Another possible error while trying to compile with nant is the following:

generateFrameworkPath
the path for the .NET Framework could not be found

Then you need to install Microsoft .NET Framework 4 SDK

Database systems

openPETRA works with a number of Database Management systems.

  • Choose one (or more) of the following Database Management systems. (If you want to start development quickly, SQLite is sufficient, so there is no immediate need to install PostgreSQL or MySQL. PostgreSQL is recommended for serious development, however).
    • SQLite: no installation effort at all is required! See Notes about SQLite
    • PostgreSQL (recommended). See Notes about PostgreSQL
      • Get version 9.3 from http://www.postgresql.org/download/windows. The one click installer works fine for me.
      • You need to add a Postgresql user/role in pgAdmin with your windows username. Give permissions to create roles and databases to that user.
      • In order to see the OpenPetra tables with pgAdmin go to "Server" -> "PostgreSQL" or "localhost" -> "Database" -> "petra" -> "Schemas" -> "public" -> "tables" - or use the Search function by right-clicking on the database-name.
    • MySQL. See Notes about MySQL

If you want to switch from SQLite to PostgreSQL which we recommend for serious development, please follow the instructions at Setup_of_Development_environment#Use_another_database_system.

Optional Software

  • For the editing of YAML files (which we use for defining the layout of screens, the main menu entries, and code hierarchy) we use Notepad++, which has syntax highlighting support for YAML files.
    • Download Notepad++
    • Once the software is installed, it needs to be set up once to accept our file extension, '.yaml', in addition to the one is built in, '.yml' for the syntax highlighting to work:
      • Menu 'Settings' -> 'Style Configurator'. Select 'YAML' in the 'Language' list and enter 'yaml' in the 'User ext.' field. Choose 'Save & Close'. (You might need to close and re-open any .yaml file that you already have open to get the syntax highlighting working.)
  • The following pieces of software are only required when you want to build releases of OpenPetra:

Downloading of source code and configuring the build environment

Get the source code

Open Source OpenPetra: Git

The source code is managed with the Git source code versioning system.

You should have got the source code already if you followed the instructions at How to work with git on the command line or How to work with git through the GUI on Windows.

Especially when using Windows 7 it is recommended to checkout into a local directory (e.g. on C:) and not one on the network as otherwise compiling with NAnt can give problems. Compiling from a network drive gave the following error on Windows 7:

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, ... failed

Please have a look at the following page: Submitting patches and features!

Finally: Building openPETRA with NAnt

After completing all the steps that are involved in the setup of your development environment for openPETRA, you are ready for the compiling and starting of openPETRA!

We have a central NAnt script that is able to build openPETRA, to generate a lot of code and is able to do all automated tasks in the openPETRA project.

Please go to Source Code and Database Configuration Architecture for finishing your openPETRA development setup.

If you want to switch from SQLite to PostgreSQL which we recommend for serious development, please follow the instructions at Setup_of_Development_environment#Use_another_database_system.