Solution platform not being created in new Project's platform

I have a solution with a custom solution target (x86).  When I create a new project (.net 2.0 Windows Forms Application), it creates the project file, but only with the 'Any CPU' project target.  The problem here is that if I press F5 to run the app, it doesn't build first (presumably because there is no 'Any CPU' target), which is a pain.  To fix this, I have been going into the configuration manager, finding the new project, and adding a new project target of x86 and clicking the build checkbox.  After that, the project works as expected, building before running on F5 and so-on.

The question - is there a way to automatically have newly created projects with the existing solution targets?
LVL 3
packratt_jkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

packratt_jkAuthor Commented:
Really?  25 hours and not even a comment?
0
DabasCommented:
Hello packratt_jk,

I must have a lesser version of VS to yours, as I do not even know (or find) where to set the project target.
But, this idea might help.
Once you have changed the project setting as you describe, can you go File -> Export Template, and create a new template with your settings?
You can then choose this template when you next create a new project.

Regards,

Dabas
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
packratt_jkAuthor Commented:
Dabas,

Thank you for your response.  The Project target can be found by viewing the project properties, Build tab, Labeled 'Platform'.

I think your approach of using a template is a good idea though - it will resolve this issue as well as keep future projects consistent.  I have made a new project and exported it as a template, then created a new project from this template.  Most of it works great, but there are a few things I would like to alter that I was hoping can be done in the template itself:

1) I would like the .cs filenames to have a name matching the project.  For example, if I have a project TestApp, than I would like to have file named TestApp.cs, not Template.cs as per the template.

2) I would like the namespace / class names to match as well.  Looking in the template file, I see that there is a '$safeprojectname$' variable (used in AssemblyInfo.cs).  I have tried to alter the .cs files to use this variable instead of the hard-coded names, but when I re-zip the files they are no longer detected by VS.  Also, if i extract the files with WinZip (v 12.0-8252), I get a CRC error.  I am assuming that VS does some non-standard things with the .zip file, and that's why when I re-zip it with winzip VS no longer recognizes it - is there a tool in VS that I should be using instead to re-zip the files?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

packratt_jkAuthor Commented:
I figured out the .zip files not being detected problem - I was zipping up the folder - VS expects just the files to be zipped up, not the folder they are in. Works great now, but still have the want to rename the files.
0
packratt_jkAuthor Commented:
Looks like nobody else is going to comment on this one.  Renaming the files is a whole lot better than what I had to do before, and this approach does resolve the reported issue, so I'm awarding full points to Dabas.

Thanks!
0
DabasCommented:
When you export to template, does it not ask you for a name? If you name it TestApp, then the name of the derived project will be TestApp.
You probably gave it the name Template

Dabas
0
packratt_jkAuthor Commented:
The project I made I named BoilerPlate.  The template I created from the project I named BoilerPlate as well.  After the template was made, I extracted the files and altered them so that the text BoilerPlate would be replaced by the new project name ($safeprojectname$).  After that, I re-zipped the files and copied that zip to the templates directory.  So now, when I make a new project based on that template, the namespace and project name are set to the new project's name (this is the desired behavior).  The only thing that I can't seem to change is the actual file names themselves.  For example, if i create a new project named NewProject based on this template, I will get a NewProject.csproj, as well as the files from the template (BoilerPlate.cs, etc).  Inside the BoilerPlate.cs file, there is a namespace declaration of NewProject, as well as a class named NewProject (this is the desired behavior).  This behavior resolves my initial question, as it does also pull in the project build targets and other project settings (references, etc) in from the template.  The last remaining problem (albeit a small one), is that the I would like the file BoillerPlate.cs to get created and added to the project as NewProject.cs.  This is a simple rename operation, but automating it would be nice.  I've read msdn's documentation, and there doesn't seem to be any support for this in templates (they just splat down the files from the zip), but I thought maybe somebody might know of a loophole in the mechanism.
0
DabasCommented:
The solution is not necessarily a time saver, but one I use myself.
You just create two templates:
The project template, with no files in it. Includes your .csproj file only
An item template, which includes your .cs file
Once you have loaded the Project from your project template, you click on Add, New Item, and at the bottom, under templates, you will find your BoilerPlate template, which you can then rename at will.
0
packratt_jkAuthor Commented:
Well, my base project has four different files in it, so I think I'll just stick with the current implementation which is just to rename the files.  Thanks for the suggestion though (especially post solution-accepted), I'll keep that in mind for future project ideas.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.