2013-07-08 29 views
0

我正在研究msuild並試圖通過msbuild scripts.i實現web.config轉換添加了額外的web.staging.config和web.production.config.when我試圖TW/p:使用命令行一樣 的MSBuild tweb.xml /噸運行目標配置=分期;平臺= AnyCPU無法使用msbuild webconfig轉換設置配置和平臺

越來越下面error.pls幫助我,我在做什麼錯誤???

"E:\tweb.xml" (tw target) (1) -> 
(_CheckForInvalidConfigurationAndPlatform target) -> 
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9) 
: error : The OutputPath property is not set for project 'tweb.xml'. Please ch 
eck to make sure that you have specified a valid combination of Configuration a 
nd Platform for this project. Configuration='staging' 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. [E:\tweb.xml] 

0 Warning(s) 
1 Error(s) 

下面是我的代碼

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/> 

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'staging|AnyCPU'"> 
    <WebConfigReplacement>staging</WebConfigReplacement> 
    </PropertyGroup> 
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'production|AnyCPU'"> 
    <WebConfigReplacement>production</WebConfigReplacement> 
    </PropertyGroup> 





    <PropertyGroup> 
    <TransformInputFile>D:\webTransdemo\deploye\Web.Temp.config</TransformInputFile> 
    <TransformFile>D:\webTransdemo\WebTransform\WebTransform\Web.$(WebConfigReplacement).config</TransformFile> 
    <TransformOutputFile>D:\webTransdemo\WebTransform\WebTransform\Web.config</TransformOutputFile> 
    <StackTraceEnabled>False</StackTraceEnabled> 
    </PropertyGroup> 

    <ItemGroup> 
    <OriginalWebConfig Include="D:\webTransdemo\WebTransform\WebTransform\Web.config"/> 
    <TempWebConfig Include="D:\webTransdemo\deploye\Web.Temp.config"/> 
    </ItemGroup> 


    <Target Name="tw" Condition="'$(Configuration)|$(Platform)' == 'Production|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Staging|AnyCPU'"> 

    <Copy SourceFiles="@(OriginalWebConfig)" DestinationFiles="@(TempWebConfig)" /> 

    <TransformXml    Source="$(TransformInputFile)" 
           Destination="$(TransformOutputFile)" 
           Transform="$(TransformFile)" 
           StackTrace="$(StackTraceEnabled)" /> 
    <Delete Files="@(TempWebConfig)"/> 


    </Target> 

回答

0

您需要設置OutputPath屬性。

<OutputPath>bin\</OutputPath> 

另外,你的目標將不會被執行,因爲配置不符合您所傳遞的參數確保外殼的比賽 -

<Target Name="tw" Condition="'$(Configuration)|$(Platform)' == 'production|AnyCPU' Or '$(Configuration)|$(Platform)' == 'staging|AnyCPU'"> 
相關問題