Is there a way to include an assembly referenced using Unity when using publish website?

北慕城南 提交于 2019-12-04 12:26:54
lexx

So with some digging around I have found a solution to my problem. This soltuion only fixes the problm when building with TFS but to be honest with continuos integration I'm not bothered about publishing from VS.

My inspiration came from an answer given by Mike Hadlow

What's the best way to get TFS to output each project to its own directory?

Basically the solution is to modify the build script for web project so that it copies the missing assembly to the publish website output folder.

Here is what I did:

  1. I right clicked on my web project in the solution explorer and clicked 'Unload Project'.
  2. I then right clicked on the unloaded project and clicked 'Edit [Project Name]'
  3. Scrolling right down to the bottom of the file I found the following commented out build target:

    <Target Name="AfterBuild"> </Target>

  4. I modified this adding the command to copy the missing assembly:

    <Target Name="AfterBuild">

    <Copy SourceFiles="$(OutDir)[Missing Assembly Name]" DestinationFolder="$(OutDir)_PublishedWebsites\$(MSBuildProjectName)\bin" SkipUnchangedFiles="true" />

    </Target>

  5. Now when building the solution in TFS the missing assembly is included in the bin folder of the published website output.

This solution could be used to copy any other missing content to the published website output. As the files that you want to copy are likely to be different for each project doing it in this way is probably the best option. I am however thinking about creating a custom version of Microsoft.WebApplication.targets which copies minified CSS and script files.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!