Now that I figured out how to enable scaffolding in ASP.NET Core MVC (see View scaffold templates in ASP.NET Core), I'd like to create custom template files for Views. I found one place that said the template files are located here:
C:\Users\{user name}\.dnx\packages\Microsoft.Extensions.CodeGenerators.Mvc\1.0.0-rc1-final\Templates\ViewGenerator
But I copied an existing file there and that copied file does not appear in the Template dropdown on the Add View dialog. Are they located elsewhere, or do I have to do something to get files added in that folder to appear? Restarting Visual Studio did not do that.
I am using Microsoft.VisualStudio.Web.CodeGeneration.Tools 1.0.0-preview2-final
Templates are located here...
C:\Users\{username}\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\1.0.0-preview2-final\Templates
Copy the Templates folder to your project and edit them as required.
I´m using Visual Studio 2017 and asp.net Core 2.0, and after search a lot, I´ve just found the Templates on this place:
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.visualstudio.web.codegenerators.mvc\2.0.0\Templates
I hope this could help someone with the same issue...
;)
Latest version as of Oct 2018 could be found in GitHub of the Asp.NET https://github.com/aspnet/Scaffolding/tree/master/src/VS.Web.CG.Mvc/Templates
You can enable code generation rather than copying from templates folder.
Using the tutorial Asp.Net Core Using existing db
Tools > Nuget Package Manager > Packagae Manager Console
Run the following commands one after the other. Make sure you have internet connection.
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
Rebuild the solution. Then right click on the controller folder > new > controller...
Related
I'm trying to use Bootstrap in my ASP.NET MVC5 project (I'd like to use .NET 5, but Visual Basic is not fully supported yet.)
I installed the latest NuGet package, but no folders/files were added to my project—only the package itself under the References node.
I found this extensive answer, but it's somewhat dated and it addresses a project architecture of ASP.NET Core. I added the suggested Package.json file, but no folder node_modules was added anywhere in my project.
How do I get started using the Bootstrap NuGet package in my MVC5 project?
--EDIT--
I'm using PackageReference, not Packages.config.
For Bootstrap is a client-side library,If you download by Nuget Package Manager, you can find it in the %UserProfile%\.nuget\packages directory. You could copy and paste it to your project.
Actually I suggest you could use LibMan for client-side library.
Here is the steps you could follow:
Create the folder wwwroot/lib;
In Solution Explorer, right-click the project folder in which the files should be added. Choose Add > Client-Side Library.
Search for bootstrap#5.0.2 like below:
Click the Install button to download the files.
Reference:
Use LibMan with ASP.NET Core in Visual Studio
Note:
The js and css are in wwwroot/bootstrap/dist/.
I created a solution on Visual Studio 2019 and that solution contains ASP.NET core MVC Web application. When i try to add new controllers it gives error and not able to add it.Error is "There was an error running the selected code generator. Unable to get repository signature information for source https://api.nuget.org/v3-index/repository-signatures/5.0.0/index.json"
Then I changed the package source of nuget package manager to my organizations's customized source on visual studio 2019.
After changing the source of nuget package manager, I tried again to add controllers and views but got different errors and not able to add it. Error is "There was an error running the selected code generator.Package restore failed.Rolling back package changes for projectname".
I tried cleaning nuget package cache but it didn't help me.
Please help me to fix this issue. Any help is appreciated.
You try by clearing ComponentModelCache
First close all instaces of visual studio. Delete all the files from this folder C:\Users\ (your_user_name) \AppData\Local\Microsoft\VisualStudio\16.0\ComponentModelCache.
I have website built on MVC4 in visual studio 2019 and for publish profile I usually used right click and select publish site. which is working great but i want it should be part of my csproj. As when as i build my web.sln it should create a publish folder.
Right now it is only creating bin folder having dll and dependency but it should have all folder having content and web.config and razor file.
I tried to search how I can make this as part of csproj file but could not figure it out? Please help me.
Starting to work with a web app and following the steps here to use razor pages
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/
Is there a template (either in VS or elsewhere) for adding a new razorpage (ie the cshtml and the cshtml.cs files)? As a workaround I created an MVC View page (with the .cshtml ext) and then created a .cs file and renamed it to match the naming pattern.
I'm having problems running the scaffolding as well but that is a separate issue.
You can do this in the latest version of Visual Studio 2017 just by using Add New Item and choosing Razor Page.
You can also use dotnet new. For example:
dotnet new page --name MyPage
See the documentation for dotnet new. You can always get started by just running dotnet new alone to see the available templates.
Visual Studio 2012 (and 2010, too) has a Start Page that has links and streamed videos. Is it possible for my package to provide content on this page, e.g., create a separate section next to Welcome/Windows 8/etc.?
I finally got a custom start page working in VS2012 - my issue was I could not install the Start Page Project Template in 2012 as the extension only installs on 2010 (which I don't have access to) and my My Documents folder is mapped to a network drive, so putting the raw XAML file in My Documents/Visual Studio 2012/Startpages didn't work as Visual Studio refused to use this "untrustworthy file".
Download the Start Page Template from here.
Rename the file to .zip and extract it.
Copy the "\Solution\CSharp\Extensibility\StartPage.zip" file to your project template folder (by default "My Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#").
Create a new project using this template.
Follow the instructions here to upgrade from 2010 to 2012 start page.
Update the project properties target framework to 4.5.
Update the project references in the Control project by removing the Microsoft.VisualStudio.Shell.10.0 reference and adding the Microsoft.VisualStudio.Shell.11.0 and Microsoft.VisualStudio.Shell.Immutable.11.0 references.
Update the namespaces references in the xaml file by replacing the existing ones with the two below.
xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.11.0"
xmlns:vsfxim="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.Immutable.11.0"
Replace the references to vsfx:VsBrushes keys to vs:EnvironmentColors keys, e.g. vsfx:VsBrushes.StartPageBackgroundKey to vs:EnvironmentColors.StartPageTabBackgroundBrushKey
In the VSIX project, make the following changes to the source.extension.vsixmanifest file (values depending on if 2010 support is desired, it is not for me):
Add an author, the default empty tag is not allowed: <Author>Ken</Author>
Change/add the visual studio support version to 11.0: <VisualStudio Version="11.0">
Change the supported runtime edition to include 4.5: <SupportedFrameworkRuntimeEdition MinVersion="4.5" MaxVersion="4.5" />
The VSIX solution should now build and spit out a VSIX file in the project bin folder. Install this and you can now choose your Start Page from the drop down list in the visual studio options.
I haven't actually developed my custom start page beyond this, but hopefully it is a helpful to people wanting to get started developing them with VS2012
EDIT: A project which includes a basic 2012 start page, custom control and can be deployed via VSIX: template
Custom Start Pages, via google:
http://msdn.microsoft.com/en-us/library/aa991992.aspx