tags:

views:

25

answers:

1

In the project file(s) I have the following

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />

Which I am not able to change.

So far my attempts at <Properties>CustomAfterMicrosoftCommonTargets=D:\Projects\OverrideCopyWebApplication.targets</Properties>

are not working.

Here's the custom .targets file I'm using:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
<ItemDefinitionGroup>
<ProjectReference Condition="'$(OverrideCopyLocalProject)'=='true'">
  <Private>False</Private>
</ProjectReference>
<Reference Condition="'$(OverrideCopyLocal)'=='true'">
  <Private>False</Private>
</Reference>
</ItemDefinitionGroup>
<Target Name="_CopyWebApplication" Condition="'$(OutDir)' != '$(OutputPath)'" >
<!-- Log tasks -->
<Message Text="Overridden Copying Web Application Project Files for $(MSBuildProjectName)" />

<!-- Create the _PublishedWebsites\app\bin folder -->
<MakeDir Directories="$(WebProjectOutputDir)\bin" />

<!-- Copy build outputs to _PublishedWebsites\app\bin folder -->
<Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(AddModules)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)" DestinationFolder="$(WebProjectOutputDir)\%(Content.SubFolder)%(Content.RecursiveDir)" SkipUnchangedFiles="true" Condition="'$(_SGenDllCreated)'=='true'" />
<Copy SourceFiles="$(IntermediateOutputPath)$(TargetName).pdb" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DebugSymbolsProduced)'=='true'" />
<Copy SourceFiles="@(DocFileItem)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DocumentationFileProduced)'=='true'" />
<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />

<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
<Message Text="Content=$(Content)" />
<!-- Copy content files recursively to _PublishedWebsites\app\ folder -->
<Copy SourceFiles="@(Content)" DestinationFolder="$(WebProjectOutputDir)\%(Content.RelativeDir)" />

<!-- Copy items that have been marked to be copied to the bin folder -->
<Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectory)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectoryAlways)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="false" />
</Target>
</Project>

I copied the existing Target directly from the file the project I'm trying to build is pointing to and just added/changed some of the messages to see if it is working. It's not calling the custom override.

How do I override this import in the project files in my build script? No changes to the project file(s) are possible. I'm using MsBuild 4.0 set to tools version 3.5, but I'd like it to be able to work with MsBuild3.5 as well.

A: 

Ok I understand better what you want to do. Unfortunately, I don't know if you can override these targets. Did you try modifying the _CopyWebApplication to check if the target is well-called at the end of the build?

Nevertheless, this thread may help you : http://stackoverflow.com/questions/1731904/can-you-prevent-msbuild-exe-from-running-build-events

Benjamin Baumann