2012-08-31 18 views
28

W MVC4, jeśli utworzyć nową konfigurację zbudować dla wszystkich projektów w roztworze, pojawia się następujący przy budowie samotnie .csproj Web:„Właściwość OutputPath nie jest ustawiony dla projektu” gdy OutputPath jest ustawiony

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.

Jednak ustawiono właściwość 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> 
    <!-- ... --> 

Czy to błąd? Jak mogę to naprawić?

Odpowiedz

43

Okazuje się, że pierwszy PropertyGroup jest ważny. Visual Studio wstawił wcześniej nową konfigurację (Dev) PropertyGroup z jakiegoś powodu. Zgaduję, że to błąd. Naprawiłem to, przenosząc nową konfigurację po pozostałych.

<?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 godzin próbuje rozwiązania Duff i huk ten jeden hit miejscu, na zdrowie! Paul –

+0

Cieszę się, że mogę pomóc! – jrummell

+0

huh! ... to zaoszczędziło tyle frustracji i czasu ... dzięki – surya

5

Miałem podobny błąd podczas próby budowania z wiersza poleceń z msbuild.exe. Mój problem polegał na tym, że określałem "Any CPU", kiedy powinienem wstawić "AnyCPU".

2

Miałem podobny problem z projektem Azure. Po dodaniu nowej konfiguracji Release-CLOUD-STAGE do roztworu, zacząłem odbierać ten sam błąd:

The OutputPath property is not set for project

Po otwarciu pliku w edytorze ccproj i szukał nowej konfiguracji, widziałem to pod koniec tego:

<PropertyGroup Condition=" '$(Configuration)' == 'Release-CLOUD' "> 
    <OutputPath>bin\Release-CLOUD\</OutputPath> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)' == 'Release-CLOUD-STAGE' "> 
    <OutputPath>bin\Release-CLOUD-STAGE\</OutputPath> 
    </PropertyGroup> 

wszystko wyglądało dobrze dla mnie - istniejąca konfiguracja Release-CLOUD działała dobrze, ale nowa nie. Okazuje się, że istnieją DWA PropertyGroup elementy w tym pliku projektu - jeden - Complete - na samym początku pliku projektu:

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

a potem z jakiegoś powodu nie jest jeszcze jedna, krótka wersja pokazałem powyżej , wstawiony blisko końca pliku. Po utworzeniu odpowiedniej wersji COMPLETE elementu PropertyGroup dla nowej konfiguracji Release-CLOUD-STAGE (i usunięto obie wersje SHORT) - wszystko było zgodne.

Nie jestem pewien, czy to jest specyficzne dla platformy Azure, ale straciłem trochę czasu na ten temat, dlatego też chciałbym podzielić się swoimi spostrzeżeniami.

0

Posiadałem dwa elementy PropertyGroup bezwarunkowo, i myślę, że ten ostatni uniemożliwiał działanie pierwszego z nich. Skonsolidowałem wszystkie elementy potomne w pierwszym elemencie PropertyGroup i pozbyłem się drugiego, a rzeczy zaczęły działać po tym.

0

Ten sam błąd wystąpił w projekcie Azure WebRole i ręcznie dodałem elementy <PropertyGroup> do pliku .csproj. Jednak przypadkowo umieszczam je poniżej kilku oświadczeń <Import>. Kompilacja zakończy się niepowodzeniem z błędem w pytaniu.

odpowiedniej kolejności

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

niewłaściwej kolejności

<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> 
Powiązane problemy