msbuild - 使用 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 应用程序一起发送。
解决方案
到目前为止,我得到的最接近的方法是制作一个全面的 .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>
比较全面...
推荐阅读
- javascript - Javascript验证只允许字符串后跟数字
- java - 无法从 Android 应用程序连接到 localhost API
- jersey - com.sun.jersey.api.container.ContainerException : ResourceConfig 实例不包含任何根资源类
- spring-ws - 使用 wss4jsecurityinterceptor 进行 spring security- 使用两个密钥配置签名和加密的安全性
- android - 如何避免 onError 停止 rxjava 中的异步流
- r - 逻辑语句中的 NA
- git - 如何将公司 Bitbucket 存储库添加到 Jira?
- assembly - 将一个字节压入堆栈(IA32)
- c# - 从 httpcontext 访问 viewcontext
- javascript - 在引导模式中显示 json 数据