【问题标题】:excluding web.config with msbuild使用 msbuild 排除 web.config
【发布时间】:2017-12-01 18:50:56
【问题描述】:

我有以下由团队城市执行的 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>

有人可以指出正确的方向吗?

【问题讨论】:

  • 顺便说一句:这不包含整个 xml 构建脚本。你能发布整个文件,而不是……后半部分吗?
  • @CJohnson 我想我发布了相关代码。休息是废话并被注释掉。可能是缺少结束标签,但我认为就是这样

标签: visual-studio-2013 msbuild teamcity


【解决方案1】:

好的,首先,构建的语法离我们很远。但是您是 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>

如果您有任何问题,请在此处发表评论,我会尽力帮助解答。

【讨论】:

  • 你在哪里删除 web.config?
  • 像 web.config 这样的文件似乎将成为 MyProj.csproj 文件中的一个“项目”。因此该文件(您尚未发布)是包含或排除 web.config 的文件。
  • 我没明白你的意思。你的意思是我写像
  • 我不知道 web.config 应该是什么,或者它应该做什么。无论如何 web.config 根本不应该在这个文件中。
猜你喜欢
  • 1970-01-01
  • 2018-04-09
  • 1970-01-01
  • 2019-04-10
  • 2015-04-02
  • 1970-01-01
  • 2023-04-04
  • 2015-07-13
  • 2011-09-15
相关资源
最近更新 更多