Is it possible to create a project template containing three projects?
I've built a sample project for my client which contains the basic structure for all their new applications. It would be sweet to be able to create a project template from it to make everything a lot easier.
Projects in the solution
ProjectName.Abstractions
ProjectName.Services
ProjectName.WebClient
What I really would like is a solution template =)
There are no solution templates, but there are multi-project templates:
http://msdn.microsoft.com/en-us/library/ms185308(v=VS.100).aspx
If you want to create a solution which contains three project as above. Just follow method of creating multi-project template.
And then in .csproj file of main project,
replace
<ProjectReference Include="\ProjectName.Services\ProjectName.Services.csproj">
<Project>{7D31A904-BA57-4CDA-XXXX-XXXXXXXXXXX}</Project>
<Name>ProjectName.Services</Name>
</ProjectReference>
with below code,
<ProjectReference Include="\$safeprojectname$.Services\$safeprojectname$.Services.csproj">
<Project>{7D31A904-BA57-4CDA-XXXX-XXXXXXXXXXX}</Project>
<Name>$safeprojectname$.Services</Name>
</ProjectReference>
Related
I only have the names/locations of my other projects but I dont want to require the developer to add project dependencies himself.
So my prebuild event needs to add "references" (=anything that makes the current project depend on the other one) via some kind of msbuild magic.
Is that possible?
Desired pseudo code:
<Task Name="MyOwnPrebuild">
<AddProjectDependencies ItemGroup="#MyProjectPaths" />
</Task>
Where I would fill the #MyProjectPaths array by iteratating over my windows folders recursively in some other task before calling this one.
In my specific case there is (luckily!) a stupidly simple, yet beautiful answer:
<ItemGroup>
<ProjectReference Include="..\**\*.csproj">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
This includes all my projects from all(?) subfolders! Exactly what I want in this particular case. If I want to restrict to a specific type of project, I could easily use a more specific regex.
I am working on creating a custom Visual Studio template for multiple project types. I would like to be able to add reference across the projects in the solution. e.g. MVVM solution where View, Model and ViewModels are each in their own projects. I'd like to have the View have reference to the ViewModel project and the ViewModel project to have reference to the Model project.
Only documentation I can find on MSDN calls for strongly named assemblies to be referenced.
http://msdn.microsoft.com/en-us/library/ms185290.aspx
I am able to get partially there, by modifying the .cproj file using some of system parameters, but this is heavily dependent on naming conventions etc. for instance I can have the Model project referenced in the ViewModel project because the concatenation of the $safeprojectname$ and "Model" makes the correct assembly name. But I cant get reference of the VM in the V, nor can I add any references to any testing projects.
<ItemGroup>
<ProjectReference Include="..\$safeprojectname$Model\$safeprojectname$Model.csproj">
<Project>{30C01E8B-96AE-45B4-A7B5-8F7BDCA4BDAB}</Project>
<Name>$safeprojectname$Model</Name>
</ProjectReference>
</ItemGroup>
Does anyone know how I can go about achieving this in the template?
Thanks.
I dont know if this is the correct way to do this, but this is what I did. I ended up opening the config file in a text editor and replacing/adding the appropriate project references as necessary. By using appropriate naming conventions I was able to programatically create the project files, sub folders etc.
My team is creating some standard VS solution templates. We have a well-defined project structure, resources, etc. that we need to use every time we start a new project and this is the perfect solution. The basics work nicely.
However, as well as defining folder structure (etc.) it would be nice to be able to import a number of projects from VSS/TFS. We have a number of shared assemblies that will be used by all projects and it would be awesome to add a reference to these projects when creating a new project via our template. Can anyone tell me if this is possible and, if so, how it can be achieved?
I think there are 3 types of items you might want to templatize (is that a word?).
New Solution
New Project added to a solution
New item added to a project
I'm not sure whether its possible to add existing projects to the solution that is created when a project template is run. http://msdn.microsoft.com/en-us/library/ms185308.aspx shows how to create multiple project templates. You may have to either manually add them to the solution or create a script that modifies the .sln file to do that part.
Adding an assembly reference to either a project or item template is easily doable. The project template is pretty simple since you just need to modify your .vstemplate file for the project template(s). See http://msdn.microsoft.com/en-us/library/ms171405.aspx for reference.
Adding a new assembly reference when you add a new item from a template is a bit harder but can also be done. See http://msdn.microsoft.com/en-us/library/ms185290.aspx for more.
Have fun!
At first I was just looking for the difference between Resource and Embedded Resource; then I noticed all these other Build Action types: Compile, Content, Embedded Resource, ApplicationDefinition, Page, Resource, SplashScreen, and EntityDeploy.
I understand some of these but some are more vague and a clearcut definition would be helpful in addition to some examples of when you might use each.
Thank you,
Compile: Pretty self explanatory. Visual studio should try to compile the code. (cs, vb code files)
Content: Required file for deployment. (ASPX, ASCX pages, Readme files etc.)
Embedded Resource: Embeds the file into the assembly DLL. (nHibernate mappings typically, any sort of content that you don't want to be separated from the assembly)
All of the build actions correspond to MSBUILD ItemGroups. If you open your .csproj file in Notepad, you'll see a list of your sources like this:
<ItemGroup>
<Compile Include="Accounts._ORMCustomToolReport.cs"/>
<Compile Include="Class1.cs" />
</ItemGroup>
There are MSBUILD targets that process the particular ItemGroups in particular ways. In particular, for a C# project, the "Compile" ItemGroup will be compiled by the CSC compiler.
In the past I have created ItemTemplates for classes that I regularly use in VS2008. I want to create a template for a solution that will have two projects, a Web Site and a Class library.
I have not been able to find any clear instructions on how to do it. I am not sure if it can be done. Does anyone have any links to a possible solution.
Thanks
There are detailed instructions on MSDN for creating custom project templates in VS2008.
-Edit-
There is no such thing as a "Solution Template." There are Item Templates (for new files), and Project Templates. However, I think what you may be looking to do is to create a specific type of Project Template called a Multi-Project Template.