发布.NET Core时,不会创建发布版本的文件夹

问题描述 投票:0回答:2

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

问题是,当我使用dotnet publish时,publish文件夹只为Debug构建创建。 即使我在Release构建集上的项目,dotnet命令为Debug生成。我做错了什么?

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

我需要脚本第一行的文件夹。我尝试使用publishvstudio,但它创建了一个nupkg文件。

bash .net-core publish
2个回答
1
投票

你必须使用dotnet build -c Release构建项目。然后它将能够在发布模式下创建dll。


0
投票

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
© www.soinside.com 2019 - 2024. All rights reserved.