使用msbuild排除web.config

时间:2017-12-01 18:50:57

标签: visual-studio-2013 msbuild teamcity

我在msbuild之下,由团队城市执行。我想排除web.config但不能这样做。在下面的代码中,您可以看到我添加了代码,但它不起作用。我在msbuild和teamcity中完全是新手

<property name="solution.dir" value="." />
<property name="SolutionFileName" value="MyProj.sln" />
<property name="projectfile" value="${solution.dir}\MyDir\Myproj.csproj" />
<property name="MSBuildPath" value="C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" />
<ItemGroup>
<MyProjectReferences Exclude="web.config" />
</ItemGroup>
<target name="build" depends="clean,UpdateBuildVersion,compile" />
<target name="clean" description="delete build artifacts">
  <property name="build.base" value="${solution.dir}/_deploy/" />
  <property name="dir.publish" value="${build.base}/publish" />
  <property name="dir.package" value="${build.base}/package" />
  <property name="project.fullversion" value="1.0.0.1" />

</target>
<target name="compile" description="compile">

  <exec program="${MSBuildPath}" failonerror="true">
   <arg value="${projectfile}" />
   <arg line="/p:Configuration=Release" />
   <arg line="/p:UseWPP_CopyWebApplication=True" />
   <arg line="/p:PipelineDependsOnBuild=False"/>
   <arg line="/t:Rebuild" />
   <arg line="/t:Package" />
   <arg line="/p:IncludeAppPool=true" />
   <arg line="/p:PackageLocation=${solution.dir}/../publish/package/Myproj.zip" />
  <arg line="/P:DeployIisAppPath=website/MyProj" />
  <!--<arg line="-skip:objectName=filePath,absolutePath=.*web\.config"></arg>-->

  </exec>
 </target>

有人能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:0)

好的,首先,构建的语法是关闭的。但你是msbuild的新手。所以我试图根据你给我们的内容来解释你需要什么。

所以这是你的脚本有些重新解释:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="Choose something else here too">
  <PropertyGroup>
    <SolutionDir>C:\Some\Path\Where\You\Keep\your\Solution\</SolutionDir>
    <BuildDir>C:\Some\Path\where\your\build\goes\that\is\outside\of\your\repo\</BuildDir>
  </PropertyGroup>
  <ItemGroup>
    <MyProject include="$(SolutionDir)MyDir\MyProj.csproj" >
      <Properties>Condiguration=Release;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False;IncludeAppPool=true;PackageLocation=$(SolutionDir);DeployIisAppPath=website\MyProj</Properties>
    </MyProject>
  </ItemGroup>
  <Target name="clean">
    <!-- The best thing to do is to call msbuild with the clean target. -->
    <MSBuild Projects="@(MyProject)" Targets="Clean" />
    <!-- Then delete anything else you want to -->
    <Delete Files="" />
    <!-- I like to just delete the build directory for cleaning -->
    <RemoveDir Directories="$(BuildDir)" />
  </Target>

  <Target name="updateBuildVersion">
    <!-- Do what ever you need to here. -->
  </Target>

  <Target name="Build" DependsOnTargets="clean;updateBuildVersion">
    <MSBuild Projects="@(MyProject" Targets="Build" StopOnFirstFailure="true" />
  </Target>
</Project>

如果您有疑问,请回复此处,我会尽力帮助解答。