How to force Team Build 2010 to publish web applications as not updated?

I am trying to switch our build with CruiseControl.NET, which runs its own .msbuild file in Team Build 2010. The compiled application is a VS2008 solution with many projects, two of which are web projects.

Using DefaultTemplate.xaml, it seems that two web projects are deployed to Binaries\_PublishedWebsites\(ProjectName) . This default location is beautiful. However, the contents of the output directories appear to be updatable, as if aspnet_compiler.exe was called with -u , or as if the MSBuild <AspNetCompiler> task <AspNetCompiler> used with Updateable="true" . So, two questions:

  • How to create a Team Build for output without updating to the _PublishedWebsites directory?
  • How can I configure IIS VirtualPath as if I were doing the following in an MSBuild task:

     <AspNetCompiler Clean="true" Force="true" VirtualPath="/My-IIS-Virtual-Path" /> 

I discovered in earlier troubleshooting that the only way to get IIS 6 to service the web service compiled with aspnet_compiler.exe in non-updatable mode is to specify a virtual path in the command, so I ask about # 2.

Edit:

Having seen one answer so far, I realized that I should have more clearly talked about the problem. I understand that if I can do something in MSBuild, I can just call MSBuild from the build template. However, I am interested in learning how to change what happens to copy the output to the _PublishedWebsites directory. โ€œFinding a task that copies the website and modifying itโ€ will work fine, except that I donโ€™t see what it is actually copying the output to _PublishedWebsites . I really want to change the step in the template that will do this.

The build log refers to a compilation object called _CopyWebApplication , which appears to do the job of copying the files needed for the web application. However, Iโ€™m not sure how to change this compilation goal, since I donโ€™t see it anywhere in the build template and not in any file in the solution. Also, everything that runs _CopyWebApplication seems to work only for web application projects, and not for many other projects in the solution. This is good, except that I do not know where the logic exists that determines whether _CopyWebApplication should be used.

Maybe there is a default MSBuild file that I am missing? What build option can I use? How to change the above assembly step?

+4
source share
3 answers

K. Moraz pointed me in the right direction, and I had to do a few more things to make it work. I really did not want to edit the embedded .targets files, as this would create a queue maintenance problem for any other developer who did not know what I did. I finished editing the .csproj files for two web applications, starting with the default <Import> element at the end of the file and ending with the default <ProjectExtensions> element:

  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- Since this Import serves no real purpose in VS2008 under Team Build, I'm commenting it out to remove a _CopyWebApplication step that we don't want. <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" /> --> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <!-- Now, for Team Build, do the AspNetCompile steps ourselves. --> <PropertyGroup> <WebProjectOutputDir Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)_CompiledWebsites\$(MSBuildProjectName)</WebProjectOutputDir> </PropertyGroup> <PropertyGroup> <BuildDependsOn> $(BuildDependsOn); DoAspNetCompile </BuildDependsOn> </PropertyGroup> <Target Name="DoAspNetCompile" Condition="'$(CompileWebsites)' == 'True' And '$(OutDir)' != '$(OutputPath)'"> <Message Text="Performing AspNetCompile step for $(MSBuildProjectName)" /> <Message Text="Output will have IIS virtual directory '$(IISVirtualPath)'" /> <Message Text="ProjectDir is $(ProjectDir)" /> <Message Text="IsDebug is $(IsDebug)" /> <RemoveDir Directories="$(WebProjectOutputDir)" ContinueOnError="true" /> <MakeDir Directories="$(WebProjectOutputDir)" /> <!-- We need the /bin directory, populated with some DLLs and PDBs --> <CreateItem Include="$(OutDir)*.dll;$(OutDir)*.pdb"> <Output TaskParameter="Include" ItemName="BinariesToCopy" /> </CreateItem> <Copy DestinationFolder="$(ProjectDir)\bin" SourceFiles="@(BinariesToCopy)" /> <AspNetCompiler Clean="True" Force="True" Debug="$(IsDebug)" Updateable="False" VirtualPath="$(IISVirtualPath)" PhysicalPath="$(ProjectDir)" TargetPath="$(WebProjectOutputDir)" /> </Target> 

Some explanations:

  • It speaks directly in the .csproj file, as you can see that C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets used by default. I did not realize earlier that MSBuild knew what to use this .targets file. Since the only way not to use the _CopyWebApplication target target file under VS2008 is not to use this file, and since the VS2010 version really didn't help me either, I just commented on the import.
  • To distinguish my output from the default, I changed the name of the output directory to _CompiledWebsites instead of _PublishedWebsites .
  • I added the <BuildDependsOn> element so that any other project files along the way that changed the extension points would not disable my target.
  • I require CompileWebsites be set to true (using something like the /p:CompileWebsites=true passed to MSBuild, although there are other ways to do this in Team Build if necessary). Thus, the local assembly is not changed by default.
  • The <Message> elements are for debugging purposes. I set $(IsDebug) to True or False in the configurations at the top of the file. We have many configurations besides the vanilla "Debug" and "Release", so this flag was necessary so that I could tell AspNetCompiler whether to include debugging symbols. $(IISVirtualPath) also specified in the configurations at the top of the file. This is necessary so that IIS 6 maintains the web service designed in this way.
  • AspNetCompiler cannot find the precompiled binaries where Team Build will place them by default, so I will copy them to the bin\ directory of the project, where AspNetCompiler waiting for them to be searched.
  • I didn't have to do anything with the .xaml template in Team Build to get this to work. I had to make sure that the assembly definition included the /p:CompileWebsites=true . To accomplish this, right-click the build definition in the Team Explorer window (under the "Builds in team" section), click "Process", expand the entry "3. Advanced" and type /p:CompileWebsites=true for the line labeled "MSBuild Arguments ".

If I had more than two projects that needed this build configuration, I would probably create a file with the DoAspNetCompile target and import this file.

+4
source

All logic of the _CopyWebApplication target _CopyWebApplication defined in:

 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets 

The goal itself is pretty simple, but it contains a bunch of prerequisites:

 <Target Name="_CopyWebApplication" Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'" DependsOnTargets="$(_CopyWebApplicationDependsOn)"> <CallTarget Condition="'$(OnAfter_CopyWebApplication)' != ''" Targets="$(OnAfter_CopyWebApplication)" RunEachTargetSeparately="true" /> </Target> 

You can control the process after receiving the desired set of flags. The following are the default values:

 <WebProjectOutputDirInsideProjectDefault>True</WebProjectOutputDirInsideProjectDefault> <WebProjectOutputDirInsideProjectDefault Condition="('$(OutDir)' != '$(OutputPath)') Or ('$(IsDesktopBuild)' == 'False')" >False</WebProjectOutputDirInsideProjectDefault> <DisableLinkInCopyWebApplicaton Condition="'$(DisableLinkInCopyWebApplicaton)'==''">False</DisableLinkInCopyWebApplicaton> <Disable_CopyWebApplication Condition="'$(Disable_CopyWebApplication)' == ''">False</Disable_CopyWebApplication> <UseWPP_CopyWebApplication Condition="'$(UseWPP_CopyWebApplication)' == ''">False</UseWPP_CopyWebApplication> <CleanWebProjectOutputDir>True</CleanWebProjectOutputDir> <CleanWebProjectOutputDir Condition="$(WebProjectOutputDirInsideProject)" >False</CleanWebProjectOutputDir> 
+4
source

DefaultTemplate.xaml in TFS 2010 Build still uses MSBuild to create your projects, so if the two things you list can be done using MSBuild.exe, they can be done with the 2010 build process. All you have to do is add the MSBuild arguments to the parameters of the process to determine your assembly. More information on updating the build definition can be found on MSDN .

+2
source

Source: https://habr.com/ru/post/1398105/


All Articles