向已发布的MVC API项目添加额外的文件 [英] adding extra files to published MVC API project

查看:71
本文介绍了向已发布的MVC API项目添加额外的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在发布过程中添加额外的XML文件.我有一个MVC API项目,也有另一个控制器项目(V1.0).我们正在使用自我记录帮助功能,该功能为每个项目创建.XML文件.在本地计算机上构建时,所有工作正常,但是在发布(使用向导)时,它将不包含该文件.

I am trying to add an extra XML file to a publishing process. I have a MVC API project which also has another project (V1.0) for controllers. We are using the self documenting help functionality which creates the .XML files for each project. When building on the local machine it all works but when publishing (with wizard) it will not include this file.

我一直在尝试按照此处所述更新发布配置文件(.pubxml)文件:

I have been trying to update the publish profile (.pubxml) file as described here:

http://www. asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/deploying-extra-files

但没有成功.我可以看到正在发生以下情况:

but without success. I can see the following is happening:

  • 我会做一个清洁工作,以确保没有东西掉下来.
  • 我通过向导发布
  • 我可以在apiproject \ bin \中看到所有文件,包括apiprojectv1 xml和dll文件
  • 我可以在apiproject \ obj \ x86 \ Release \ AspnetCompileMerge \ Source \ bin中看到它具有apiprojectv1 dll,但没有xml文件
  • 我可以在apiprojet \ obj \ x86 \ Release \ AspnetCompileMerge \ TempBuildDir \ bin \ li中看到与上面相同的内容
  • 我可以在apiproject \ obj \ x86 \ Release \ Package \ PackageTmp \ bin中看到与上面相同的内容
  • I do a clean to ensure nothing hanging around.
  • I publish with wizard
  • I can see in apiproject\bin\ there are all the files including the apiprojectv1 xml and dll files
  • I can see in apiproject\obj\x86\Release\AspnetCompileMerge\Source\bin it has the apiprojectv1 dll but not the xml file
  • I can see the same as above in apiprojet\obj\x86\Release\AspnetCompileMerge\TempBuildDir\bin
  • I can see the same as above in apiproject\obj\x86\Release\Package\PackageTmp\bin

我不确定为什么没有跨文件复制.这是我完整的pubxml文件:

I am not sure why the file is not being copied across. This is my full pubxml file:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize     the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit     http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0"     xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <SiteUrlToLaunchAfterPublish />
    <publishUrl>\\myserver\wwwroot\apiproject</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
  <Target Name="CustomCollectFiles">
        <ItemGroup>
          <_CustomFiles Include="..\bin\apiprojectv1.XML" />
          <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
            <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)    </DestinationRelativePath>
          </FilesForPackagingFromProject>
        </ItemGroup>
  </Target>
</Project>

编辑

我忘记了一个主要部分,将以下内容放在pubxml文件的底部:

I had forgot one major part, to put the below at the bottom of the pubxml file:

 <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>

    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>

我没有得到文件,但是现在遇到了关于找不到文件的错误(我现在可以调试).

I do not get the file, but now get an error regarding the file not being found, (which I can now debug).

推荐答案

我错过了两件事:

  1. 第二个属性组,实际上告诉它执行操作.
  2. 路径不正确,必须使用项目目录路径

现在看起来像这样并且可以工作:

Now looks like this and works:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit     http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <SiteUrlToLaunchAfterPublish />
        <publishUrl>\\myserver\wwwroot\apiproject</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>

 <Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="$(MSBuildProjectDirectory)\bin\apiprojectv1.XML" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>bin\%(RecursiveDir)%(Filename)%(Extension)    </DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>

  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>

    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>

</Project>

这篇关于向已发布的MVC API项目添加额外的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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