首页 > 解决方案 > 使用 msbuild 和 TeamCity 构建 nuget .Net Framework Web 应用程序包?

问题描述

使用 TeamCity 创建 Web 应用程序 nuget 包的方法是什么?

.NET 成为一件事后,我完全糊涂了。我正在尝试做的是创建一个包含 .Net Framework 4.8 Web 应用程序的 nuget 包。

以前的工作方式似乎已经过时或不推荐使用。在 TeamCity 中,以前使用的元运行器要么已弃用,要么运行不佳。

当我在谷歌上搜索 f.ex。msbuild https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package-msbuild 我得到了关于 .Net Core 和 .Net Standard 的东西,没有关于 .Net Framework 的东西。而且这些东西通常已经使用了 10 年或更长时间。

了解 nuget 在 .NET 中的工作方式后,我可能会变得愚蠢,因为一切都与项目相关联,您实际上可以避免将代码(cs 文件)与 Web 应用程序一起发送。

标签: msbuildnugetteamcity.net-framework-4.8

解决方案


到目前为止,我得到的最接近的方法是制作一个全面的 .nuspec 文件,然后在使用所有必要的依赖项构建项目后在 Web 应用程序的项目目录中运行。

但是,构建输出将记录警告:

    WARNING: NU5100: The assembly 'bin\Antlr3.Runtime.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.

nuget 包命令

nuget pack <path to nuspec file> 

nuspec 文件:

<?xml version="1.0" encoding="utf-8"?>
<package>
    <metadata>
        <id>MyPackageId</id>
        <version>1.0.0.0</version>
        <title>My application title</title>
        <authors>my authors</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Some description</description>
        <releaseNotes>Summary of changes made in this release of the package. 
        </releaseNotes>
        <copyright>My copyright</copyright>
        <tags>framework application</tags>
     </metadata>
     <files>
        <file src="bin\**\*.*" target="bin"/>
        <file src="Content\**\*.*" target="Content"/>
        <file src="Resources\**\*.*" target="Resources" exclude="**\*.cs"/>
        <file src="Scripts\**\*.*" target="Scripts" />
        <file src="Views\**\*.*" target="Views" />
        <file src ="favicon.ico"  target=""/>
        <file src ="Global.asax"  target=""/>
        <file src ="Log4Net.config"  target=""/>
        <file src ="StrongNameKeyFile.snk"  target=""/>
        <file src ="Web.config"  target=""/>
        </files>
 </package>

比较全面...


推荐阅读