Feature Builder multiple projects and parameters - visual-studio

I am using Visual Studio Feature Builder to create a new Guidance in my office. Everything was working fine until I smashed my head against the multiple project template.
When you create a multiple project template it looks like there is now way to propagate parameters value in the child project of the template solution.
Any idea or tutorial or whatever as I am going mad with this.

If, for example, want to retrieve some value that is available within the template substitution dictionary, you can do this by adding a binding/command combination to the BeforeUnfold property of your VSTemplateLaunchPoint.
When the command executes, you can inspect the TemplateReplacementsDictionary which is available by accessing FeatureCallContext.Current.TemplateReplacementsDictionary.
The value of this variable is not valid in the AfterUnfold situation. However, you can access the Blackboard inside the command you bind to BeforeUnfold if you wish to save user inputs.
The same dictionary should be used for all projects in your multi-project template.

Related

How to customize generated Source Code Using Altova Mapforce Project

Background: When I generate the code for my mapping project, only one map will run, regardless of which file type I send in to the command.
I would like to modify the project code generation so that when the maps are generated the applicationConsole.cs allows multiple files and file types, and chooses the appropriate map based upon the parameters I send in.
so far, my project contains 4 maps, each one is different and has a parameter indicating whether or not to run the map. Once the code is generated, the applicationConsole.cs does not differentiate when running the maps. the first map listed in the applicationConsole.cs is run and the others are not. if the first map matches the given parameters, the output is correct, but if the next file coming in does not match, the console closes rather than moving on to the next map.
I am trying to avoid direct manipulation of the applicationConsole.cs, due to having to generate the code frequently.
the question: Does anyone know how to modify the output of Mapforce Project code generation to add a switch for map type based on file type?
In altova mapforce Application Install Directory,there is one SPL Directory. this is generate auto generate code as per your selected Language.
Take the backup of that Directory and modify SPL Directory code as per your requirement.
You need to learn SPL (Spy Programming Language) .
http://manual.altova.com/Mapforce/mapforce-enterprise/index.html?cgthewaytospl(spyprogrammingla.htm
If you need anything else then please inform me here. I have Good command on Customize the SPL.
Thank you
Take a look at refactoring under Java and C#
Really when you look at the stub code generated and you need to combine a couple maps the first refactoring task is to rename the namespace, Altova uses it's namespace as a default, so a mapa namespace would be helpful mapb namespace etc.
I'll provide the C# examples
http://msdn.microsoft.com/en-us/library/vstudio/6kxxabwd.aspx
Then you have the console app so you want to copy the applicationConsole.cs and rename it your project name or class name and then extract the method
http://msdn.microsoft.com/en-us/library/vstudio/0s21cwxk.aspx
Finally you would want to extract the interface so as to return the exception Constructor
http://msdn.microsoft.com/en-us/library/vstudio/fb3dyx26.aspx
and:
http://msdn.microsoft.com/en-us/library/tz6bzkbf.aspx
What you would have is a project with your start-up being the original applicationConsole.cs that you copied and renamed in a project or solution folder. When you update the map you should be able to over-write the code in that folder with what Mapforce generated.
This file was generated by MapForce 2013r2sp2.
YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
Refer to the MapForce Documentation for further details
This is what you will see in that file, use the technique outlined above and the tool is very easy to use. If you are a desktop programmer the refactoring might be new but it saves allot of time and effort down the road and makes the product complete.

How can one globally define a variable in a visual studio 2010 solution?

Is there any way one can define for a solution a global variable accessable by any project file or project property sheet included in the solution?
One variable is enough if that can define a path for a property sheet that every project can include.
This is desirably for a solution.
An environment variable would be ok though less desirable.
** (visual studion 2010)
Poking at it again, I can't see how to set a user defined $(xxx) vartiable in a project - yes you can in a property sheet, but In a project I have reference to the $(ProjectDir) -
The problem is I want to define a $(tree of projects root) that any project that references a specific poject can access and the root will be relative to that project.
An alternative would be if a property sheet can have access to its own path and define the project collection root (of a tree of related projects with common resources) relative to that.
It seems every one building a big system with VS has the same problem.
I don't know your use case but it doesn't sound like the best idea. This will tie all of your projects together very tightly, which violates good OO design. Microsoft hasn't included any solution-level properties for this reason. However, if you really want to do something like this, you have two ways (at least) to go about it.
The first way, and the way I would recommend against, would be to store the variable in one of your projects and make it public. Then all of your projects could access it as long as they include the project as a reference.
The second way, and the way that will retain some OO principles, would be to create a config file that all projects looked at for the variable. This could be an XML file, a CSV file, or even a simple text file. If you wanted to get more complicated, you could point to a database location since this is one of the roles of a database.

How do I pass custom action data from a Visual Studio Setup MSI to an output project via a Merge module

I have a fully working Setup project within Visual Studio 2008 that takes inputs from a UI and passes them via a Custom Action to the output - this works perfectly.
Now I have to change this so that the UI is still in a setup project but that the output is within a merge module.
The current Custom Action Data looks much like the following with EditHostUrl coming from a UI dialog editbox.
/HostUrl="[EditHostUrl]"
I now need to pass this value to the merge module and then from there use it as an input for the custom action data to the project output but there does not seem to be any documentation on how to achieve this.
To be clear Wix/InstallShield etc... are not currently options. I would also rather not embed the UI within the merge module (for reasons of separation and also it's not supported out of the box with visual studio).
The answer turned out to be reltively simple.
When the Merge Module is included into the Setup project it is truely merged and as such the MergeModule can read values from the parents UI variables as if they were its own. I had other difficulties making this non-apparent to begin with but when creating the modules and setup projects from scratch the values are in the same context.

Software To Help Me Reuse Code

I often find myself writing small (5-20 lines) files for things like input validation, reading a URL and so on. In fact, I probably write nearly the same files over and over because I either forget that I've already implemented such functionality in another project or I don't want to have to go searching for that file.
I want to know if there is a way to simply add code to a global repository from an IDE (in my case Visual Studio) and simply extract that code into whatever project I'm working on. It should be able to:
Extract code to a new file or to the currently open file in my IDE.
w.r.t. #1 I want smart defaults based on how I added the code to the repository.
Easy to use UI.
I don't need replacement/substitution of variables.
For instance, if I right click on a file I want to add to the repository then the default extraction operation is to create a new file. If, instead, I highlight some text in the currently open file and commit that, then the default is just to paste the snippet into the currently open file.
I've tried VS's snippet manager a few times, always with disappointment and quick abandonment. My biggest complaint is its interface and complexity required to add new code to it, plus the inability to extract the code to a file versus just inside whatever I have open.
You might want to check out ReSharper's Live Templates.
I don't use them to the extent that you're obviously looking for, but you can definitely create new file-based templates. I use that all the time when I create a new unit testing fixture class - just Add New Item -> From Template -> NUnit Test Fixture, where "NUnit Test Fixture" is one of my defined file templates.
Additionally, all the templates can be assigned a shortcut sequence, so you can auto-replace a given combination of text with a code snippet.
All the template configuration is file based, so you can save them to solutions or global workspaces as well.

Can I generate values for a custom parameter such as a timestamp for a Visual Studio Item Template?

I would like to include the current timestamp as part of a Visual Studio Item Template (the timestamp of when the file is created by the user). Is this possible?
It's really simple. There are several built-in replacement parameters that you can use. For a timestamp, include $time$ in the template. It will be replaced by the current date and time in the format DD/MM/YYYY HH:MM:SS.
Check this excellent guide: Create Reusable Project And Item Templates For Your Development Team
You can cause code to be executed when a template is expanded by implementing a wizard. The wizard need not have a user interface, but can populate a dictionary of name/value pairs. The values can then be substituted into the template.
Look in the Visual Studio SDK documentation for the topic named "How to: Use Wizards with Project Templates". I believe you can also use a wizard in an item template.
Also, take a look at the Guidance Automation Toolkit, which provides a declarative way to create wizards, among many other things.

Resources