Msbuild:错误:未为此项目设置OutputPath属性

时间:2020-10-12 09:59:40

标签: visual-studio msbuild

我目前正试图解耦一个项目,但出现以下错误

未为项目'MyProj.vcxpro j'设置OutputPath属性。 请检查以确保您指定了有效的组合 该项目的配置和平台。配置='' 平台='x64'。您可能会看到此消息,因为您重新 试图在没有解决方案文件的情况下构建项目,并且已指定 为此不存在的非默认配置或平台 项目。 [D:\ Test \ MyProj.vcxproj]

我将此添加到了项目中,但没有帮助

  <PropertyGroup Label="Globals">
    <Platform Condition="'$(Platform)' == ''">x64</Platform>
    <TargetName>MyProj</TargetName>
    <ResolveExportedSymbols>true</ResolveExportedSymbols>
    <ProjectGuid>{xxxxx-xxxx-xxxx-xxx}</ProjectGuid>
    <UsePrecompiledHeader>true</UsePrecompiledHeader>
    <OutputPath>D:\MyOutput\out\</OutputPath>
  </PropertyGroup> 

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

请使用此:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

         <ItemGroup Label="ProjectConfigurations">
            <ProjectConfiguration Include="Debug|x64">
              <Configuration>Debug</Configuration>
              <Platform Condition="'$(Platform)' == ''">x64</Platform>
            </ProjectConfiguration>
        </ItemGroup>
        
         <PropertyGroup Label="Globals">
            <TargetName>MyProj</TargetName>
            <ResolveExportedSymbols>true</ResolveExportedSymbols>
            <ProjectGuid>{xxxxx-xxxx-xxxx-xxx}</ProjectGuid>            
            <OutputPath>D:\MyOutput\out\</OutputPath>
          </PropertyGroup>
 
        <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
       <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
         <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
      </ImportGroup>


        <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
        <ClCompile>
          <PrecompiledHeader>Use</PrecompiledHeader>
          <WarningLevel>Level3</WarningLevel>
          <SDLCheck>true</SDLCheck>
          <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 
          </PreprocessorDefinitions>
          <ConformanceMode>true</ConformanceMode>
          .....
        </ClCompile>
      </ItemDefinitionGroup>

.....
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

然后,删除所有输出文件夹,例如Debug,然后重新构建。