[英]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.