Asp.net mvc &引用;未为“项目”设置OutputPath属性;设置OutputPath时

Asp.net mvc &引用;未为“项目”设置OutputPath属性;设置OutputPath时,asp.net-mvc,visual-studio-2010,msbuild,asp.net-mvc-4,Asp.net Mvc,Visual Studio 2010,Msbuild,Asp.net Mvc 4,在MVC4中,如果我为解决方案中的所有项目创建一个新的构建配置,那么在单独构建web.csproj时会得到以下结果: msbuild Company.Directory.Web.csproj /p:Configuration=Dev [错误] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483, 9) :未为项目设置OutputPath属性 “Company.Directory.Web.cspro

在MVC4中,如果我为解决方案中的所有项目创建一个新的构建配置,那么在单独构建web.csproj时会得到以下结果:

msbuild Company.Directory.Web.csproj /p:Configuration=Dev
[错误] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483, 9) :未为项目设置OutputPath属性 “Company.Directory.Web.csproj”。请检查以确保您 已为指定配置和平台的有效组合 这个项目。配置='Dev'平台='AnyCPU'。你可能是 看到此消息是因为您正在尝试在没有 解决方案文件,并且已指定非默认配置或 此项目不存在的平台

但是,
OutputPath
属性已设置

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
    <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
    <DeployIisAppPath>Port 80/directory/dev</DeployIisAppPath>
  </PropertyGroup>
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{285FBF79-7933-4AF9-AAAF-25EE7734AAAA}</ProjectGuid>
    <ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Company.Directory.Web</RootNamespace>
    <AssemblyName>Company.Directory.Web</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <MvcBuildViews>false</MvcBuildViews>
    <UseIISExpress>true</UseIISExpress>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
    <RestorePackages>true</RestorePackages>
  </PropertyGroup>
  <!-- ... -->

真的
垃圾箱\
调试;痕迹
满的
任意CPU
促使
假的
假的
端口80/目录/dev
调试
任意CPU
2
{285FBF79-7933-4AF9-AAAF-25EE7734AAAA}
{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
图书馆
性质
Company.Directory.Web
Company.Directory.Web
v4.0
假的
真的
..\
真的

这是一个bug吗?如何修复它?

事实证明,第一个
属性组
很重要。由于某种原因,Visual Studio在其前面插入了新配置(Dev)
PropertyGroup
。我猜这是一只虫子。我通过在其他配置之后移动新配置来修复它

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{285FBF79-7933-4AF9-AAAF-25EE7734AAAA}</ProjectGuid>
    <ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Company.Directory.Web</RootNamespace>
    <AssemblyName>Company.Directory.Web</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <MvcBuildViews>false</MvcBuildViews>
    <UseIISExpress>true</UseIISExpress>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
    <RestorePacCompanyes>true</RestorePacCompanyes>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
    <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
    <DeployIisAppPath>Port 80/directory/dev</DeployIisAppPath>
  </PropertyGroup>
  <!-- ... -->

调试
任意CPU
2
{285FBF79-7933-4AF9-AAAF-25EE7734AAAA}
{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
图书馆
性质
Company.Directory.Web
Company.Directory.Web
v4.0
假的
真的
..\
真的
真的
满的
假的
垃圾箱\
调试;痕迹
促使
4.
pdbonly
真的
垃圾箱\
痕迹
促使
4.
真的
垃圾箱\
调试;痕迹
满的
任意CPU
促使
假的
假的
端口80/目录/dev

尝试使用msbuild.exe从命令行生成时,我遇到了类似的错误。我的问题是,当我应该放置“AnyCPU”时,我指定了“AnyCPU”。

我在
Azure
project中遇到了类似的问题。在我向解决方案中添加了新的配置
Release CLOUD STAGE
之后,我开始收到相同的错误:

未为项目设置OutputPath属性

在编辑器中打开
ccproj
文件并搜索新配置后,我在接近尾声时看到:

  <PropertyGroup Condition=" '$(Configuration)' == 'Release-CLOUD' ">
    <OutputPath>bin\Release-CLOUD\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Release-CLOUD-STAGE' ">
    <OutputPath>bin\Release-CLOUD-STAGE\</OutputPath>
  </PropertyGroup>
出于某种原因,我在上面展示了另一个简短的版本,插入到文件末尾。在我为新的
Release CLOUD STAGE
配置创建了
PropertyGroup
元素的正确完整版本(并删除了两个短版本)之后,一切都符合要求


我不确定这是否是特定于Azure的,但我确实在这方面浪费了一些时间,因此我也想分享我的发现。

我有两个PropertyGroup元素,但没有条件,我认为后者阻止了前者的生效。我将所有子项合并到第一个PropertyGroup元素中,并删除了第二个元素,然后开始工作。

我在Azure WebRole项目中遇到了相同的错误,并手动将
元素添加到.csproj文件中。然而,我不小心把它们放在了几个
语句下面。构建将失败,并出现问题中的错误

顺序正确

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
   <DebugSymbols>true</DebugSymbols>
   <OutputPath>bin\</OutputPath>
   <DefineConstants>DEBUG;TRACE</DefineConstants>
   <DebugType>full</DebugType>
   <PlatformTarget>AnyCPU</PlatformTarget>
   <ErrorReport>prompt</ErrorReport>
   <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
   <DebugSymbols>true</DebugSymbols>
   <OutputPath>bin\</OutputPath>
   <DefineConstants>DEBUG;TRACE</DefineConstants>
   <DebugType>full</DebugType>
   <PlatformTarget>AnyCPU</PlatformTarget>
   <ErrorReport>prompt</ErrorReport
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

真的
垃圾箱\
调试;痕迹
满的
任意CPU
促使
最小推荐规则集
顺序错误

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
   <DebugSymbols>true</DebugSymbols>
   <OutputPath>bin\</OutputPath>
   <DefineConstants>DEBUG;TRACE</DefineConstants>
   <DebugType>full</DebugType>
   <PlatformTarget>AnyCPU</PlatformTarget>
   <ErrorReport>prompt</ErrorReport>
   <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
   <DebugSymbols>true</DebugSymbols>
   <OutputPath>bin\</OutputPath>
   <DefineConstants>DEBUG;TRACE</DefineConstants>
   <DebugType>full</DebugType>
   <PlatformTarget>AnyCPU</PlatformTarget>
   <ErrorReport>prompt</ErrorReport
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

真的
垃圾箱\
调试;痕迹
满的
任意CPU

提示+1 3个小时尝试无用的解决方案,然后点击此处,干杯!呵呵!!。。。这节省了很多挫折和时间。。thanksPerfect-立即修复我的问题!Deffo请使用\p:Platform=“AnyCPU”而不是\p:Platform=“AnyCPU”进行尝试。这对我起作用了!我看了很久了\p:Platform=“AnyCPU”太棒了。