我发现这里在计算器上其他职位与我的问题我遇到处理之外的文件,例如:还有Include Files in MSBuild that are not a part of the project 我想和大家分享,我是代码包括的MSBuild
MSBuild: Deploying files that are not included in the project能够在阅读这些帖子后创建,并寻求一些帮助,为什么它可能不工作?
详细说明什么是错误的以及我打算做什么。我正在使用Visual Studio 2012和TFS 2012.
我有一个名为CreateMyFiles.bat的批处理文件,我想要做的是执行此操作,然后将其输出的文件(它将它们输出到我的Includes/Javascript/Bundled文件夹),并将它们包含在MSBuild的部分构建中(以便将它们部署到目标IIS服务器)。
当我在本地Visual Studio中编辑我的本地.csproj,并将下面的代码添加到文件底部并重新加载时,我可以右键单击我的web项目,选择“发布”,然后选择我的本地基于文件的发布配置文件确实将我的文件部署到了正确的位置。有效!
然后我检查了我的代码到TFS,然后去了TFS上的“构建”,并排队了一个新的构建。果然,我能够看到文件输出到构建服务器上的同一目录。现在,我并不是100%确定MSBuild,但我注意到,就像当我点击本地发布时一样,它也在构建服务器上创建了一个_publishedWebsite文件夹(源代码上方的目录)。问题是,在这个发布的网站文件夹中,我手动创建的文件不存在。此外,在构建完成后转到目标Web服务器,很不幸没有我想要的文件。
所以看起来好像我要手动选择发布,下面的代码工作,但如果我用TFS排队构建,它不起作用。 MSBuild是否使用发布?这可能是它不起作用的原因吗?
这里是我放在我的.csproj文件中的代码:
<Target Name="CustomCollectFiles">
<Exec Command="CreateMyFiles.bat" /> <!-- Generate Files -->
<ItemGroup>
<!-- Create an identity called _CustomFiles, and associate it to the files I created -->
<_CustomFiles Include="Includes\JavaScript\Bundled\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Includes\JavaScript\Bundled\*%(Filename)%(Extension) </DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<!-- Hook into the pipeline responsible for gathering files and tell it to add my files -->
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
我真的卡在这,想寻求一些帮助,为什么这些文件可能不会去。我怀疑MSBuild不使用发布,这就是为什么它在本地工作(因为我选择发布)?
非常感谢您的帮助
UPDATE 试过这种按下面的评论,但此时的文件甚至没有出现(所以它似乎没有即使是现在运行的任务)。任何想法为什么?我输入了这个权利吗?
<Target Name="CustomCollectFiles">
<Exec Command="CreateMyFiles.bat" />
<!-- Generate Files -->
<ItemGroup>
<!-- Create an identity called _CustomFiles, and associate it to the files I created -->
<_CustomFiles Include="Includes\JavaScript\Bundled\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Includes\JavaScript\Bundled\*%(Filename)%(Extension) </DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<!-- Hook into the pipeline responsible for gathering files and tell it to add my files -->
<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
CustomCollectFiles;
$(PipelineCollectFilesPhaseDependsOn);
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>
更新2 当我走在上面的代码,并把它变成我的pubxml文件,然后执行实际的发布,它的工作原理,但据我所知,我们的工艺是刚刚排队构建来自TFS。当简单地排队构建时,是否可以钩入上面的代码块?或者我需要发布?
因此,当我在TFS中构建队列时,它会*执行发布?有什么办法可以运行上面的代码而不必发布? – NullHypothesis 2014-10-07 13:52:49
除非您使用上面显示的MSBuild参数告诉它,否则不发布。你可以做类似的事情,但你上面的代码是针对发布我假设由于“FilesForPackagingFromProject”在代码 – 2014-10-07 14:14:35
谢谢所以我认为正在发生的是,当我排队时,我看到文件被推送到发布目标仅仅是因为ms构建活动,对吧?在出版方面是否有任何伤害? – NullHypothesis 2014-10-07 14:20:51