什么是“服务包含"?在一个 csproj 文件中? [英] What is "Service Include" in a csproj file for?

查看:23
本文介绍了什么是“服务包含"?在一个 csproj 文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 解决方案中,我添加了一个现有项目.
之后,Visual Studio 在其他 .csproj 文件中添加了以下条目:

In a C# solution, I added a existing project.
After that, Visual Studio has added the following entry in other .csproj files:

<ItemGroup>
    <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>

这是干什么用的?
可以删除吗?

What's this for?
Can I delete it?

推荐答案

我有一个类似的案例,添加了这个:

I had a similar case, where this was added:

<ItemGroup>
  <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>

如果您创建 NUnit 测试项目,但忘记将其标记为测试项目,则此包含是 VS2013 有意生成的,如本 answer 来自微软:

This inclusion turns out to be generated on purpose by VS2013 if you create an NUnit test project, but forget to tag it as test project, as described in this answer from Microsoft:

这种行为是故意的.

为了支持第三方测试框架,如 NUnit 和 XUnit,Visual Studio 2012 在解决方案打开时加载测试资源管理器,无论它是否包含测试项目.这为所有用户的启动和解决方案打开方案增加了几秒钟的延迟,其中大多数用户不使用测试.

To support third-party test frameworks, like NUnit and XUnit, Visual Studio 2012 loaded Test Explorer on solution open, regardless of whether it contained test projects. This added seconds of delay to startup and solution open scenarios for all users, majority of whom don't use tests.

在 Visual Studio 2013 中,我们对其进行了更改,以便仅当解决方案包含一个或多个测试项目时才加载测试资源管理器包.测试项目以两种不同的方式标识.从内置单元测试项目模板之一创建的项目使用项目类型 GUID 进行标识.其他类型的项目,例如带有 XUnit 或 NUnit 测试的类库项目,在第一次测试发现期间由测试资源管理器识别并用 项标记".

In Visual Studio 2013, we changed it so that Test Explorer package is loaded only when the solution contains one or more test projects. Test projects are identified in two different ways. Projects created from one of the built-in unit test project templates are identified using project type GUIDs. Other types of projects, such as Class Library project with XUnit or NUnit tests, are identified by Test Explorer during first test discovery and "tagged" with the <Service/> item.

这篇关于什么是“服务包含"?在一个 csproj 文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆