English 中文(简体)
如何简化微型和小型工业机械化目标?
原标题:How to simplify MSBuild-targets?
  • 时间:2012-04-17 12:31:25
  •  标签:
  • msbuild
<Target Name="ProtobufCompile"
        Inputs="@(ProtocCompile)"
        Outputs="$(IntermediateOutputPath)$([System.Text.RegularExpressions.Regex]::Replace( %(ProtocCompile.RelativeDir) , ..[/\] ,  ))%(ProtocCompile.Filename).cs">
  <PropertyGroup>
    <protooutdir>$(IntermediateOutputPath)$([System.Text.RegularExpressions.Regex]::Replace( %(ProtocCompile.RelativeDir) , ..[/\] ,  ))</protooutdir>
  </PropertyGroup>
  <Message Text="%(ProtocCompile.Filename)%(ProtocCompile.Extension)" Importance="high" />
  <MakeDir Directories="$(protooutdir)" />
  <Exec Command="$(ProtobufCompiler) --protoc_dir=${PROTOBUF_PROTOC_EXECUTABLE}/.. --proto_path=%(ProtocCompile.RootDir)%(ProtocCompile.Directory) -output_directory=$(protooutdir) %(ProtocCompile.FullPath)" />
</Target>
<!-- set Intputs and Outputs -->
<Target Name="ProtobufCSharpCompile"
        DependsOnTargets="ProtobufCompile">
  <CreateItem Include="$(IntermediateOutputPath)$([System.Text.RegularExpressions.Regex]::Replace( %(ProtocCompile.RelativeDir) , ..[/\] ,  ))%(ProtocCompile.Filename).cs">
    <Output TaskParameter="Include" ItemName="Compile"/>
  </CreateItem>
</Target>
<Target Name="ProtobufClean"
        BeforeTargets="Clean">
  <Delete Files="$(IntermediateOutputPath)$([System.Text.RegularExpressions.Regex]::Replace( %(ProtocCompile.RelativeDir) , ..[/\] ,  ))%(ProtocCompile.Filename).cs" />
</Target>

这是一份目标文件。 如何简化这一法典? • 如何减少下文描述的重复?

$(IntermediateOutputPath)$([System.Text.RegularExpressions.Regex]::Replace( %(ProtocCompile.RelativeDir) , ..[/\] ,  ))
最佳回答

既然你已经指明了具有这种价值的财产:

  <PropertyGroup>
  <protooutdir>$(IntermediateOutputPath)$([System.Text.RegularExpressions.Regex]::Replace( %(ProtocCompile.RelativeDir) , ..[/\] ,  ))</protooutdir>
  </PropertyGroup>

您只能用$(protooutdir)等代替提及该雕刻的内容:

<CreateItem Include="$(protooutdir)%(ProtocCompile.Filename).cs">

以及

<Delete Files="$(protooutdir)%(ProtocCompile.Filename).cs" />
问题回答

暂无回答




相关问题
How can I overwrite file web.config with web.other.config?

I have a msbuild script with custom logic to deploy my service to the qa server automatically. I have to overwrite the default config with a dedicated one, but when I use <Copy SourceFiles="web....

How do I use MSBuild on a C# project with no compilable code

I have a C# web app project which actually has no ASP.Net or C# in it. It s just a single html page with some Javascript, CSS, and a couple of images. I want to use MSBuild to deploy a version of ...

您能否防止MSBuild.exe经营活动?

我用文字建造一些项目,偶尔利用习俗制造事件,给建筑系统造成了很大困难。 如果有可能,我想援引MSBuild.exe。

building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

How long does my Visual Studio C# compile take?

It seems like it should be possible to configure Visual Studio to print out how long the compile takes. Perhaps somewhere in the .sln file. If the sln is compiled from the command line using ...

热门标签