nuspec contentFiles未添加到项目 [英] nuspec contentFiles not added to a project

查看:124
本文介绍了nuspec contentFiles未添加到项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web项目(mvc5),其中包含 project.json .

I have a web project (mvc5) with a project.json inside.

我也有一个nuget包.在此软件包中(除了dll参考文件之外),我还有一些内容文件(cshtml文件,css,javascript等).

Also, I have a nuget package. Inside this package (besides the dll reference) I have some Content files (cshtml files, css, javascript etc).

要实现2个目标:

  • 将软件包安装到项目中之后,我想将内容文件包含到项目中.
  • 构建项目后,我希望nuget还原内容文件

nuspec文件:

<?xml version="1.0"?>
    <package>
      <metadata>
        /.../

        <dependencies>
            <group targetFramework="net461">
              /.../

           </group>
        </dependencies>
          <contentFiles>
        <files include="**/*.*" flatten="false" copyToOutput="false" buildAction="Content" /> 
      </contentFiles>
      </metadata>
      <files>
         /.../
    <file src="..\src\Content\**\*.*" target="contentFiles\any\any\Content" /> 
    <file src="..\src\Views\**\*.*" target="contentFiles\any\any\Views" /> 
      </files>
    </package>

好吧,Visual Studio正在添加nuget包,没有任何问题.该参考文献也包括在内.但是内容总是不见了.内容文件不是从/packages/文件夹复制的,也不包含在项目中. 构建项目时也是如此,它只是复制dll而完全不接触包中的内容文件.

Well, Visual Studio is adding nuget package with no issues. The reference is also included. But the content is always missing. The content files are not copied from the /packages/ folder and are not included to the project. The same is when I build the project - it just copies the dll and does not touch content files from the package at all.

仅当我具有copyToOutput ="true"时它才有效,但是所有内容当然都进入bin文件夹.

It only works if I have copyToOutput="true", but all content goes to bin folder, of course.

之所以需要还原内容文件,是因为nuget包中的文件被tfs忽略文件"(.tfignore)忽略.我不想让这些内容文件成为TFS中的Web项目的一部分.但是,当然,TFS生成服务器无法生成项目,因为缺少某些内容文件(软件包中的文件).因此,我希望nuget在构建服务器上还原内容文件,然后再统计构建项目的情况.

The reason why I need to restore the content files is that the files from the nuget package are ignored by a tfs 'ignore file' (.tfignore). I don't want to have these content files to be a part of the web project in TFS. However, of course, TFS build server fails to build the project, because some content files are missing (the files from the package). So I want nuget on the build server to restore the content files before it stats building the project.

有什么想法,如果可能的话,如何进行这项工作?还是这不可能,我必须将内容文件包含到项目中?

Any idea how to get this work if it is possible? Or maybe this is not possible and I must have content files to be included to the project?

推荐答案

,您可以将msbuild目标添加到包中.在此目标中,您可以执行nuget restore命令...

you could add a msbuild target to your package. in this target you can execute the nuget restore command...

示例:

<?xml version="1.0"?>
<package >
    <metadata>
    <!-- ... -->
    </metadata>
    <files>
      <!-- Include your MSBuild target to \build -->
      <file src="build\myNuGetRestoreTarget.targets" target="build" />
    </files>
</package>

请参阅: 查看全文

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