您当前的位置: 首页 > 

Linux小百科

暂无认证

  • 0浏览

    0关注

    1185博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

nuget打包文件丢失如何使用powershell脚本解决

Linux小百科 发布时间:2021-05-12 11:05:27 ,浏览量:0

本文介绍的是在使用nuget打包的过程中遇到丢失文件的问题的时候使用powershell脚本实现的解决办法,非常的巧妙

对于进行nuget打包时,有时我们需要添加一个配置文件,就是一些文本文件,而这些文件我们在网站发布时需要同时复制到输出目录,否则会出现文件丢失的问题,我们在打包时通过添加powershell脚本来解决它。

一般添加powershell包之后,包的格式如下nuget打包文件丢失如何使用powershell脚本解决nuget打包文件丢失如何使用powershell脚本解决

添加-〉工具-〉install.ps1脚本

param($installPath, $toolsPath, $package, $project)
$configItem = $project.ProjectItems.Item("log4.config")
 
# set 'Copy To Output Directory' to 'Copy if newer'
$copyToOutput = $configItem.Properties.Item("CopyToOutputDirectory")
$copyToOutput.Value = 1
 
# set 'Build Action' to 'Content'
$buildAction = $configItem.Properties.Item("BuildAction")
$buildAction.Value = 2

当我们在项目里添加nuget包时,查看输出窗口,可以看到我们的ps1脚本被自动执行了,它修改了log4.config的文件属性,它让具有“始终复制”到输出目录的属性!nuget打包文件丢失如何使用powershell脚本解决nuget打包文件丢失如何使用powershell脚本解决

现在我们在建立nuget包时,如果希望进行一些初始化的功能,就可以使用这种方式了!

关注
打赏
1665632672
查看更多评论
立即登录/注册

微信扫码登录

0.0379s