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">
<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.

Maslow
  • 18,464
  • 20
  • 106
  • 193
  • I don't understand : Where did you try to put the Property Code you quoted? How do you start the build? What have you done to the original project file? – Benjamin Baumann Sep 22 '10 at 13:04
  • The property element is in the build script's msbuild task that calls the project file(s). I start the build via cc.net. It calls my custom build script that goes to get all the project files, and calls an msbuildtask with this property element in it. – Maslow Sep 22 '10 at 13:11

1 Answers1

0

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 : Can you prevent MSBuild.exe from running Build Events?

Community
  • 1
  • 1
Benjamin Baumann
  • 4,035
  • 2
  • 25
  • 35