【问题标题】:Visual Studio custom project template - applicationUrl port numberVisual Studio 自定义项目模板 - applicationUrl 端口号
【发布时间】:2019-03-20 00:01:49
【问题描述】:

有没有办法为从自定义 VisualStudio 模板创建的项目的 applicationUrl 添加可用的随机端口号? 我为 .NET Core 项目创建了一个 VS 项目模板,并添加了一些占位符参数,例如“$guid1$”和“$safeprojectname$”,但找不到任何方法来替换 IISExpress 应用程序 url 的端口号。

Default port number is as

感谢任何提示和答案!

【问题讨论】:

    标签: .net-core visual-studio-2017 project-template


    【解决方案1】:

    对于 IIS Express,您可以使用 AutoAssignPort 属性。

    它来自以前的 SO 问题:Update IIS Express port in Visual Studio 2012 when creating project template

    【讨论】:

    • 很遗憾,它不起作用,因为 .NET 核心项目的 VS 模板有点不同。尝试在 下添加 但仍然无效。
    【解决方案2】:

    对于 .NET Core 项目,在使用 Project\Export Template 创建模板之前,从 Properties 文件夹中删除 launchSettings.json 文件。 Visual Studio 会自动生成launchSettings.json 文件。

    如果您手动创建项目: 只需将其从Properties 文件夹中删除,同时删除MyTemplate.vstemplate 文件中的文件引用。 保留空文件夹节点:

    <Folder Name="Properties" TargetFolderName="Properties">
            
    </Folder>
    

    这适用于 Visual Studio 2019 和 Visul Studio 2022。

    我没有在 Visual Studio 2017 中尝试过。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多