【问题标题】:Folder for Release build does not get created when publishing .NET Core发布 .NET Core 时未创建发布版本的文件夹
【发布时间】:2018-09-03 09:25:42
【问题描述】:

您好,我正在使用 bash 脚本从源代码中获取 publish 文件夹并将其放入另一个应用程序的文件夹中。

问题是,当我使用dotnet publish 时,publish 文件夹仅为Debug 构建创建。
即使我的项目在Release 构建设置,dotnet 命令也会为@ 生成987654327@.我做错了什么?

Bash 脚本

releasepath="D:\Work\redius\core\redius\bin\Release\netcoreapp2.1\publish" 
destpath="D:\dotpeek"
rediuspath="D:\Work\redius"
curDir="$(pwd)\out.txt"

if  [ ! -f curDir ]; 
then  
touch  $curDir
fi

echo $releasepath
rm -rf  $destpath
mkdir $destpath
(cd $rediuspath &&  dotnet publish | $curDir && echo "done publishing")
echo "Copying from : ${releasepath} to ${destpath}"
cp -rf  releasepath destpath
cd

我需要脚本第一行的文件夹。我已经尝试使用来自vstudio 的publish,但它会创建一个nupkg 文件。

【问题讨论】:

    标签: bash .net-core publish


    【解决方案1】:

    dotnet publish 首先构建项目,然后发布它。默认使用构建配置Debug。

    如果您想使用构建配置 Release 构建项目,您必须指定 -c 标志。

    dotnet publish -c Release
    

    https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore21

    如果您需要指定额外的构建标志,您可以先构建项目然后发布它。

    dotnet build -c Release
    dotnet publish --no-build
    

    【讨论】:

      【解决方案2】:

      您必须使用dotnet build -c Release 构建项目。然后就可以在Release模式下创建dll了。

      【讨论】:

      • 但是出版公司不也应该进行构建吗?构建就像在本地具有依赖项的发布。我已经从 Visual Studio 中构建了项目。
      • 这对我有用。发布后我没有从 Release 获得构建。发布模式下的显式构建解决了我的问题。
      猜你喜欢
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多