ASP.NET Core doesn't create XML comments file - visual-studio

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.

Related

How to include project file in solution in Visual Studio for Windows but not on Mac?

Our solution contains a project type not supported on VsMac. It's a data tier app. In the solution file, there's the reference to the project:
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "SqlData", "Data\SqlData\SqlData.sqlproj", "{707B86CA-45F7-43C4-A9A4-CC2687E82056}"
EndProject
Is it possible to have this include for Windows versions of Visual Studio only?
The only option I'm aware of would be to use a separate *.sln file which is not optimal.

Is it safe to delete .dsp and .dsw files?

I've been given a Visual Studio project which has come with the following files:
myproj.def
myproj.dsp
myproj.dsw
myproj.idl
myproj.vcxproj
myproj.vcxproj.filters
After reading the Project and Solution Files Microsoft Docs it says for Projname.vcxproj:
The project file. It stores information specific to each project. (In earlier versions, this file was named Projname.vcproj or Projname.dsp.) For an example of a C++ project file (.vcxproj), see Project Files.
And this Microsoft Docs page says:
For convenience, Microsoft Visual Studio 6.0 provides a project file for each sample. This file has the DSP extension. An Allsamp.dsw workspace file is also provided in the main directory so that you can compile all the samples at once from within Visual Studio.
Does that mean that if I have the .vcxproj file, I can safely delete the .dsp and .dsw files?
Assume I do not care to ever recompile using Visual Studio 6.0 in the future.
.sln is equivalent to .dsw in VC6.0
.vcxproj is equivalent to .dsp in VC6.0
As far as I'm concerned ,if you have the .vcxproj file , you can safely delete the .dsp and .dsw files?

How to "install" a dotnet core 2.2 custom template in Visual Studio

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.

Build .net standard 1.4 class library TFS 2015 on premise

We are building a web API application for a Xamarin forms app. I included a .NET standard class library project to use as my view models. The idea being as we build out the web api endpoints - I will publish the updated class library to our internal NuGet server.
Our CI is failing. When I check in the code - I am getting a build error (using TFS 2015 on premise). The first error I received was
The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
So I added the XML namespace to the csproj
Now I get this:
There is no target in the project.
Which version of Visual Studio do you use? Can you build the project locally with VS or build with msbuild in command line?
Anyway, based on the error message, it seems related to the version of VS which created the project and the msbuild version (New .csproj project format applied in VS 2017). You can reference below threads to troubleshoot the issue:
For the first error:
The default XML namespace of the project must be the MSBuild XML namespace
Visual Studio .NET 2015 can't open migrated project
For the second error:
Visual Studio 2010 Project Targets
Add the following attribute to the Project element:
DefaultTargets="BuildTarget"
That will tell MSBuild to use the target named "BuildTarget" when we do a build. Next add the following subelement to the Project element (just before the last line, which has "</Project>"):
<Target Name="BuildTarget">
<Message Text="Build selected" Importance="high"/>
</Target>
Then save the file and close the edit window. Then return to the Solution Explorer and right-click on the solution and select "Reload Project". Then build the project. You should get the message "Build selected" along with the output of the build, as in:
So answer is not possible. I have tried install VS 2017 on the agent - that didn't work.
We did find an article that TFS needed to be upgraded beyond Update 3.
I will end up upgrading us to 2017 in a few months - which will make this a moot point.
Thanks for the answers.

Cross-targeting frameworks with NuGet 4.0 and Visual Studio 2017

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.

Resources