2010-09-22 24 views
0

在项目文件(S)我有以下如何从调用它的构建脚本覆盖项目目标导入?

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

对此我不能够改变。

到目前为止,我尝试在 <Properties>CustomAfterMicrosoftCommonTargets=D:\Projects\OverrideCopyWebApplication.targets</Properties>

不工作。

这里的风俗.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,但我希望它能够与MsBuild3.5一起工作。

+0

我不明白:你在哪里尝试把属性代码,你引用?你如何开始构建?你对原始项目文件做了什么? – 2010-09-22 13:04:34

+0

属性元素位于调用项目文件的构建脚本的msbuild任务中。我通过cc.net开始构建。它调用我的自定义构建脚本来获取所有项目文件,并使用此属性元素调用一个msbuildtask。 – Maslow 2010-09-22 13:11:50

回答

0

好吧我明白你想要做的更好。不幸的是,我不知道你是否可以重写这些目标。您是否尝试修改_CopyWebApplication来检查目标在构建结束时是否被良好调用?

然而,这个线程可以帮助你:Can you prevent MSBuild.exe from running Build Events?