【问题标题】:OutputPath property is not set for project未为项目设置 OutputPath 属性
【发布时间】:2014-01-20 09:22:37
【问题描述】:

我有一个已在 Team City 成功构建一年多的解决方案。一位开发人员将两个项目添加到解决方案中,我们立即收到以下错误:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(483, 9):未为项目“Compass.Communication.Server.Config.csproj”设置 OutputPath 属性。请检查以确保您为此项目指定了有效的配置和平台组合。配置='DEV' 平台='AnyCPU'。您可能会看到此消息,因为您正在尝试构建没有解决方案文件的项目,并且指定了该项目不存在的非默认配置或平台。

Compass.Communication.Server.Config\Compass.Communication.Server.Config.csproj 项目失败。 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(483, 9):没有为项目“Compass.Communication.Server.Processor.csproj”设置 OutputPath 属性。请检查以确保您为此项目指定了有效的配置和平台组合。配置='DEV' 平台='AnyCPU'。您可能会看到此消息,因为您正在尝试构建没有解决方案文件的项目,并且指定了该项目不存在的非默认配置或平台。

我已经尝试了所有我能找到的关于任何 CPU 与 AnyCPU 以及许多其他东西但没有成功的东西。这是第一个的项目文件:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{5FC19B70-7DB4-4D8A-B33F-748528E5A042}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Compass.Communication.Server.Config</RootNamespace>
    <AssemblyName>Compass.Communication.Server.Config</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <DocumentationFile>bin\Debug\Compass.Communication.Server.Config.XML</DocumentationFile>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="CommunicationConditionalElement.cs" />
    <Compile Include="CommunicationConditionalSection.cs" />
    <Compile Include="CommunicationConfigurationManager.cs" />
    <Compile Include="CommunicationCriterionElement.cs" />
    <Compile Include="CommunicationCriterionSection.cs" />
    <Compile Include="CommunicationElementExtensions.cs" />
    <Compile Include="CommunicationIntroductionElement.cs" />
    <Compile Include="CommunicationIntroductionSection.cs" />
    <Compile Include="CommunicationSectionElement.cs" />
    <Compile Include="CommunicationSectionSection.cs" />
    <Compile Include="CommunicationTypeElement.cs" />
    <Compile Include="CommunicationTypeSection.cs" />
    <Compile Include="GenericConfigurationElementCollection.cs" />
    <Compile Include="RefElement.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Compass.Communication.Entities\Compass.Communication.Entities.csproj">
      <Project>{25B8C709-0574-496E-BD1D-5F4DF966F258}</Project>
      <Name>Compass.Communication.Entities</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

【问题讨论】:

    标签: c# msbuild


    【解决方案1】:

    您可以在下面的项目文件中直接添加以下内容

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel> 
    </PropertyGroup>
    

    【讨论】:

      【解决方案2】:

      几周前我遇到了类似的问题,在我的情况下,问题是由于“任何 CPU”之间的空间引起的

      您需要确保“AnyCPU”不包含任何您在构建定义中使用的空间。

      问候

      【讨论】:

      • 很遗憾,这解决了很多人的问题,包括我自己。你会认为微软会正确设置默认值。
      【解决方案3】:

      您可以手动将 OutputPath 属性插入到 DLL 类库的 proj 文件中。下面是一个 sn-p/example 它的去向。

      <propertygroup condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 
      </propertygroup> 
      <codeanalysisruleset>MinimumRecommendedRules.ruleset</codeanalysisruleset>
      <errorreport>prompt</errorreport>
      <platformtarget>x64</platformtarget>
      <debugtype>full</debugtype>
      <defineconstants>DEBUG;TRACE</defineconstants>
      <outputpath>bin\x64\Debug\</outputpath>
      <debugsymbols>true</debugsymbols>
      

      您也可以按照以下步骤操作:

      1. 右键解决方案->属性
      2. 点击“配置属性”,然后点击“配置管理器”
      3. 点击类库的平台下拉列表,然后选择“new…”
      4. 在弹出的对话框中,确保新平台为x64,取消勾选“创建新的解决方案平台”,然后点击确定

      【讨论】:

      • 绝对废话,您需要将其中的大部分内容大写,并且属性组会错误地关闭,请参见下文。如果您使用编译器指令,您还需要设置正确的常量定义
      【解决方案4】:

      刚刚通过在 .csproj 文件中将“AnyCPU”手动替换为“x64”解决了类似问题:

      <Platform Condition=" '$(Platform)' == '' ">x64</Platform\>
      

      【讨论】:

        【解决方案5】:

        我也遇到了同样的错误。

        尝试删除“平台”环境变量。

        然后重新启动 VS,并构建您的解决方案...

        【讨论】:

        • 能否请您详细说明您的答案,添加更多关于您提供的解决方案的描述?
        • 进入Windows的环境变量,删除名为“Platform”的环境变量。 (Visual Studio 使用这个环境变量,它可能有一个错误的值......)
        【解决方案6】:

        这通常发生在您的项目未设置为针对活动解决方案配置构建但被该项目引用时。签入 Visual Studio 并确保您已将发布和调试解决方案配置添加到新项目中。

        【讨论】:

        • 我不确定您所说的“未设置为为活动解决方案构建的项目”是什么意思。我检查了配置管理器,并且有问题的两个项目在每个解决方案配置中都适当地出现。虽然我确实认为问题是这样的。
        猜你喜欢
        • 2012-08-26
        • 2012-02-23
        • 1970-01-01
        • 1970-01-01
        • 2019-10-26
        • 2018-04-29
        • 2014-06-10
        • 2018-06-04
        相关资源
        最近更新 更多