首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用msbuild转换设置配置和平台

无法使用msbuild转换设置配置和平台
EN

Stack Overflow用户
提问于 2013-07-08 13:10:43
回答 1查看 275关注 0票数 0

我正在研究msuild,并试图通过msbuildscripts实现web.config转换。我添加了额外的web.staging.config和web.production.config.when,我尝试使用命令行(如msBuildtweb.xml /t:tw )运行目标。

在error.pls下面帮助我,我犯了什么错误?

代码语言:javascript
复制
"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)

下面的是我的代码

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2013-07-08 14:22:01

您需要设置OutputPath属性。

代码语言:javascript
复制
<OutputPath>bin\</OutputPath>

此外,您的目标将不会被执行,因为配置不匹配您要传入的参数。确保套管匹配-

代码语言:javascript
复制
<Target Name="tw"  Condition="'$(Configuration)|$(Platform)' == 'production|AnyCPU' Or '$(Configuration)|$(Platform)' == 'staging|AnyCPU'">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17527529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档