简体   繁体   English

自定义 Visual Studio 解决方案

[英]Custom Visual Studio solution

I'm using these tools and technologies:我正在使用这些工具和技术:

  • Visual Studio 2019 CE Visual Studio 2019 CE
  • Windows 10 Windows 10
  • SQL Server SQL服务器
  • C# and ASP.NET MVC C# 和 ASP.NET MVC

Currently I create a new Visual Studio 2019 solution.目前我创建了一个新的 Visual Studio 2019 解决方案。

  1. Add three/four nuget packages (automatically targets MVC).添加三个/四个 nuget 包(自动针对 MVC)。

  2. Change a couple of files.更改几个文件。

  3. Setup configuration files.设置配置文件。

  4. Add standard/default project images.添加标准/默认项目图像。

I now start to develop the site as required.我现在开始根据需要开发网站。

I will check-in the project into Azure DevOps at the end of the day.我将在一天结束时将项目签入 Azure DevOps。

Is there a way to do the above 4 steps by the means of a template/package that I set once so in future I can click a few buttons in Visual Studio and all 4 steps have been done for me rather than having to do each step manually?有没有办法通过我设置一次的模板/包来完成上述 4 个步骤,以便将来我可以单击 Visual Studio 中的几个按钮,并且所有 4 个步骤都已为我完成,而不必执行每个步骤手动?

Errors错误

Error 1错误 1

This project references NuGet package(s) that are missing on this computer.此项目引用此计算机上缺少的 NuGet 包。 Use NuGet Package Restore to download them.使用 NuGet Package 恢复下载它们。 For more information, see http://go.microsoft.com/fwlink/?LinkID=322105 .有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105 The missing file is..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.缺少的文件是..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props。

After attempting to Restore the packages尝试还原软件包后

Error 2错误 2

An error occurred while trying to restore packages: Unable to find version 'XXXX' of package 'AAAA' C:\Program files(x86)\Microsoft SDKs\NuGetPackages: Package 'AAAA' is not found on source C:\Program files(x86)\Microsoft SDKs\NuGetPackages.... https://api.nuget.org/v3/index.json Package 'AAAA' is not found on source https://api.nuget.org/v3/index.json An error occurred while trying to restore packages: Unable to find version 'XXXX' of package 'AAAA' C:\Program files(x86)\Microsoft SDKs\NuGetPackages: Package 'AAAA' is not found on source C:\Program files( x86)\Microsoft SDKs\NuGetPackages.... https://api.nuget.org/v3/index.json Package 'AAAA' is not found on source https://api.nuget.org/v3/index.json

There is something called a multi-project template .有一种叫做多项目模板的东西。 That same page has a specific section on creating a multi-project template from an existing solution :同一页面有一个关于从现有解决方案创建多项目模板的特定部分:

  1. Create a solution and add two or more projects.创建一个解决方案并添加两个或更多项目。

  2. Customize the projects until they are ready to be exported to a template.自定义项目,直到它们准备好导出到模板。

  3. On the Project menu, choose Export Template.在项目菜单上,选择导出模板。

  4. The Export Template Wizard opens.导出模板向导打开。

  5. On the Choose Template Type page, select Project Template.在选择模板类型页面上,select 项目模板。 Select one of the projects that you want to export to a template, and then choose Next. Select 要导出到模板的项目之一,然后选择下一步。 (You'll repeat these steps for each project in the solution.) (您将为解决方案中的每个项目重复这些步骤。)

  6. On the Select Template Options page, enter a name and optional description, icon, and preview image for your template.在 Select 模板选项页面上,输入模板的名称和可选描述、图标和预览图像。 Choose Finish.选择完成。

  7. The project is exported into a.zip file and placed in the specified output location.工程导出为.zip文件,放置在指定的output位置。

  8. Create a directory for your template, with a subdirectory for each project.为您的模板创建一个目录,每个项目都有一个子目录。

  9. Extract the contents of each project's.zip file into the corresponding subdirectory that you created.将每个项目的 .zip 文件的内容提取到您创建的相应子目录中。

  10. In the base directory, create an XML file with a.vstemplate file extension.在基本目录中,创建一个带有 .vstemplate 文件扩展名的 XML 文件。 This file contains the metadata for the multi-project template.此文件包含多项目模板的元数据。 See the example that follows for the structure of the file.有关文件结构,请参见下面的示例。 Be sure to specify the relative path to each project's vstemplate file.请务必指定每个项目的 vstemplate 文件的相对路径。

  11. Select all the files in the base directory, and from the right-click or context menu, choose Send to > Compressed (zipped) folder. Select 基本目录中的所有文件,并从右键单击或上下文菜单中选择发送到 > 压缩(压缩)文件夹。 The files and folders are compressed into a.zip file.文件和文件夹被压缩成 .zip 文件。

  12. Copy the.zip file into the user project template directory.将.zip文件复制到用户工程模板目录下。 By default, this directory is %USERPROFILE%\Documents\Visual Studio \Templates\ProjectTemplates.默认情况下,此目录为 %USERPROFILE%\Documents\Visual Studio\Templates\ProjectTemplates。

  13. In Visual Studio, choose File > New > Project and verify that your template appears.在 Visual Studio 中,选择“文件”>“新建”>“项目”并验证您的模板是否出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM