发布未包含在Web项目中的额外dll文件 [英] Publish extra dll files not included in the web project

查看:216
本文介绍了发布未包含在Web项目中的额外dll文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标:添加来自其他项目的dll并将这些文件发布到bin文件夹中。

My goal : add dlls coming from other projects and publish the web app with those files in the bin folder.

所以我试着发布不包括的额外dll文件在我的主要web项目。我需要这样做,因为几个类库项目没有引用。这些项目有后期构建事件,复制自己的dll在主要的web项目文件夹(我读它们与DI感谢Autofac)。在本地,如果我发布所有的文件夹,但是当我想发布主要的web项目,额外的dll是不是有效。

So I try to publish extra dll files not included in my main web project. I need to do this because several class library projects are not referenced. Those projects have post-build events that copy their own dlls in the main web project folder (I read them with DI thanks to Autofac). Locally it works well if I publish all the folders, but when I want to publish the main web project, the extra dlls are not there.

我需要使用它与TeamCity因为我想在每次提交时自动发布。这部分工作,唯一的问题是额外的dll文件没有发布。

And I need to use it with TeamCity cause I want to publish automatically at every commit. This part works, the only problem is that the extra dll files are not published.

一些有趣的链接:

  • http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx
  • http://cgeers.com/2011/06/04/using-a-msbuild-script-in-teamcity/
  • http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html

我试图:


  • 创建MSBuild文件以动态插入DLL>失败

  • 添加pre / post构建/发布事件>失败,类库项目编译后的主要项目

  • 更改构建顺序>失败的原因取决于依赖项(我希望主项目忽略所有其他项目)

我现在可以尝试什么?非常感谢任何帮助。

What could I try now? Any help would be greatly appreciated.

UPDATE

文件(位于: http:/ /blog.samstephens.co.nz/2010-10-18/msbuild-including-extra-files-multiple-builds/ ),这里是我的构建文件。我在TeamCity中启动BuildAll目标。

I tried to add custom files (found here: http://blog.samstephens.co.nz/2010-10-18/msbuild-including-extra-files-multiple-builds/), here is my build file. I launch the BuildAll target in TeamCity.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WorkingFolder>$(MSBuildProjectDirectory)</WorkingFolder>
        <SolutionFile>..\Project.sln</SolutionFile>
        <TargetFolder>..\Project.MvcApp\bin</TargetFolder>
        <Configuration>Release</Configuration>
    </PropertyGroup>
    <Target Name="BuildAll" DependsOnTargets="Compile">
        <Message Text="=== BuildAll: $(Configuration) configuration ===" />
    </Target>
    <Target Name="Compile">
        <Message Text="=== Compile: $(Configuration) configuration, $(WorkingFolder) working folder ===" />
        <MSBuild Projects="$(SolutionFile)" Properties="Configuration=$(Configuration)" />
    </Target>
    <Target Name="DefineCustomFiles">
        <ItemGroup>
            <CustomFilesToInclude Include="..\Project.Login\bin\Project.Login.dll" />
            <CustomFilesToInclude Include="..\Project.Login\bin\$(Configuration)\Project.Login.dll" />
        </ItemGroup>
    </Target>
    <Target Name="CustomCollectFiles">
        <ItemGroup>
            <FilesForPackagingFromProject Include="@(CustomFilesToInclude)">
                <DestinationRelativePath>$(TargetFolder)\%(Filename)%(Extension)</DestinationRelativePath>
            </FilesForPackagingFromProject>
        </ItemGroup>
    </Target>
    <PropertyGroup>
        <CopyAllFilesToSingleFolderForPackageDependsOn>
            DefineCustomFiles;
            CustomCollectFiles;
            $(CopyAllFilesToSingleFolderForPackageDependsOn);
        </CopyAllFilesToSingleFolderForPackageDependsOn>
    </PropertyGroup>
</Project>

Project.MvcApp是主要的MVC应用程序,Project.sln是全局解决方案文件和Project.Login该项目我想要的dll插入在出版物。

Project.MvcApp is the main MVC application, Project.sln is the global solution file and Project.Login the project I want the dll to be inserted in the publication.

我在这里做错了什么? :(

What am I doing wrong here? :(

UPDATE

解决方案是将自定义目标插入您的.csproj文件的末尾。这是另一个关注此问题的线程: DefineCustomFiles和CustomCollectFiles不会被TeamCity触发

The solution is to insert the custom targets at the end of your .csproj file. Here is another thread focused on the problem: DefineCustomFiles and CustomCollectFiles are not fired by TeamCity

推荐答案

如果添加dll(而不是项目)我想这些是你的选择:

If you add the dlls (instead of the projects) as references, and set them to copy always, you should get what you want. How to get the dlls where you want them is another question. I think these are your options:

在我目前的项目中,我们使用了一个组合第一和第三个解决方案对我们工作良好,因为依赖dll不会经常变化。 BTW,我们不直接使用msbuild进行发布,我们使用带/ publish的devenv命令行。

In my current project we use a combination of the first and third solution which works fine for us since the dependent dlls don't change very often. BTW, we don't use msbuild directly for publishing, we use the devenv command line with /publish.

希望这有助于!

这篇关于发布未包含在Web项目中的额外dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆