【问题标题】:Create proj file that loads csproj files into solution explorer when opened with visual studio创建 proj 文件,在使用 Visual Studio 打开时将 csproj 文件加载到解决方案资源管理器中
【发布时间】:2016-08-22 17:21:42
【问题描述】:

我正在为我们的应用程序构建一个项目文件,我将在我们的构建机器上执行该文件。我想知道我是否可以打开项目文件并在我打开解决方案文件时获得与 Visual Studio 为我提供的解决方案相同的视图。

到目前为止,这是我的 Contosa.proj 文件。

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)'=='' ">Debug</Configuration>
    <RootNamespace>Contosa</RootNamespace>
    <AssemblyName>Contosa</AssemblyName>
  </PropertyGroup>

  <ItemGroup>
    <Projects Include="C:\Users\localuser\Documents\Perforce\Contosa\Branches\Working23\UI\Desktop\ContosaClient\ContosaClient.csproj" />
  </ItemGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

  <Target Name="Build">

    <PropertyGroup>
        <Contosa>$(MSBuildProjectDirectory)\UI\Desktop\ContosaClient\ContosaClient.csproj</Contosa>
    </PropertyGroup>



    <MSBuild Projects="$(Contosa)"
                 Properties="Configuration=QA;
                             VisualStudioVersion=12.0;
                             DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\;
                             SolutionDir=$(MSBuildProjectDirectory)\"/>
  </Target>
</Project>

目前,使用 Visual Studio 作为其关联应用程序双击此文件将打开 Contosa.proj 进行文本编辑。我真的希望能够将我的 Contosa.proj 文件与 Visual Studio 相关联,就像我们的 Contosa.sln 文件一样。因此,当开发人员使用 Visual Studio 打开它时,他们会获得与您从 Contosa.sln 获得的相同视图。我不明白 csproj 或 sln 文件的哪些部分使它们在 Visual Studio 中作为项目或解决方案打开。

更新 1

我希望做这个用户Replace .sln with MSBuild and wrap contained projects into targets 所做的事情,但我希望项目文件能够像解决方案文件一样被用户打开。我希望将我包含的项目加载到解决方案资源管理器中。

【问题讨论】:

    标签: visual-studio-2013 msbuild


    【解决方案1】:

    安装 Visual Studio 时,它会将资源管理器配置为在双击 .csproj 时启动 Visual Studio (How can I set a file association from a custom file type to a program)。您的窗口和您的开发人员窗口不知道 .proj 是什么。因此,将其重命名为 .csproj 或分发引用 .proj 的 .sln

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-08
      • 2018-06-07
      • 2013-10-15
      • 1970-01-01
      • 2015-10-25
      • 2019-04-23
      • 1970-01-01
      相关资源
      最近更新 更多