2012-08-31 65 views
28

在MVC4,如果我創建了一個解決方案,我獨自建立網絡的.csproj時,遇到下列所有項目一個新的生成配置:「的OutputPath屬性未設置項目」時OutputPath設置

msbuild Company.Directory.Web.csproj /p:Configuration=Dev 

[Error] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483, 9): The OutputPath property is not set for project 'Company.Directory.Web.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Dev' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.

但是,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> 
    <!-- ... --> 

這是一個錯誤?我該如何解決它?

回答

43

事實證明,第一個PropertyGroup是重要的。由於某種原因,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> 
    <!-- ... --> 
+2

+1 3小時努力達夫解決方案,並一鼓作氣這一個擊中當場,乾杯! Paul –

+0

很高興能幫到你! – jrummell

+0

呵呵!! ...這節省了很多的時間和無奈..謝謝 – surya

5

我試圖從命令行使用msbuild.exe構建時出現了類似的錯誤。我的問題是,我應該把'AnyCPU'放在'任何CPU'上。

2

我和Azure項目有類似的問題。之後,我添加了新的配置Release-CLOUD-STAGE到溶液中,我開始收到同樣的錯誤:

The OutputPath property is not set for project

我打開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運行良好,但新的沒有。原來,有PropertyGroup元素在項目文件 - 一個 - 完成 - 在項目文件的開始:

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

,然後由於某種原因,還有另外一個,短版我上面顯示,插入靠近文件的末尾。在爲新的Release-CLOUD-STAGE配置創建了PropertyGroup元素的適當COMPLETE版本(並刪除了兩個SHORT版本)之後,一切都得到了遵守。

我不確定這是否是Azure特有的,但我確實浪費了一些時間,所以我想分享我的發現。

0

我有兩個PropertyGroup元素沒有條件,我認爲後者是阻止前者生效。我把所有的子項都整合到第一個PropertyGroup元素中,並且擺脫了第二個元素,並且之後開始工作。

0

我得到了Azure WebRole項目的相同錯誤,並手動將<PropertyGroup>元素添加到.csproj文件中。然而,我不小心把它們放在幾個<Import>聲明之下。構建將失敗,並在問題中出現錯誤。

正確的順序

<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>