I am using F# and i found that the available templates were a bit to sparse for my liking, and i want to make more. How would i go about doing that? also, how would i install these templates after I've made them?
In Visual Studio's path you will find the default templates, these are a set of zip files that get expanded into the template cach.
They are stored in
Item Templates - %VSInstallDir%\Common7\IDE\ItemTemplates\
Project Templates - %VSInstallDir%\Common7\IDE\ProjectTemplates\
Extracting the {{.zip}} in question and recompressing with the modified contents will update the template. You can also copy these files to one of the respective template folders in %USERPROFILE%\Documents\Visual Studio 2010.
For information on building templates have a look at Visual Studio Templates on MSDN.
You then need to tell VS to rebuild the cache.
Open a visual studio command line shell
Execute devenv /installvstemplates
You can also use the "Export Template..." wizard from the file menu, however the exported template loses original content such as if statements.
I ran into problems with this and multiple custom templates. Each template (e.g. vstemplate + cs file) should be in it's own zip file. If you put several into the same zip it won't pick up any of them.
I also found that if you put them in:
$My Documents$\Visual Studio 2010\Templates\ItemTemplates
then you wont need run the command (devenv /installvstemplates) mentioned by Brett. Presumably this is only when modifying the existing ones in the install folder.
Here's a sample that I use for knocking up NUnit tests:
Code file (with .cs/relevant extension):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace $rootnamespace$
{
[TestFixture, Category("issue")]
public class $safeitemname$
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test()
{
}
}
}
Template file (with .vstemplate extension):
<VSTemplate Version="3.0.0" Type="Item"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" >
<TemplateData>
<DefaultName>ATest.cs</DefaultName>
<Name>NUnit test</Name>
<Description>
with [TestFixture] attribute set on class and one empty method
called Test that has [Test] attribute
</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>someIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs"
ReplaceParameters="true">TheCodeFile.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
I'd try http://msdn.microsoft.com/en-us/library/ms185291.aspx - it seems like a good starting point, at least.
I was missing SharePoint 2010 and MOSS 2007 templates in Visual Studio 2010 development tool after my SharePoint installation. I reinstalled VS and found they were available. It looks like during installation of SharePoint pre-requisites for some reason I missed those templates from getting installed.
You can get the complete example implemented here: Multi-Project Templates with Wizard: Visual Studio 2010 Sample
You can download and install VS 2010 SDK (or VS 2010 SP1 SDK) which contains new project templates such as Item Template template and Project Template template (I don't know if there's version for earlier versions of VS and if these templates are only for C# or not).
Visual Studio 2010 SP1 SDK:
http://www.microsoft.com/download/en/details.aspx?id=21835
Visual Studio 2010 SDK:
http://www.microsoft.com/download/en/details.aspx?id=2680
Related
I have created a custom dotnet core project template following the documentation here: https://learn.microsoft.com/en-us/dotnet/core/tools/custom-templates
I can install this template, and create new projects from it, on the command line using dotnet new -i ...\mycustomtemplate and dotnet new mycustomtemplate, respectively.
Now I would like to make this template available in Visual Studio (2017)'s new project wizard but I cannot find any documentation on how to do that.
Visual Studio help only contains info about creating "Visual Studio project templates", which use a completely different configuration than the dotnet core templates, and also would not work with the dotnet core cli, as far as I understand.
Could anyone give a hint where I could find some documentation how to "install" a dotnet core custom template in Visual Studio? I would really like to have a single template that works with both Visual Studio, Jetbrains Rider and the dotnet core cli.
Or is this simply not possible?
With all credits to #willwolfram18:
You have a working custom template in the NuGet package.
Add vs-2017.3.host.json file to .template.config/.
Add Framework symbol to template.json.
Place the .nupkg file(s) into the root of a VSIX extension project and make sure to set the "Include in VSIX" flag to True.
The detailed original answer and the working prototype.
I am using Swashbuckle for Api documentation, which requires projectname.xml document from the output, but when i build my ASP.NET Core project I don't get that file.
https://learn.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger
Visual Studio has an option to generate the XML file but how can I do that from console?
Here is my ASP.NET Core version:
.NET Command Line Tools (1.0.0-preview2-1-003177)
For Visual Studio 2017 and the dotnet CLI, setting the DocumentationFile property in the .csproj file will generate XML documentation at the specified path, relative to the project file. For example, to generate the XML doc in the same directory as your built assembly, you can add the following property group to the project file:
<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\MyProject.xml</DocumentationFile>
</PropertyGroup>
If you only want it built for particular configurations or platforms, make sure to set an appropriate Condition on the property group.
If you are still using Visual Studio 2015, you can do it in the project.json by adding xmlDoc to buildOptions
"buildOptions": {
"xmlDoc": true,
}
Visual Studio 2017 (*.csproj structure) I am not sure. But when you set it via Visual Studio it will be persisted in the csproj/project.json file.
I am having a rough time figuring out how to setup cross-targeting inside a Visual Studio 2017 project and I have not been able to find any examples.
I started out with a .NET Standard 1.5 project and to keep it simple I am just trying to add .NET Standard 1.6. If I understand the documentation correctly, I should now be able to do all of this inside the csproj file without having to mess with a project.json or nuspec file.
I've tried all of these values but none seem to work:
<TargetFrameworks>netstandard15;netstandard16</TargetFrameworks>
<TargetFrameworks>netstandard1.5;netstandard1.6</TargetFrameworks>
<TargetFrameworks>.NETStandard,Version=v1.5;.NETStandard,Version=v1.6</TargetFrameworks>
This is the only source of documentation I can find on the feature and it doesn't contain a full example:
https://docs.nuget.org/ndocs/schema/msbuild-targets
https://docs.nuget.org/ndocs/create-packages/supporting-multiple-target-frameworks
I've gotten this to work on latest Visual Studio 2017. As described in this post https://blogs.msdn.microsoft.com/dotnet/2016/10/19/net-core-tooling-in-visual-studio-15/ it is the correct way to do it. My csproj file looks like this:
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
</PropertyGroup>
Visual Studio 2017 RC release notes also has this listed as a feature (under .NET Core and Docker):
Cross-target multiple target frameworks in one project.
My mistake at the start was that when I first created the project the property was called TargetFramework, I tried to add multiple targets and VS did not like that at all. It just crashes then... So make sure to rename it to TargetFrameworks and it should work.
Is there a way to programmatically add a source file to the project, given a file path?
I am trying to work on a visual studio project in sublime text 2. I can build using a custom build:
{
"cmd": ["c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe"],
"working_dir": "${project_path:${folder:${file_path}}}/../Project"
}
I can link libraries using #pragma comment(lib, "path to library")
I can include the new source files using #include ""
but I cannot add new source file to the project.
Is there any code that could do that?
In the end Filburt gave a brilliant answer here:
Is there a way to add source files to visual studio project from command-line?
There are two ways how you could do this.
You simply treat the project as XML and you edit that XML.
You use Visual Studio's COM/.NET APIs.
It is not (IMHO) easy to do it using the Visual Studio APIs but it is doable. Start at MSDN's "How to: Get References to the DTE and DTE2 Objects" and follow the links.
I am trying to convert a SharePoint 2010 solution (custom web parts, content types, lists, event receivers, etc.) developed in Visual Studio 2010 to SharePoint 2013 and Visual Studio 2012. When I open the project in VS 2012, it converts a couple of the project files but won't compile because of reference issues.
I copied the DLLs (mostly Microsoft.SharePoint..., although I needed to copy the Microsoft.Office.SecureStoreService.dll too) that were causing issues from my 2010 server to the 2013 server and fixed the references. However, the Microsoft.Office.SecureStoreService.dll still gives me compiler errors claiming "Error 203 The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)" when visual studio has no problem with the namespace and finds the SecureStoreProvider class inside it just fine.
I've also tried to change the target framework from 3.5 to 4 and only see "Install other frameworks..." in the target framework dropdown.
I'm sure that others have dealt with this, but have been unsuccessful in framing the right google search query. I'm relatively new to SharePoint in general and any help would be appreciated.
thanks,
Mike
I was able to get my solution upgraded from a 2010 project to 2013 using the following. Note that this will update your solution to use the new 2013 API. It is possible to update just the project file but still run in 2010 mode.
First edit your .csproj file (for c#).
Modify the target framework to this:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
Add this a node for the office version, I put mine directly below the TargetFrameworkVersion tag
<TargetOfficeVersion>15.0</TargetOfficeVersion>
Update references
Reload the project and update your referenced assemblies. If you haven't specified a specific version they should already be referencing the v15 (SharePoint 2013) assemblies.
Do a find replace for 14.0.0.0 to 15.0.0.0. This updates any references on your pages, layouts, and master pages to the v15 assemblies.
Change calls
Change any calls to SPUtility.GetGenericSetupPath() to SPUtility.GetVersionedGenericSetupPath()
Check each file to do a check for any hive references. You'll need to add a /15/ to these. EG: _layouts/ to _layouts/15/
Open the package "folder" in visual studio then update the properties for that package to use version 15.
Clean up
Finally do a compile clean up any missed items. Deploy your solution and make sure to test thoroughly.