如何在 MSBUILD 中执行任务?

发布于 2024-09-12 08:48:57 字数 1851 浏览 1 评论 0原文

我正在尝试了解 MSBuild。

到目前为止,我有一个非常简单的脚本,它执行以下操作:

构建一个解决方案并将其放置在我的放置位置。

我创建了一个 ,在其中我想从我的源代码管理位置复制文件并将它们放在放置位置。

最终脚本必须创建文件夹等。现在我只是尝试复制一个文件来看看它是如何工作的。

解决方案将构建并放置在放置位置,但不会复制任何文件。构建日志没有提及该目标曾经运行过。

我缺少什么?

 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  <Target Name="Build">
    <Message Text="Building msbuildintro" />    
  </Target>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />

  <ProjectExtensions>    
    <ProjectFileVersion>2</ProjectFileVersion>  
    <Description></Description>   
    <BuildMachine>hw-tfs-build02</BuildMachine>
  </ProjectExtensions>

  <PropertyGroup>   
    /* Properties here*/
  </PropertyGroup>

  <ItemGroup>
    <SolutionToBuild Include="$(BuildProjectFolderPath)/HostASPX/mySolution.sln">
      <Targets></Targets>
      <Properties></Properties>
    </SolutionToBuild>

    <CommonFiles Include="$(SolutionRoot)\trunk\folder\Common\Shared\js\somefile.js"></CommonFiles>
  </ItemGroup>

  <ItemGroup>    
    <ConfigurationToBuild Include="Release|Any CPU">
      <FlavorToBuild>Release</FlavorToBuild>
      <PlatformToBuild>Any CPU</PlatformToBuild>
    </ConfigurationToBuild>    
  </ItemGroup>


    <Target Name="CopyCommonData">       
      <Message Text="Copy Common Data" />      
      <Copy SourceFiles="@(CommonFiles)"
            DestinationFiles="$(DropLocation)\Common\somefile.js" /> 
    </Target>  


</Project>

谢谢!

I'm trying to wrap my head around MSBuild.

I have a very simple script that does the following so far:

Builds a solution and places it in my drop location.

I have created a <Target> and in it I would like to copy files and from my source control location and drop them in the drop location as well.

Eventually the script will have to create the folders etc. For now I am just trying to copy one file over to see how this works.

The solution builds and is placed in the drop location but no files are copied. The build log makes no mention of this Target ever being run.

What am I missing?

 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  <Target Name="Build">
    <Message Text="Building msbuildintro" />    
  </Target>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />

  <ProjectExtensions>    
    <ProjectFileVersion>2</ProjectFileVersion>  
    <Description></Description>   
    <BuildMachine>hw-tfs-build02</BuildMachine>
  </ProjectExtensions>

  <PropertyGroup>   
    /* Properties here*/
  </PropertyGroup>

  <ItemGroup>
    <SolutionToBuild Include="$(BuildProjectFolderPath)/HostASPX/mySolution.sln">
      <Targets></Targets>
      <Properties></Properties>
    </SolutionToBuild>

    <CommonFiles Include="$(SolutionRoot)\trunk\folder\Common\Shared\js\somefile.js"></CommonFiles>
  </ItemGroup>

  <ItemGroup>    
    <ConfigurationToBuild Include="Release|Any CPU">
      <FlavorToBuild>Release</FlavorToBuild>
      <PlatformToBuild>Any CPU</PlatformToBuild>
    </ConfigurationToBuild>    
  </ItemGroup>


    <Target Name="CopyCommonData">       
      <Message Text="Copy Common Data" />      
      <Copy SourceFiles="@(CommonFiles)"
            DestinationFiles="$(DropLocation)\Common\somefile.js" /> 
    </Target>  


</Project>

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Saygoodbye 2024-09-19 08:48:57

哦,我明白了..目标名称不是“编造的”。它们必须是此处找到的特定目标名称:

http://msdn.microsoft。 com/en-us/library/aa337604.aspx

OH I get it.. Target Names are not 'made up'. They must be a specific Target Name found here:

http://msdn.microsoft.com/en-us/library/aa337604.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文