Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) How to open and organize projects in solutions? (Read 11900 times)
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
How to open and organize projects in solutions?
Jan 10th, 2017 at 2:09am
Print Post  
Tim@Visual Micro wrote on Jan 9th, 2017 at 2:54pm:
5) A solution holds one or more projects. A project points to one of more source files. New users should work with single project solutions until they understand how things work.

Hmmm. Undecided

My current project involves two Sketches/Programs/INO files/Projects or whatever communicating via nRF24L01 in a Master/Slave relationship.  My thinking is that I should have one project including two Sketches/Programs/INO files.

When I use File --> New --> Project I get a Project which creates an SLN file (presumably Solution - I would have expected a PRJ file (for Project) - in its own directory.  But that file is not an Arduino file (INO), and to get it to that (this is a single Sketch project - to mix terminology) I have to save it as an INO file which creates a new Folder under the Project/Solution directory/folder.

Now I have an INO I cannot open the SLN with the intention of creating a second Program/Project/INO file in the same Solution/Project.   Cry  (Do you see why I am finding the terminology confusing?   Huh)

I know you are thinking of telling me to RTFM.  I have tried that.  Probably because of my terminological confusion I seem to remember my secondary school Swahili textbook being more comprehensible.   Shocked  I'll have to beg your indulgence to help me over the hump until things start to work.  

Thanks Smiley
« Last Edit: Jan 10th, 2017 at 12:30pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #1 - Jan 10th, 2017 at 12:38pm
Print Post  
The Visual Micro menu called "File>Open>Arduino Project" will open existing arduino projects in the same solution.

The Visual Micro menu called "File>New>Arduino Project" will create a new arduino project and add it to the solution.

The two menu items are for new users like you.

A Visual Studio solution is a .sln file which is a text file. If you want to move a solution to organize the files into a better structure then use notepad to edit the paths in the .sln

The ideal file structure is

FolderTop\solution_my_projects.sln
   \Sub Folder: Project1
     project1.vcxproj (project)
     project2.ino
     .ino/.cpp/h
   \Sub Folder: Project2
     project2.vcxproj (project)
     project2.ino
     .ino/.cpp/h


If you use the Visual Micro menus they will make life easier. If you use the standard Visual Studio menus you should take time to study how Visual Studio works.

All Visual Studio config files are text/xml files so you can edit them or you can remove them and start again
  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #2 - Jan 13th, 2017 at 7:08am
Print Post  
I am studying the page on 'About Projects and Solutions' http://www.visualmicro.com/page/User-Guide.aspx?doc=Projects-and-Solutions.html\
and the diagram in it represents just this structure:
Tim@Visual Micro wrote on Jan 10th, 2017 at 12:38pm:

The ideal file structure is

FolderTop\solution_my_projects.sln
   \Sub Folder: Project1
     project1.vcxproj (project)
     project2.ino
     .ino/.cpp/h
   \Sub Folder: Project2
     project2.vcxproj (project)
     project2.ino
     .ino/.cpp/h

which is precisely the file structure I need for my project.

I created a project, gave it a name and saved it: it appears in my IDE as an INO file (RF-Project.png attached) and in the file structure as both an SLN in its own folder and INO in a subfolder of that.  I just can't see the instructions as to how to create the second tier - what you named \Sub Folder: Project 1 etc. within the SLN and with the Master project and the Slave project (each of them with its respective INO file(s)).

How do I create this secondary level?

Thanks




  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #3 - Jan 13th, 2017 at 12:06pm
Print Post  
You can use windows explorer sometimes it's easier Smiley

In Vs>

Empty Ide

"File>New>Project>Arduino" name Project1. Make sure the location points to FolderTop\Project1

This creates  project1. Click the solution in the solution explorer then click "File>Save As". Save the solution to FolderTop

"File>Add>Project>Arduino" name Project2. Make sure the location points to FolderTop\Project2

Make sense?


  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #4 - Jan 14th, 2017 at 4:01am
Print Post  
Tim@Visual Micro wrote on Jan 13th, 2017 at 12:06pm:

In Vs>

Empty Ide

"File>New>Project>Arduino" name Project1. Make sure the location points to FolderTop\Project1


Yes - create the top level project in a designated folder.  This produced an INO in the VS IDE.  From there this is what I did:

Next, File --> New --> Project --> Arduino Project
Name : Enter the name of the Second Level Project
Solution: Select Add to Solution  
Location : (do this as third step) Browse to designated folder
OK or save or whatever.

This creates the second level project.
Next, File --> New --> Project --> Arduino Project
Name : Enter the name of the Third Level Project which in my case will be active code
Solution: Select Add to Solution[/i]  
Location : (do this as third step) Browse to Second Level Folder
OK or save or whatever. 

The key here, I think, is the selection of [i]Add to Solution
for the second and subsequent levels of folder.

In any case, I have the two INO files (masterBackChat.ino and slaveBackChat.ino) in their own subsidiary folders, and which compile independently.

Since I cannot attach three PNGs showing three views of the file structure, I have zipped and attached them.  Is this the correct structure to match the diagram in 'About Projects and Solutions' at http://www.visualmicro.com/page/User-Guide.aspxdoc=Projects-and-Solutions.html?Â...  Smiley

Also: in the image '03 Visual Studio View.png' you will see the three '... _Project' tabs.  Can I safely close those without problems with VS?  Excuse me for asking, but after all this hassle I don't want to wreck everything and have to start again. Sad

Thanks
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #5 - Jan 14th, 2017 at 1:20pm
Print Post  
Okay maybe a little time working with single project solutions in standard ways would have allowed you to understand some things that would have helped Smiley

1) You can close the code tabs in visual studio. They open again when you click them in the solution explorer (when the project is open).

2) You need to use the standard "File>Add>New Project" wizard to create new projects in specific locations. The  "File>New>Arduino Project" MENU item is for novices and works the way the arduino IDE works by creating projects in the sketch book folder.

3) You should now close visual studio and use windows explorer to correct the arrangement of your files and folders.

You only need the following

TopLevel
  mySolution.sln
  \Project1
    Project1.ino
    Project1.vcxproj
  \Project2
    Project2.ino
    Project1.vcxproj
   

After you have this simple structure and you have deleted all your duplicate or failed attempts you can edit the .sln file in the topLevel with notepad and ensure that only the two projects are referenced in it. Then save the changes to the .sln in notepad.

Then open the .sln in Visual Studio

note: there are other ways to achieve this result but it's not the function of this forum to guide people about basic visual studio use because it is already documented by microsoft.


  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #6 - Jan 14th, 2017 at 10:33pm
Print Post  
Tim@Visual Micro wrote on Jan 14th, 2017 at 1:20pm:
1) You can closed the code tabs in visual studio. They open again when you click them in the solution explorer (when the project is open).


They close automatically.  All that show now are masterBackChat.ino, slaveBackChat.ino, and RF_Communication_Project.ino.

Tim@Visual Micro wrote on Jan 14th, 2017 at 1:20pm:
2) You need to use the standard "File>Add>New Project" wizard to create new projects in specific locations. The  "File>New>Arduino Project" MENU item is for novices and works the way the arduino IDE works by creating projects in the sketch book folder.


Yeah!  Huh  These two ways of getting a new project can be confusing.  I'll have to remember to use File --> Add --> New Project.

Tim@Visual Micro wrote on Jan 14th, 2017 at 1:20pm:
3) You should now close visual studio and use windows explorer to correct the arrangement of your files and folders.


I have attached a picture of what I have.  I guess the folder RF_Communication_Project (circled) has to stay.  Otherwise, isn't that structure what we want?

Tim@Visual Micro wrote on Jan 14th, 2017 at 1:20pm:
... you can edit the .sln file in the topLevel with notepad and ensure that only the two projects are referenced in it. Then save the changes to the .sln in notepad.
.

My top level SLN is attached.  It references all five projects.  Which ones should I delete?  If I do that, how do I get them back should I choose to edit or otherwise modify them?  Shocked

BTW:  VS is a nice IDE to use, and the documentation is at least on par with any.  Your patient assistance, however, makes learning to interpret that documentation as a beginner much less painful.  Thanks

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #7 - Jan 14th, 2017 at 10:53pm
Print Post  
Thanks.

Your structure is still confused. It's much simpler than you think but you should make sure each project has a unique name otherwise the compiler cache won't be as effective.

Zip your top level folder and all sub folders into a single zip and attach here. It will be easier to see what you have.
  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #8 - Jan 14th, 2017 at 11:33pm
Print Post  
I can't upload the project as a ZIP, it's almost a MB.  Cry  It's on OneDrive at https://1drv.ms/u/s!ArMxdUYEh9fKgVgHJ5G9TBAemxR6  Sorry, but you'll have to download it.

It will be very interesting to see what you change.  It's a great way to learn.  Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #9 - Jan 15th, 2017 at 12:30am
Print Post  
The onedrive link isn't valid. you can email to info[at]visualmicro.com

It might be a great way to learn but I'd be charging a lot if I normally supported the dev environments as well as visual micro  Smiley
  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #10 - Jan 15th, 2017 at 12:59am
Print Post  
The project is in the email.  Cool

It is a great way to learn.  Apprentices learn by watching someone who know how to do it ... doing it!  Shocked  Problem is, you need someone who knows how to do it who will take the time to show you.

Perhaps you would not have people like me taking up your time if VM included pseudocode precise instructions covering the things we are discussing in Creating a New Project at http://www.visualmicro.com/page/User-Guide.aspx?doc=Create-New-project.html or a similar page.  If I had found that, I wouldn't have started this thread.  Grin
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #11 - Jan 15th, 2017 at 2:13pm
Print Post  
Attached is 3 projects below a solution called RF_Communications

Always open the RF_Communications.sln in the root. After you do this is will be on the File>Recent list and the recent list on the Start Page. 

notes: 

If you attempt to open a vcxproj or .ino from an empty IDE the IDE will create a new solution for you. The same project can be included in many different solutions but it gets confusing so stick to the RF_Communications.sln

If you open the RF_Communications.sln then you can Add Existing or Add New projects to the solution. You can also right click a project in the solution explorer to Remove them from the solution. I suggest you use test solutions to study how projects can be added and removed from solutions. I edited the .lsn, vcxproj and .vcxproj.filter files to correct/organize your existing solution. You could also delete the .sln, create a new solution in RF_Communications then right click the explorer and "add existing project" for each of your existing three projects.

You have three projects not five. I remove duplicates from below some of the projects. You should not allow projects to exist below projects but I suspect the "File>New>Project" wizard confused you because it attempts to create a solution folder with the project folder below that. Makes sense once you understand the system but it's alien speak for new users Smiley


Code
Select All
Perhaps you would not have people like me taking up your time if VM included pseudocode precise instructions covering the things we are discussing in Creating a New Project at http://www.visualmicro.com/page/User-Guide.aspx?doc=Create-New-project.html or a similar page.  If I had found that, I wouldn't have started this thread.   



I know what you mean but consider this:-

The VS users want to know what an arduino project is, what arduino libraries are and why they can't use dlls on arduino
The arduino people want to know what a visual studio solution is and how to add/remove projects from a solution
The GDB debug users want to know how to use gdb
The Serial debug users want to know how to use GDB
Most users want to know what the Arduino sketch book folder is and how to install user libs
A lot of people want to know how to write or fix Arduino code.
Microsoft and Arduino both release new IDE's quite often and each brings a whole pile of differences.
and the list goes on ....

I do agree that new users would benefit from an overview of Visual Studio solutions and projects but it's standard stuff that is documented and blogged by many, it's relatively easy for users to find this information along with all the other Arduino or Visual Studio features. 

I want to produce and support a plugin for people that is mainly free. It's a big job and to provide anymore would mean stopping the free version.

Finally, did you create a single project and learn how it works before jumping in with multiple projects? That would probably have helped you understand the various components of a project and solution. New users would normally be very confused by documentation of a multiple project solution so it's also important not to confuse the docs with too much clutter.



« Last Edit: Jan 15th, 2017 at 2:33pm by Tim@Visual Micro »  

Please Register or Login to the Forum to see File Attachments
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #12 - Jan 15th, 2017 at 11:59pm
Print Post  
There is a fair amount to digest in that post!  Huh  I'll print it and try to nail it bit by bit.

Sadly, your ZIP won't download.  Would you eMail it back please?

Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #13 - Jan 16th, 2017 at 1:19am
Print Post  
Ok, I'm not at my machine but it will download if you grab the url that appears in the horrible white window when you click the link. It's just telling you the real location of the zip.

Thanks
« Last Edit: Jan 16th, 2017 at 1:20am by Tim@Visual Micro »  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #14 - Jan 16th, 2017 at 1:32am
Print Post  
It doesn't want to play.
Closest I can get is a message saying it can't open the file.  Cry

No hurry.  When you can.

Cheers
  
Back to top
 
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #15 - Jan 17th, 2017 at 6:42am
Print Post  
Hi Tim

Boy, now I AM confused.  I thought I was already confused.   Huh

1.  Your file structure is not that shown in the top illustration on the 'About Projects and Solutions' page at http://www.visualmicro.com/page/User-Guide.aspx?doc=Projects-and-Solutions.html.  That structure is three tiers, yours only two.

2.  You appear to have moved files from where VS put them (for me) to where you wanted them (the top-level SLN for example).  The thought terrifies me.   Shocked  How does the SLN now know where the files are?

3.  You seem a bit choosy about which files and folders you keep.  I guess that if you wipe them out the VS will make them again if it needs them.

4.  I can't work out how you could have created this structure directly in VS.  You must have shifted things around using Windows Explorer.

5.  What happens if I now want to create an header file common to both working files (which is what my HLL programming instincts tell me to do, what my Arduino experience tells me is a no-no, and what I am not going to do in this project.  This question is rhetorical and can be comfortable ignored.)?  Wink

Cheers
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #16 - Jan 17th, 2017 at 1:01pm
Print Post  
Quote:
1.  Your file structure is not that shown in the top illustration on the 'About Projects and Solutions' page at http://www.visualmicro.com/page/User-Guide.aspx?doc=Projects-and-Solutions.html....; That structure is three tiers, yours only two.

No it is not different it is exactly the same as the image you linked to but three projects instead of two.




Quote:
2.  You appear to have moved files from where VS put them (for me) to where you wanted them (the top-level SLN for example).  The thought terrifies me.   Shocked  How does the SLN now know where the files are?


Vs can put solution and project in different locations depending on what you select in the File>New>Project wizard. There is an option that says to create separate folder for the solution then you would see a structure like the one I have given you. Allows for .sln in top level folder and projects in folder below.

I already previously told you that a .sln is just a text file that you can open with notepad. It is a simple file that contains relative paths of each project.

I followed the instruction that I gave you and edited the .sln to ensure it found the new structure.

Quote:
3.  You seem a bit choosy about which files and folders you keep.  I guess that if you wipe them out the VS will make them again if it needs them.

Yes, I gave you the bare bones so you could see without the clutter what a project really is. You had some duplicate folders but also some files that vs auto creates. 

Bear in mind that an arduino project does not really need the visual studio solution or project files to compile. The VS files simply bring things together for the editor and for intellisense.

So it's difficult to break. In fact you could delete the vcxproj files and use "file>open>arduino project" which recreates them.

Quote:
4.  I can't work out how you could have created this structure directly in VS.  You must have shifted things around using Windows Explorer.


Because it was already created I used windows explorer.

You need to inspect the settings on the "file>new>project wizard" and tell it to create solution and project in different folders.

Quote:
5.  What happens if I now want to create an header file common to both working files (which is what my HLL programming instincts tell me to do, what my Arduino experience tells me is a no-no, and what I am not going to do in this project.  This question is rhetorical and can be comfortable ignored.)?  Wink


With normal arduino you would create a library.

With visual micro you can create a shared project or add a short cut to the .h file. 

If you add a shortcut it will be compiled with the project code in the root of the project (although in a hidden temp folder)

You can not add include paths with arduino so you need to learn arduino then look at visual micro.

  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: How to open and organize projects in solutions?
Reply #17 - Jan 17th, 2017 at 10:23pm
Print Post  
Thanks Tim.

I think this is a key
Quote:
Because it was already created I used windows explorer.

You need to inspect the settings on the "file>new>project wizard" and tell it to create solution and project in different folders.


Planning before production.  Look before you leap.   Cheesy
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to open and organize projects in solutions?
Reply #18 - Jan 17th, 2017 at 11:23pm
Print Post  
Great thanks for the update.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint