![](/img/trans.png)
[英]Possible to limit the scope of Directory.Build.Props to a single Visual Studio Solution?
[英]Why doesn't Directory.Build.props work when building a solution using Visual Studio 2017?
我有一个 Directory.Build.props 文件位于与 .sln 文件相同的目录中。
<Project>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DocumentationFile>bin\Debug\$(MSBuildProjectName).xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DocumentationFile>bin\Release\$(MSBuildProjectName).xml</DocumentationFile>
</PropertyGroup>
</Project>
当我使用 MSBuild 构建解决方案时,我能够正确生成 XML 文件。 但是,在 Visual Studio 中使用 Build -> Rebuild Solution 任务不会生成 XML 文件。
与 MSbuild 相比,Visual Studio 2017 构建和使用 Directory.Build.props 的方式有什么不同吗?
我已将 directory.build.props 添加为解决方案项。 这以某种方式阻止了 Visual Studio 在构建过程中获取并使用它。 一旦我将它作为解决方案项目删除,这工作正常。
您可能还必须删除 .vs 目录(或其中的一部分),因为它似乎也缓存在那里。
您需要检查您的项目文件是否包含文件开头的下一行
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
没有行导入'魔法'不会发生。 因此,您需要将此行插入到所有旧项目中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.