CI/CD ASP.NET Core Web API 使用 VSTS

CI/CD of a ASP.NET Core Web API using VSTS

我使用 Visual Studio 2017(社区版)创建了一个 ASP.NET Core Web API 应用程序。我可以使用 Visual Studio.

成功发布到 Azure 应用服务

我现在想使用 VSTS 设置 CI/CD。我使用了 Visual Studio 中的 'Configure Continuous Delivery' 选项,它在 VSTS 中创建了一个项目并创建了一个构建定义。为了避免 Nuget 恢复错误,我必须基于 VSTS 中的 'ASP.NET Core' 模板创建一个新的构建定义。解决方案现在构建并且测试是 运行 但 'Publish' 任务完成并带有警告 -

##[warning]No web project was found in the repository. Web projects are identified by the presence of either a web.config file or wwwroot folder in the directory.

'Publish Artifact' 任务有类似的警告 -

##[warning]Directory 'd:\a\a' is empty. Nothing will be added to build artifact 'drop'.

显然,构建不会产生任何工件。

我是否需要向默认 ASP.NET 核心构建模板添加任何构建任务?如何使用 VSTS 将 Web API 发布到 Azure?

如警告消息所示,您的存储库似乎没有网络项目。 因此,您应该 取消选择 .NET Core 发布任务中的 Publish Web Projects 选项,并在项目选项中指定 .csproj .

您还可以找到 发布 Web 项目选项 的提示消息,如下所示:

If true, the task will try to find the web projects in the repository and run the publish command on them. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory.

这可能对你有帮助..

根据我的情况,我也遇到了这个错误,我使用 wwwroot 文件夹来保存我的文件

project.csproj

  <ItemGroup>
    <Folder Include="wwwroot\FoodItem\" />
    <Folder Include="wwwroot\Shops\" />
  </ItemGroup>

在我进入 vsts 后,side repo 中没有 wwwroot 文件夹。正因为如此,我得到了这个错误,然后我再次推送 wwwroot 并修复了子文件夹错误