Alati za programiranje I dio
Pisanje programa danas i prije 20 i više godina se razlikuje u nekoliko segmenata. Nekada su programi pisani u običnim tekstualnim programima a kompajlirani i linkani preko komandi koje su se unosile tekstualno u programe koje prihvataju komande u obliku tekstualnih linija. Npr. u Linux baziranim operativnim sistemima poput Fedora, Ubuntu, Open SUSE programi su pisani u nekom od editora teksta poput vi ili vim programa, dok se proces kompajliranja, linkanja i pokretanja realizira preko Terminala. I danas se ovakav način pisanja i pokretanja programa održao, posebno na fakultetima i akademskim zajednicama. Kompajliranje i pokretanje programa preko komandne linije moguće je raditi i u Windowsima, mada je ovakav pristup manje zatupljen na ovom OSu.
Programiranje u Linuxu
Ukoliko posjedujete jedan od Linux verzija OSamoguće je programirati samo sa običnim editorom teksta i instaliranim kompajlerom. vi ili vim editor teksta ugrađen je u sami terminal tako da u terminal prozoru možete obavljati cjelokupan proces programiranja, kompajliranja i pokretanja programa. Na slici 2.1 imamo prikazan početni izgled Ubuntu OSa, sa otvorenim Terminalom. Ubutnu verzija Linuxa predstavlja pored Fedore jednu od najpolularnijih verzija i najviše korištenu.
Slika 2.1 Izgled Desktopa i Terminala u Ubuntu 13
Prije samog pisanja programa potrebno je instalirati c++ kopajler u koliko već nije instaliran. Da bi instalirali c++ kompajler Na Ubuntu ilia bolo kojoj Linux distribuciji potrebno je unijeti slijedeći skup komandi:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
Sada smo u mogućnosti da kampajliramo i pokrećemo napisane c++ programe.
Za pokretanje editora teksta potrebno je unijeti slijedeću komandu:
$ sudo vi faktorijel.cpp
Ovom komandom pokrećemo vi editor u administratorskom modu, te prilikom pokretanja editora formira se nova datoteka pod nazivom faktorijel.cpp
.
Pritiskom na tipku ENTER, potrebno je unijeti lozinku za administratorski nalog. Ukoliko smo ukucali ispravnu lozinku dobijamo startni prozor editora u kojem se nalaze osnovne komande za rad sa ovim jednostavnim editorom.
Slika 2.2 vi startni pozor
Prije početka editovanja, potrebno je program staviti u INSERT mod koji nam dozvoljava unos teksta. Insert mode pokrećemo ako pritisnemo tipku i. Editor je u insert modu i možemo unijeti text. Napišimo jedan C++ program koji izračunava faktorijel unesenog broja. Takav jedan program prikazuje naredna slika.
Slika 2.3 C++ program faktorijel u vi editoru
Pritiskom na tipku ESC, prekidamo insert mode i prelazimo u command mod. Sada je potrebno datoteku zapisati na disk na nazivom faktorijel.cpp. Da bi spasili datoteku potrebno je poslije pritiksa na tipku ESC upisati:
:wq
Zadnjom komandom smo sačuvali izmjene napravljene u datoteci i izašli iz vi editora. Sada smo u mogućnosti da kompajliramo i pokrenemo program. U terminal upišimo komandu:
g++ -o FAKTOR faktorijel.cpp
Ukoliko nema kompajlerskih grešaka naš program je spreman za pokretanje. Program pokrećemo na način da u komandnu liniju ukucamo:
./FAKTOR
Naredna slika prikazuje test programa za unos broja 3.
Slika 2.4 Test programa FAKTOR za unos broja 3
Pisanje programa na ovakav način može služiti samo za male i demonstratorske primjere kada imamo nekoliko datoteka i jednostavnu strukturu programa.
nastavlja se…
Add EULA to ClickOnce Installation using Visual Studio 2015
ClickOnce technology is very smart and useful when you want simple, small and smart piece of software for deploying your Windows Forms or WFP application. This is specially useful if you deliver application which doesn’t require administrator rights during installation. ClickOnce is very powerful if you wants automatic update of your product, you can decide whenever the update appears before or after app is run. Also by using certificate you can deliver reliable and secure product to your customers. Long time ago I wrote detailed blog post how to make ClickOnce deployment.
But one big thing is missing in ClickOnce deployment and for most of dev community is the feature which should be included by default. The feature which missing is “End User License Agreement” (EULA). There is no simple way to implement it. Searching the internet I have found one forum on Microsoft site describing how to implement it. Only way you can get ELUA at the beginning of the ClickOnce installation proces is by using it as prererquested component. Actually you build a redistributable component which would be seen as prerequsites dialog box under the publish window. To build custom prerequisites component you need a three files:
- Product.xml. – which is the file for bootstrapper and Visual Studio to show a component in prerequisites dialog,
- Package.xml – which is the file containing all information about the component to be installed,
- EULA.txt – your ELUA text for user to accept.
Those three files must be installed in the location where all components are registered: C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages
For this blog post I have prepare demo sample which look like the following picture:
As can be seen, there is a two folders and one xml file. Each folder contains two files described earlier. Folders “en” and “de” means we are going to have EULA translated on two languages.
In order to successfully registered perquisites to be visible by Visual Studio we need to define proper content of the product.xml. The following xml code show content of our demo sample:
<?xml version="1.0" encoding="utf-8" ?> <Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" ProductCode="EULA.Bootstrap.Component"> <!-- Defines list of files to be copied on build --> <PackageFiles> <PackageFile Name="en/eula.txt"/> </PackageFiles> <Commands> <!-- Open eula.txt without any parameters --> <Command PackageFile="en/eula.txt" Arguments='' > <!-- These checks determine whether the package is to be installed --> <!-- No install conditions --> <InstallConditions> </InstallConditions> <!-- Exit codes --> <ExitCodes> <ExitCode Value="0" Result="Success" /> <DefaultExitCode Result="Fail" FormatMessageFromSystem="false" String="GeneralFailure" /> </ExitCodes> </Command> </Commands> </Product>
As we can see xml content is self-described, it contains product information, files to be installed, installation conditions and exit codes.
Each folder (en, de, …) contains package.xml file which holds localized messages and list of files to copied on build. The following xml content shows content of our en demo sample:
<?xml version="1.0" encoding="utf-8" ?> <Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" Name="ClickOnceWithLicenseAgreement" Culture="Culture" LicenseAgreement="eula.txt"> <!-- Defines list of files to be copied on build --> <PackageFiles> <PackageFile Name="eula.txt"/> </PackageFiles> <!-- Defines a localizable string table for error messages and url's --> <Strings> <String Name="DisplayName">ClickOnceWithLicenseAgreement 1.0 (x86 and x64)</String> <String Name="Culture">en</String> <String Name="CancelFailure">User Refuse to Accept to ClickOnceWithLicenseAgreement End User License Agreement.</String> <String Name="GeneralFailure">A fatal error occurred during the installation of ELUA Component Execution</String> <String Name="AdminRequired">You do not have the permissions required to install this application. Please contact your administrator.</String> </Strings> </Package>
The EULA.txt file contains the text user need to accept in order to install the product.
For this demo we created folder EULAPackage, put product.xml and two folders en and de because we are going to support two installation languages (see picture above).
Copy the EULAPackage folder in to : C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages
Now we have set all necessary information about ELUA component and can be included in our demo sample.
- Open Visual Studio 2015 and create new WFP application.Name it as “ClickOnceWithLicenseAgreement“
2. Right-Click on the Project and select Property menu option, then select Publish tab item of the Project Property window.
3. Click on Prerequisites Button, then you will see your prerequisite component in the standard prerequisites lists.
4. Select ClickOnceWithLicenseAgreement component and click Ok button. Afterwards click Publish button to build installation package.
5. Open publish folder from the disk. DoubleClick Setup.exe and the ELUA window should be appeared:
6. Now user has two choises to accept or Refuse the EULA, which means install or not install the app.
Prerequested demo sample component for EULA can be downloaded from .
Happy programming.
How to Install Windows 10 on Microsoft Azure
It is great time Windows 10 is released and there are huge amount of hype everywhere on the internet. I am using Windows 10 from the beginning through the Insider program, and all I can say the Windows 10 is the greatest and the best OS ever made.
There are plenty of blog posts and articles about the Windows 10, and everybody who is using previous version of the Windows OS should upgrade to Windows 10. As soon as you upgrade you will see the difference and better experience in all aspects.
For this blog post I would show you how to install Windows 10 on Azure, and how to enable some of the great feature. So lets start.
1. First of all go to your Microsoft Azure Subscription Portal.
2. Create New Azure Virtual Machine
3. Start defining Virtual Machine Parameters by defining OS version. Select Windows 10 Enterprise (x64)
4. Define Virtual Machine Name, username, and password.
Note: This User name should not be developer username, because you have some restriction for Administrator when developing Windows Application. For this reason I have defined bhrnjica_admin user name. My developer username will be bhrnjica, which will be defined later.
5. Define Cloud service name, DNS Name and Region. In this step it is also neccessery to open all port you will need. In my case I have opened the following port:
- Remote Desktop – this is default without this port you are not able to connect to this machine.
- PowerShell in case you are working on PowerShell.
- MSSQL port if you are planning to install Microsoft SQL Server on this machine.
- MySQL is you are planning to install MySQL server.
6. The last step is to enable some components to be installed on the virtual machine. You have option to include some Antimalware software as well as some Virtual Machine Agent.
7. After you click on the last OK button, wait some time (few minutes) and you should see the following status on you Microsoft Azure Portal.
8. To connect to your created Windows 10 machine, click Connect button to download RDP connection (See picture above). Double click to downloaded RDP file, enter your credentials.
9. Then you have your Windows 10 Azure Machine.
10. Enjoy on your Windows 10 Azure Machine
Where is Debug – Exception menu option in Visual Studio 2015
Few days ago Microsoft launched Visual Studio 2015, the long waited release with tons of great features. In the last three years I held several sessions on Microsoft and Community conferences about some of the new feature in Visual Studio 2015, like new C# and VB compiler so called Roslyn, new JIT 64 compiler, Framework 4.6 , native Compiler, as well as great new Debugging and Profiling tools.
During daily development I am using Debug features a lot. First time I have opened Visual Studio 2015, I could not find Debug Exception option. Usually the option is under Debug menu.
After some researching I have found the option in Debug->Window->Exception Settings. Now the Exception Setting window is modless dialog, so you can set the option without interrupting debug process. Also there are powerfull filter to quickly find right exception you want to throw.
There is a great video about this feature which you can see here and see why Visual Studio team moved this option to Debug-Windows menu option.