HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: Wibo on January 15, 2015, 10:13:21 PM

Title: Recommended Development Environment
Post by: Wibo on January 15, 2015, 10:13:21 PM
Hi all,

did a lot of reading this evening and wondering what Visual Studio version is used by the gurus.
Simply could not find it...

I used VS2010 because I like it and I saw it mentioned at the forum.
I had to change <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> it was 4.5
This indicates vs2013
I had to install MSBuild2013 before the project builds.
Maybe this is also an indication for VS2013

Well I could be wrong (shit happens), are you all using VS2013?

Best regards,
Wibo.

Title: Re: Recommended Development Environment
Post by: Gene on January 15, 2015, 11:18:22 PM
HG VS solution file is built with VS2013.
There's a community edition available:

http://www.visualstudio.com/it-it/downloads/download-visual-studio-vs#d-community (http://www.visualstudio.com/it-it/downloads/download-visual-studio-vs#d-community)

Cheers,
g.
Title: Re: Recommended Development Environment
Post by: bkenobi on January 15, 2015, 11:27:40 PM
Here's an English version of the page for those that don't speak Italian.   ;D

http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#d-community (http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#d-community)
Title: Re: Recommended Development Environment
Post by: NicoVermeir on January 16, 2015, 08:10:55 AM
Visual Studio 2013 here (both for the win phone app and HG solution). together with ReSharper, it's the ultimate dev tool :)
Title: Re: Recommended Development Environment
Post by: Wibo on January 16, 2015, 06:43:30 PM
Hi all,

thanks again for all the help I get.

Untill now I've been hacking my way in, time to create a clean vmware and install the same tools.

Downloading VS2013 Community...
and of course I want resharper, so downloading v9

I'll be busy for some time...

regards,
Wibo.
Title: Re: Recommended Development Environment
Post by: bkenobi on January 16, 2015, 07:24:18 PM
I've been using VS2010 express with some success recently.  I started installing VS2013 Community yesterday before I realized how big a download it was.  I'll try again and just grab the ISO this time.  Resharper v9, sounds good.
Title: Re: Recommended Development Environment
Post by: Wibo on January 18, 2015, 10:33:57 PM
Hi bkenobi,

I'm making a new dev environment for HG based on a fresh win7 install.
Since this is not something I'm planning to do often, It could be good idea to write some sort of a tutorial about what I did to get it working (Unique chance, a newbie writing a tutorial).

The plan is to write something for less experienced programmers...
Please let me know if there is any need for this, because it takes a lot of extra time.

Regards,
Wibo.
Title: Re: Recommended Development Environment
Post by: bkenobi on January 19, 2015, 04:52:41 PM
Tutorials are never bad!
Title: Re: Recommended Development Environment
Post by: Wibo on January 19, 2015, 09:30:01 PM
Hi all,

Here's a draft of my tutorial, colleagues tell me I have a typical style.

Just let me know if this is usefull.

regards,
Wibo.

Title: Re: Recommended Development Environment
Post by: Wibo on January 19, 2015, 09:30:32 PM
Hi all,

To me it seems a good idea to post the complete setup since I'm setting it up from scratch.
Already could compile, debug and run HG on windows, but a lot of hacking was needed.

You need to know that I develop(and hack) in virtual machines using VMware workstation 10.
I really like to blow up a vm without compromizing the host.

I'm targetting this report on people that have basic knowledge of Windows, Visual studio and Svn.

Here we go!

Took a vmware that only has a fresh Win7pro 32bit installed, it's a lean and mean win7, all eyecandy is disabled.

Integrated development environment (Obviously you need a compiler)

Installed VisualStudio 2013 Community.
It's free, it doesn't seem to have the limitations of the express edition.
Totally missed the announcment in november last year, but this is a big improvement for developpers.
There are not many configuration options during setup, so this part is very hard to screw up.

Version control (you need this to get the source files and view history)

Installed TortoiseSVN 1.8.10
It's free and the setup is really easy, just download the right (32/64) version for your os.

Integrated version control for Visual Studio (You can do without it, but I think it's handy)

Installed AnkhSvn 2.5.12566
It's free, it's getting pretty good, it can handle multiple repositories.
The setup is easy, you only need to know that (sometines) you have to select it in Visual Studio, enough tutorials online so good

luck.
You can work perfectly without AnkhSvn if you know svn well, it's just handy.

The finishing touch (You can do without it, but I think it's really handy)

Installed Resharper V9Update1
It's NOT free, you can get a 30 day trial or be creative.
You can work perfectly without resharper, but I'm addicted to it.

=====================================
Finished installing software(for now)
=====================================

All software needed to compile/debug and getting the code is now installed.
Let's get the code...

Get yourself a folder somewhere convenient(it's source code!) and call it HomeGenie or whatever convention you're already using.
Now right click on the folder and select SVN Checkout...
Insert the URL of the repository: svn://svn.code.sf.net/p/homegenie/code/trunk
Click OK and it should get the latest revision of HomeGenie.
In my case that was revision 460

Before starting the solution please make 2 folders bin and debug
You create this path: HomeGenie\HomeGenie\bin\debug
Copy really EVERYTHING from HomeGenie\BaseFiles\Windows to HomeGenie\HomeGenie\bin\debug

Now we have the code, find the solution file HomeGenie_VS10.sln
Let's first take windows, later on linux will be discussed, I don't do mac.

If you've gotten so far, let's build.
Well that became very simple since revision 460.
Just open a context menu on the solution or choose it from the menu or hit F6 like I do.
The first time you run there's a possibility that you encounter an unhandled exception.
Stop execution with SHIFT-F5 and run again, this workaround works for me, it only happens once.

If you want to see what's going on, my advise would be to open the output window.
It's under menu->DEBUG->Windows

*****************
Finished building
*****************

I could now start running and debugging, but before you do that, remember I had a clean install.
If you've installed the windows version of HomeGenie you must stop the HomeGenie service before doing that.
If you don't you'll have 2 HomeGenie services at the same time listening on different ports.
If the first HG is on port 80, the second will take 8080 and the third 8081 and so on.

There was an issue when running HG the first time.
The system could not find System.Data.SQLite.dll or one of its dependencies.
The workaround is to start it again for now, this only happens once and you really need a fresh checkout to let it happen.

The HomeGenie project's name should have a bold font, that means it's the startup project.
If it's not the active project, make it the active by using the context menu.

Now hit Run in your toolbar.
A console window should open and you see HomeGenie logging.
Open a browser and go to http://localhost/ (http://localhost/)

Now you can debug if you know how to use Visual Studio.

If you have a clean win7 install like me, there is only IE8 and HG doesn't look pretty.
Get yourself an up to date browser, IE, Firefox, Chrome, they all work.

This is the first part of the tutorial, I'll wait for reactions before I spend more time on it.

Deploying to RPi with my own HG modified code or latest HG revision and the same for RaspberrySharp.IO on Raspberry Pi is my next

goal.
It could be the next chapter...





Title: Re: Recommended Development Environment
Post by: bkenobi on January 19, 2015, 11:43:17 PM
Looks helpful.  When I installed VS2010 Express I also had to install a Mono compiler.  Does VS2013 Community include a Mono compiler by default, or did you install one that wasn't listed?
Title: Re: Recommended Development Environment
Post by: Gene on January 20, 2015, 03:18:22 PM
Hi Wibo,

I tried to fix problems in VS solution file.
Now to compile it just needs one step:

- right click on the main solution folder and select Build All.

When debugging no worries about http port 80 already taken since HG automatically locates the first free port >= 8080 if the default one is already in use.
To find out what port HG is running on, just look at the output in the console window. The first line will tell on which port hg is running.

Quote
I think that creating linux packages and windows installers is something that must be done centralized(read Gene).

I read, but dunno how to do this.

If you're curious about what inside the Linux Packager project, I'll tell you, it's just a bash script that call dpkg to build the debian package.

Cheers,
g.
Title: Re: Recommended Development Environment
Post by: Wibo on January 20, 2015, 06:54:52 PM
Hi all,

@bkenobi
I used VS2010 pro first time and had no need for a mono compiler, afaik this is only needed on platforms where VS doesn't run.
When modifying the RaspberrySharp.IO library I compiled it on windows with VS2010.
Copied my test program on the RPi and excecuted it with "sudo mono MyTest.exe"
Mono on RPi did everything for me as VS did everything for me on windows.

@Gene
Got me a fresh checkout on r460.

Can confirm (Re)build all works without prebuilding anything on the win solution.
The SQLite issue is back, but that was your intention, I checked you're changes.
I'm going to correct the draft tutorial by modifying the previous post if that's ok.
I'll throw in the port stuff that I didn't know off and explain how to fix the SQLite issue.
Just sit back, I'll do the work.

Thanks for the info about the bash script and dpkg, now I know what to search for.
This is not a high priority anymore, just wanted to know how far I could get.

Regards,
Wibo.
Title: Re: Recommended Development Environment
Post by: Wibo on January 20, 2015, 08:56:51 PM
Hi Gene,

there is an easy workaround for the SQLite issue, but the cause is unclear to me.
The problem is that I can't reproduce it any more.

I took a fresh checkout r460, build and run and exception.
Second and third run everything was fine.

I took a new fresh checkout r460, build and run and exception.
Second and third run everything was fine.

I took some other fresh checkouts(3) and the problem was gone.

Since I have no copy of the exception I have to do this from memory.
It was a SystemFileIOException telling that System.Data.SQLite.dll or one of its dependencies could not be found.
The exception was thrown in SQLite? where it dynamically loads all kinds of stuff.

It smells like a timing bug, but I'm not sure.
It's not a big deal to me, but I wanted you to know.
If it happens again I'll make sure I got you decent info.
Nothing so frustrating as a bug that disappears while you're hunting it.

Regards,
Wibo.
Title: Re: Recommended Development Environment
Post by: Gene on January 20, 2015, 09:06:27 PM
Hi Wibo,

SQLite dll files are copied over the build directory from the Common/Windows solution files, so this project must be built each time your clean the output folder.
In HomeGenie project the dll MUST be not flagged as "copy to output folder".
This is because Linux-Mac and Windows solutions use different version of the SQLite library that is indeed copied by the platform specific project (Common/Linux or Common/Windows).

Cheers,
g.
Title: Re: Recommended Development Environment
Post by: Wibo on January 20, 2015, 09:18:02 PM
Thanks for the quick answer Gene!

The info you just provided was already known to me.

The strange thing about this is that the behavior between multiple checkouts is different.
With a checkout I don't mean Sourcesafe checkout.

I mean svn checkout in a completely empty folder.
Sometimes it failed to run and now you don't need to do anything to succesfully run HG.
The problem just disappeared.

regards,
Wibo.
Title: Re: Recommended Development Environment
Post by: Wibo on January 20, 2015, 11:54:31 PM
Sorry made a mistake.

The behavior is very reproducible, i copied a "fresh" checkout from a folder already build.

First time you take a checkout and run it has an exception.
After that it's fixed, second run works.

HG heals itself!

Call it a day...
Title: Re: Recommended Development Environment
Post by: Wibo on January 21, 2015, 09:17:35 PM
Hi Gene,

report as promised...

The exception is attached.

Setup for completeness:
win 7 pro 32 bits
VS2013Community
svn checkout into empty folder
start windows solution
build all

=========================
Checking HomeGenie\bin\debug
System.Data.SQLite.dll is present (version 1.0.85.0)
Checking HomeGenie\bin\debug\x86
SQLite.Interop.dll is present (version 1.0.85.0) (821,760 bytes)
Checking HomeGenie\bin\debug\x64
SQLite.Interop.dll is present (version 1.0.85.0) (1,064,960 bytes)
=========================

Run homegenie and the attached exception is thrown.
SHIFT-F5 to stop it.
Run again and everything is fine and stays fine.

=========================
Checked the same files as I did before and nothing changed.
Checked all files in the HomeGenie\bin\debug and subfolders.
No files are added.
=========================
It really some SQLLite thing, the exception takes place when HomeGenie.Service.Logging.StatisticsLogger.OpenStatisticsDatabase() is called.
The call causes the CLR to load SQLite.Interop.dll since it uses SQLiteConnection

Things I didn't try:
Updating to the latest SQLite 1.0.94.1
or dowgrading to the 1.0.66.0 (that's obviously for the RPi)
I didn't try to use filemonitor or other low level tools to find out what's missing the first time.
Don't know a lot of SQLite and google is full of issues on this problem.

Gene, if you want me to dig deeper, just tell.
I can perfectly live with this small issue. (The workaround is so easy)

regards,
Wibo.
Title: Re: Recommended Development Environment
Post by: Wibo on January 22, 2015, 08:29:22 PM
Hi Gene,

I decided to do literally what you told me.
Copy everything from HomeGenie\BaseFiles\Windows to HomeGenie\HomeGenie\bin\debug
The problems are gone than.

It feels unnatural to me to copy files like Dummy.cs and Windows.csproj to the bin\debug.
Hope you understand that I want to understand why I'm copying these files.

I'll take more time to learn HomeGenie, thanks for all the help.

regards,
Wibo.

PS: I'll update the tutorial