Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, October 23, 2018 4:57 PM
With .NET core one can easily create a new project with 'dotnet new classlib'. How can I achieve the same for a .NET Framework 4.5 class library project? I looked at some of the tools at https://docs.microsoft.com/en-us/dotnet/framework/tools/ but none of them seem to offer an option to create a project (sln + csproj) from the command line.
As background information, I will have a bunch of projects each one using the same basic code where the final code needs to be inserted. Each of these projects also depends on another project. So I want to just call a batch file that take the new project name as an argument, then creates the project (csproj), adds a .cs template and adds the dependency on that other project.
All replies (3)
Wednesday, October 24, 2018 2:22 AM ✅Answered
Hi hulamula,
Welcome to the MSDN forum.
Now, we cannot use the dotnet new command to create a .NET Framework project. For the detail description, please have a look at this similar issue: Using dotnet new for targeting .NET Framework
For your current situation, maybe you can check this: How to: Create project templates. We can create a new project and use the basic code, add reference to another project and some others, then go to Project-Export Template and export this current project as the template, it will default auto add into VS. Go to File-New-Project, you will find this custom project template and choose it, then insert your final code and others.
Best regards,
Sara
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]
Wednesday, October 24, 2018 5:00 AM
Perhaps you can also imply “T4 Text Templates” into project generation:
· /en-us/visualstudio/modeling/code-generation-and-t4-text-templates?view=vs-2017
Thursday, October 25, 2018 4:03 PM
Thank you for the feedback. I didn't know about the project templates but decided to take that approach. With some digging around I ended up following the instructions at the following like. It explains how to create a template project ("MyTemplateProj") and then a VSIX project ("MyVSIXProj") to distribute the template.
/en-us/visualstudio/extensibility/how-to-use-wizards-with-project-templates?view=vs-2017
I followed these exact steps and run MyVSIXProj in debug mode. When I did go to the VS that started up as part of the debugging session I did see the template. When I ran another debugging session it stopped appearing and I just can't get it back. When I go to the menu Tools->Extensions and Updates I do see MyVSIXProj in there (shouldn't it be MyTemplateProj?) but when I go to File->New->Project I don't see it anywhere under Visual C#. I do see a directory MyVSIXProj in C:\Users\user]\AppData\Local\Microsoft\VisualStudio\15.0_821de0edExp\Extensions\MyName]. If I drill down to the subdirectory [version] I see a vsixmanifest file along with two json files and the subdirectory ProjectTemplates. That directory has subdirectories CSharp/1033/MyTemplateProj with a vstemplate file (and an .ico and .cs file).
So why does my template not show up when creating new projects? Also the path above has that _821de0edExp. Is it because it's a debugging session? If so, why does it not disappear after I am done debugging? Could that be the source of the problem.