Msbuild 如何从调用项目目标导入的生成脚本重写项目目标导入?

Msbuild 如何从调用项目目标导入的生成脚本重写项目目标导入?,msbuild,Msbuild,在项目文件中,我有以下内容 这是我无法改变的 到目前为止,我试图 CustomAfterMicrosoftCommonTargets=D:\Projects\OverrideCopyWebApplication.targets 你不工作了 以下是我正在使用的自定义.targets文件: <?xml version="1.0" encoding="utf-8" ?> <Project xmlns="http://schemas.microsoft.com/developer/m

在项目文件中,我有以下内容

这是我无法改变的

到目前为止,我试图
CustomAfterMicrosoftCommonTargets=D:\Projects\OverrideCopyWebApplication.targets

你不工作了

以下是我正在使用的自定义.targets文件:

<?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>

假的
假的
我直接从我试图构建的项目所指向的文件中复制了现有目标,并添加/更改了一些消息,以查看它是否正常工作。它没有调用自定义覆盖


如何在生成脚本的项目文件中覆盖此导入?无法更改项目文件。我正在将MsBuild 4.0设置为工具版本3.5,但我希望它也能够与MsBuild 3.5一起使用

好的,我更了解你想做什么。不幸的是,我不知道你是否能超越这些目标。您是否尝试修改_CopyWebApplication以检查在生成结束时是否正确调用了目标


不过,此线程可能会帮助您:

我不明白:您试图将引用的属性代码放在哪里?如何开始构建?您对原始项目文件做了什么?property元素位于调用项目文件的生成脚本的msbuild任务中。我通过cc.net开始构建。它调用用于获取所有项目文件的自定义生成脚本,并调用包含此属性元素的msbuildtask。