主頁 > .NET開發 > .NET6打包部署到Windows Service

.NET6打包部署到Windows Service

2022-10-29 07:04:22 .NET開發

1.安裝Nuget包

安裝以下nuget包支持windows service

    <PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="6.0.10" />
    <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.1" />

2.設定ContentRootPath

不設定ContentRootPath會指向C盤sc.exe所在檔案夾,

var options = new WebApplicationOptions
{
    Args = args,
    ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
};

var builder = WebApplication.CreateBuilder(options);

3.啟用WIndowsService

通過以下方法即可啟用WIndowsService支持

builder.Host.UseWindowsService();

4.發布專案

右鍵專案,進行發布,發布到檔案夾

5.簡單安裝

通過以下BASH命令,實作安裝/開始/停止/洗掉windows service

安裝

set "CDir=%~dp0"
sc.exe create "MyService" start=auto binpath="%CDir%MyService.exe --environment Development"

啟動

sc.exe start "MyService"

停止

sc.exe stop "MyService"

洗掉

sc.exe delete "MyService"

 

6.安裝打包工具

安裝Inno Setup打包工具

安裝好后,進行漢語支持支持,打開Inno Setup安裝目錄,默認C:\Program Files (x86)\Inno Setup 6,

復制Default.isl,將其拷貝至C:\Program Files (x86)\Inno Setup 6\Languages檔案夾,并重命名為Chinese.isl

將以下內容覆寫到Chinese.isl

 ; *** Inno Setup version 5.5.0+ Chinese messages ***
 ;
 ; To download user-contributed translations of this file, go to:
 ;   http://www.jrsoftware.org/files/istrans/
 ;
 ; Note: When translating this text, do not add periods (.) to the end of
 ; messages that didn't have them already, because on those messages Inno
 ; Setup adds the periods automatically (appending a period would result in
 ; two periods being displayed).
 
 [LangOptions]
 ; The following three entries are very important. Be sure to read and?
 ; understand the '[LangOptions] section' topic in the help file.
 LanguageName=Chinese
 LanguageID=$0409
 LanguageCodePage=0
 ; If the language you are translating to requires special font faces or
 ; sizes, uncomment any of the following entries and change them accordingly.
 ;DialogFontName=
 ;DialogFontSize=8
 ;WelcomeFontName=Verdana
 ;WelcomeFontSize=12
 ;TitleFontName=Arial
 ;TitleFontSize=29
 ;CopyrightFontName=Arial
 ;CopyrightFontSize=8
 
 [Messages]
 
 ; *** Application titles
 SetupAppTitle=安裝
 SetupWindowTitle=安裝 - %1
 UninstallAppTitle=卸載
 UninstallAppFullTitle=%1 卸載
 
 ; *** Misc. common
 InformationTitle=安裝資訊
 ConfirmTitle=提示
 ErrorTitle=錯誤
 
 ; *** SetupLdr messages
 SetupLdrStartupMessage=現在將安裝 %1,是否繼續?
 LdrCannotCreateTemp=不能創建臨時檔案,安裝中止!
 LdrCannotExecTemp=不能在臨時目錄中解壓檔案,安裝程序中止!
 
 ; *** Startup error messages
 LastErrorMessage=%1.%n%n 錯誤 %2: %3
 SetupFileMissing=在安裝目錄中找不到檔案 %1 ,請更正該問題或者獲得一個新的檔案,
 SetupFileCorrupt=安裝檔案被占用,請獲得一個新的安裝檔案,
 SetupFileCorruptOrWrongVer=安裝檔案被占用, 或者安裝檔案的版本不對,請更正該問題或者獲得一個新檔案,
 NotOnThisPlatform=該程式不能在 %1 下運行,
 OnlyOnThisPlatform=該程式必須在 %1 下運行,
 OnlyOnTheseArchitectures=該程式只能在以下WINDOWS版本下運行:%n%n%1
 MissingWOW64APIs=該版本需要64位的安裝程式,要更正該問題,請安裝 Service Pack %1,
 WinVersionTooLowError=該軟體需要 %1 版本號 %2 或者更高,
 WinVersionTooHighError=該軟體不能在 %1 版本號 %2 或者更高版本中安裝,
 AdminPrivilegesRequired=您在安裝該程式時必須是管理員權限,
 PowerUserPrivilegesRequired=您在安裝程式是必須是管理員權限或者高權限用戶權限,
 SetupAppRunningError=安裝程式檢測到 %1 正在運行,%n%n請關閉它的所有實體,然后單擊“確認”繼續安裝,或者單擊“放棄”退出,UninstallAppRunningError=卸載程式檢測到 %1 正在運行,%n%n請關閉它的所有實體,然后單擊“確認”繼續安裝,或者單擊“放棄”退出,
 
 ; *** Misc. errors
 ErrorCreatingDir=安裝程式不能創建目錄 "%1"
 ErrorTooManyFilesInDir=不能在目錄"%1" 下創建檔案,因為該目錄下有太多的檔案了,
 
 ; *** Setup common messages
 ExitSetupTitle=退出安裝
 ExitSetupMessage=安裝沒有完成, 如果您現在退出,程式將不被安裝,%n%n您可以下次在完成安裝任務,%n%n退出安裝?
 AboutSetupMenuItem=關于安裝程式[&A]...
 AboutSetupTitle=關于安裝程式
 AboutSetupMessage=%1 版本 %2%n%3%n%n%1 主頁:%n%4
 AboutSetupNote=
 TranslatorNote=
 
 ; *** Buttons
 ButtonBack=< 回退[&B]
 ButtonNext=下一步[&N] >
 ButtonInstall=安裝[&I]
 ButtonOK=確認
 ButtonCancel=放棄
 ButtonYes=市[&Y]
 ButtonYesToAll=全部確認[&A]
 ButtonNo=否[&N]
 ButtonNoToAll=全部否認[&o]
 ButtonFinish=完成[&F]
 ButtonBrowse=瀏覽[&B]...
 ButtonWizardBrowse=瀏覽[&r]...
 ButtonNewFolder=新建檔案夾[&M]
 
 ; *** "Select Language" dialog messages
 SelectLanguageTitle=選擇安裝語言種類
 SelectLanguageLabel=選擇該語言作為安裝語言:
 
 ; *** Common wizard text
 ClickNext=單擊“下一步”繼續,或者單擊“放棄”退出本安裝程式,
 BeveledLabel=
 BrowseDialogTitle=瀏覽檔案夾
 BrowseDialogLabel=在下面的串列中選擇一個目錄, 然后單擊“確認”繼續,
 NewFolderName=新檔案夾
 
 ; *** "Welcome" wizard page
 WelcomeLabel1=歡迎進入 [name] 安裝向導
 WelcomeLabel2=將在您的電腦上安裝 [name/ver] ,%n%n建議在繼續安裝之前退出其它程式的運行,
 
 ; *** "Password" wizard page
 WizardPassword=密碼
 PasswordLabel1=本安裝程式受密碼保護,
 PasswordLabel3=請輸入密碼,密碼區分大小寫,然后單擊“下一步”繼續,
 PasswordEditLabel=密碼[&P]:
 IncorrectPassword=輸入的密碼不正確,請重新輸入,
 
 ; *** "License Agreement" wizard page
 WizardLicense=用戶許可協議
 LicenseLabel=請在繼續之前仔細閱讀用戶許可協議,
 LicenseLabel3=請仔細閱讀下面的用戶許可協議,在繼續安裝之前,您必須接受該協議,
 LicenseAccepted=我接受協議[&a],
 LicenseNotAccepted=我不接受協議[&d]
 
 ; *** "Information" wizard pages
 WizardInfoBefore=提示
 InfoBeforeLabel=在繼續安裝之前請仔細閱讀以下重要的資訊,
 InfoBeforeClickLabel=當您準備好繼續安裝時,單擊“繼續”,
 WizardInfoAfter=資訊
 InfoAfterLabel=在繼續安裝之前請仔細閱讀以下重要的資訊,
 InfoAfterClickLabel=當您準備好繼續安裝時,單擊“繼續”,
 
 ; *** "User Information" wizard page
 WizardUserInfo=用戶資訊
 UserInfoDesc=請輸入您的資訊,
 UserInfoName=用戶名[&U]:
 UserInfoOrg=組織[&O]:
 UserInfoSerial=序列號[&S]:
 UserInfoNameRequired=您必須輸入一個名稱,
 
 ; *** "Select Destination Location" wizard page
 WizardSelectDir=選擇目標位置
 SelectDirDesc=您將把[name]安裝在哪里?
 SelectDirLabel3=安裝程式將把[name]安裝在下面的的檔案夾中,
 SelectDirBrowseLabel=為了繼續安裝, 請單擊“下一步”,如果您想選擇一個不同的目錄,請單擊“瀏覽”,
 DiskSpaceMBLabel=為了安裝本軟體,至少需要 [mb] MB 的空閑磁盤空間,
 ToUNCPathname=安裝程式不能安裝到一個 UNC 目錄名稱,如果您試圖網上安裝本程式,請映射網路驅動器,
 InvalidPath=您比如輸入一個含盤符的路徑名稱,比如:%n%nC:\APP%n%n 或者一個網路路徑,例如:%n%n\\server\share
 InvalidDrive=您選擇的磁盤或者網路路徑不存在或者不能訪問,請重新選擇其它的磁盤或者網路路徑,
 DiskSpaceWarningTitle=磁盤空間不足,
 DiskSpaceWarning=安裝程式至少需要 %1 KB 空閑磁盤空間來安裝本軟體,但是選擇的磁盤上只有 %2 KB 空間可用,%n%n 您確認繼續?
 DirNameTooLong=該檔案夾的名稱太長,
 InvalidDirName=該檔案夾的名字太長,
 BadDirName32=檔案夾名稱中不能包括以下的任何字符:%n%n%1
 DirExistsTitle=檔案夾已經存在
 DirExists=檔案夾:%n%n%1%n%n已經存在,您想繼續安裝?
 DirDoesntExistTitle=檔案夾不存在
 DirDoesntExist=檔案夾:%n%n%1%n%n不存在,您想創建該檔案夾?
 
 ; *** "Select Components" wizard page
 WizardSelectComponents=選擇部件
 SelectComponentsDesc=哪些部件需要安裝?
 SelectComponentsLabel2=選擇您想要安裝的部件; 清除您不想安裝的部件,當您準備好后,請單擊“下一步” ,
 FullInstallation=完全安裝
 ; if possible don't translate 'Compact' as 'Minimal' (I mean 'Minimal' in your language)
 CompactInstallation=精簡安裝
 CustomInstallation=自定義安裝
 NoUninstallWarningTitle=部件存在
 NoUninstallWarning=安裝程式檢測到以下部件已經在您的電腦中被安裝了:%n%n%1%n%n不選擇它們將不在您的電腦中安裝它們,%n%n您想就這樣繼續嗎?
 ComponentSize1=%1 KB
 ComponentSize2=%1 MB
 ComponentsDiskSpaceMBLabel=當前選擇項至少需要 [mb] MB 的空閑磁盤空間才能安裝,
 
 ; *** "Select Additional Tasks" wizard page
 WizardSelectTasks=選擇一個附加任務
 SelectTasksDesc=您想選擇哪個附加任務?
 SelectTasksLabel2=選擇在安裝[name]時執行的附加任務, 然后單擊“下一步”,
 
 ; *** "Select Start Menu Folder" wizard page
 WizardSelectProgramGroup=選擇開始選單檔案夾
 SelectStartMenuFolderDesc=您想在哪里放置軟體的快捷方式?
 SelectStartMenuFolderLabel3=安裝程式將在下面的檔案夾中創建軟體的快捷方式,
 SelectStartMenuFolderBrowseLabel=為了繼續,單擊“下一步”,如果您想另外選擇一個檔案夾,單擊“瀏覽”,
 MustEnterGroupName=您必須輸入一個檔案夾名稱,
 GroupNameTooLong=檔案夾名稱或者路徑名稱太長,
 InvalidGroupName=檔案夾名稱非法,
 BadGroupName=檔案夾名字中不能包含下面的字符:%n%n%1
 NoProgramGroupCheck2=不創建開始選單中的檔案夾[&D]
 
 ; *** "Ready to Install" wizard page
 WizardReady=準備開始安裝
 ReadyLabel1=安裝程式開始在您的電腦中安裝[name].
 ReadyLabel2a=單擊“安裝”開始安裝本軟體,或者單擊“回退”修改安裝設定,
 ReadyLabel2b=單擊“安裝”開始安裝本軟體,
 ReadyMemoUserInfo=用戶資訊:
 ReadyMemoDir=安裝目標位置:
 ReadyMemoType=安裝種類:
 ReadyMemoComponents=選中的部件:
 ReadyMemoGroup=開始選單檔案夾:
 ReadyMemoTasks=附加任務:
 
 ; *** "Preparing to Install" wizard page
 WizardPreparing=準備安裝
 PreparingDesc=安裝程式準備在您的電腦中安裝[name],
 PreviousInstallNotCompleted=安裝/卸載一個以前的程式沒有完成,您需要重新啟動您的電腦來完成安裝作業,%n%n當重新啟動您的電腦后,請運行安裝程式來完成安裝[name],
 CannotContinue=安裝程式不能繼續執行,請單擊“放棄”退出,
 
 ; *** "Installing" wizard page
 WizardInstalling=安裝中
 InstallingLabel=安裝程式正在安裝[name],請等待,
 
 ; *** "Setup Completed" wizard page
 FinishedHeadingLabel=[name]安裝完成
 FinishedLabelNoIcons=安裝程式已經在您的電腦中安裝了[name],
 FinishedLabel=安裝程式已經在您的電腦中安裝了[name],要執行本軟體,請單擊安裝好的本軟體圖示 ,
 ClickFinish=單擊“完成”退出本安裝程式.
 FinishedRestartLabel=為了完成[name]的安裝, 安裝程式必須重新啟動您的電腦,您想現在就重新啟動?
 FinishedRestartMessage=為了完成[name]的安裝, 安裝程式必須重新啟動您的電腦,%n%您想現在就重新啟動?
 ShowReadmeCheck=是的,我想查看 README 檔案
 YesRadio=是的,我想重新啟動計算機[&Y]
 NoRadio=不,我將稍后重新啟動計算機[&N]
 ; used for example as 'Run MyProg.exe'
 RunEntryExec=運行 %1
 ; used for example as 'View Readme.txt'
 RunEntryShellExec=查看 %1
 
 ; *** "Setup Needs the Next Disk" stuff
 ChangeDiskTitle=安裝程式需要下一個安裝盤
 SelectDiskLabel2=請插入安裝盤 %1 并且單擊“確認”,%n%n如果該盤不是下面顯示的盤,請輸入正確的路徑或者單擊“瀏覽”,
 PathLabel=目錄[&P]:
 FileNotInDir2=在 "%2" 中沒有發現檔案,請插入正確的磁盤或者選擇其它的檔案夾,
 SelectDirectoryLabel=請輸入下一個磁盤中的正確位置,
 
 ; *** Installation phase messages
 SetupAborted=安裝沒有完成,%n%n請修復錯誤并重新安裝,
 EntryAbortRetryIgnore=單擊“重試”重新嘗試,單擊“忽略”將繼續安裝,或者單擊“放棄”退出安裝,
 
 ; *** Installation status messages
 StatusCreateDirs=創建目錄中...
 StatusExtractFiles=解壓檔案中...
 StatusCreateIcons=創建快捷方式中...
 StatusCreateIniEntries=創建INI單元中...
 StatusCreateRegistryEntries=創建注冊表內容中...
 StatusRegisterFiles=注冊檔案中...
 StatusSavingUninstall=保存卸載資訊中...
 StatusRunProgram=正在完成安裝...
 StatusRollback=恢復原來修改的內容中...
 
 ; *** Misc. errors
 ErrorInternal2=內部錯誤: %1
 ErrorFunctionFailedNoCode=%1 失敗
 ErrorFunctionFailed=%1 失敗; 代碼 %2
 ErrorFunctionFailedWithMessage=%1 錯誤; 代碼 %2.%n%3
 ErrorExecutingProgram=不能執行檔案:%n%1
 
 ; *** Registry errors
 ErrorRegOpenKey=在打開注冊表鍵時發生錯誤:%n%1\%2
 ErrorRegCreateKey=在創建注冊表鍵時發生錯誤:%n%1\%2
 ErrorRegWriteKey=在些注冊表鍵時發生錯誤:%n%1\%2
 
 ; *** INI errors
 ErrorIniEntry=在創建INI檔案時發生錯誤 "%1".
 
 ; *** File copying errors
 FileAbortRetryIgnore=單擊“重試”再試一次,單擊“忽略”忽略該檔案,或者單擊“放棄”退出安裝程式,
 FileAbortRetryIgnore2=單擊“重試”再試一次,單擊“忽略”忽略該檔案繼續安裝,或者單擊“放棄”退出安裝程式,
 SourceIsCorrupted=源檔案被使用
 SourceDoesntExist=源檔案 "%1" 不存在
 ExistingFileReadOnly=該已經存在的檔案是只讀屬性,%n%n單擊“重試”洗掉只讀屬性并重新嘗試,單擊“忽略”忽略該檔案,或者單擊“放棄”退出安裝程式,
 ErrorReadingExistingDest=當試圖讀取一個已經存在的檔案時發生了錯誤:
 FileExists=該檔案已經存在,%n%n您想覆寫它嗎?
 ExistingFileNewer=已經存在的檔案比安裝程式試圖安裝的檔案要新,建議您保留該檔案,%n%n您想保留已經存在的檔案嗎?
 ErrorChangingAttr=當試圖改變一個存在的檔案的屬性時發生了錯誤:
 ErrorCreatingTemp=當試圖在目標目錄中創建一個檔案時發生了錯誤:
 ErrorReadingSource=當試圖讀取一個檔案時發生了錯誤:
 ErrorCopying=當試圖復制一個檔案時發生了錯誤:
 ErrorReplacingExistingFile=當試圖覆寫已經存在的檔案時發生錯誤:
 ErrorRestartReplace=重新啟動置換失敗:
 ErrorRenamingTemp=當在目標目錄中重命名檔案時發生錯誤:
 ErrorRegisterServer=不能注冊 DLL/OCX: %1
 ErrorRegisterServerMissingExport=沒有Dll注冊服務庫輸出
 ErrorRegisterTypeLib=不能注冊以下型別庫: %1
 
 ; *** Post-installation errors
 ErrorOpeningReadme=當打開 README 檔案時發生錯誤,
 ErrorRestartingComputer=安裝程式不能重新啟動電腦,請手動啟動,
 
 ; *** Uninstaller messages
 UninstallNotFound=檔案 "%1" 不存在,不能卸載,
 UninstallOpenError=檔案 "%1" 不能打開,不能卸載,
 UninstallUnsupportedVer=卸載記錄檔案 "%1" 不是基于本安裝程式的版本,不能完成軟體的洗掉作業,
 UninstallUnknownEntry=一個未知的物體 (%1) 存在于卸載記錄檔案中,
 ConfirmUninstall=您確定完全洗掉 %1 和所有基于它上面的部件嗎?
 UninstallOnlyOnWin64=該安裝程式只能在64位的Windows上執行卸載作業,
 OnlyAdminCanUninstall=該安裝程式只能在您具有管理員權限時才能執行卸載作業,
 UninstallStatusLabel= %1 正在被洗掉,請稍等,
 UninstalledAll=%1 被成功地從您的電腦中洗掉,
 UninstalledMost=%1 洗掉完成,%n%n有某些部件不能被洗掉,您可能需要手動洗掉它們,
 UninstalledAndNeedsRestart=為了完成 %1 的洗掉作業, 您必須重新啟動電腦,%n%n您想現在就重新啟動嗎?
 UninstallDataCorrupted=檔案"%1" 被占用,不能完成洗掉作業,
 
 ; *** Uninstallation phase messages
 ConfirmDeleteSharedFileTitle=洗掉共享程式檔案?
 ConfirmDeleteSharedFile2=系統指出以下的共享程式檔案將不再被使用,您是否想洗掉這些共享檔案?%n%n如果這些檔案洗掉后,其他程式仍然要使用它,可能其它程式的功能將受影響,如果您不能肯定,請選擇“否”,讓這些檔案保留在系統中不會對系統造成損害,
 SharedFileNameLabel=檔案名:
 SharedFileLocationLabel=位置:
 WizardUninstalling=卸載
 StatusUninstalling=卸載 %1 中...
 
 ; The custom messages below aren't used by Setup itself, but if you make
 ; use of them in your scripts, you'll want to translate them.
 
 [CustomMessages]
 
 NameAndVersion=%1 版本 %2
 AdditionalIcons=附加圖示:
 CreateDesktopIcon=創建桌面圖示[&d]
 CreateQuickLaunchIcon=創建快速啟動圖示[&Q]
 ProgramOnTheWeb=%1 on the Web
 UninstallProgram=卸載 %1
 LaunchProgram=執行 %1
 AssocFileExtension=用檔案擴展名 %2 匹配[&A] %1?
 AssocingFileExtension=正在用檔案擴展名 %2 匹配[&A] %1 中...

7.打包

打開Inno Setup,通過右上角File->New新建Inno Setup打包檔案,設定應用程式資訊

 

設定安裝目錄為前面的程序發布目錄

 

添加卸載快捷鍵

 

 設定licence資訊

 

 選擇安裝模式

 

 選擇漢化語言

 

 設定輸出目錄

 

 腳本中添加安裝命令,卸載命令

[Run]
Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "create MyService start=auto binPath=""{app}\MyWeb.exe""" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "start MyService" ; Flags: runhidden

[UninstallRun]
Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhidden

腳本最終內容

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "MyService"
#define MyAppVersion "1.0.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{0C9603FD-2587-41FD-A532-CB5294E7B56E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=D:\Mylicence.txt
InfoBeforeFile=D:\Myshowafter.txt
InfoAfterFile=D:\Myshowbefore.txt
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\c\Desktop
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl"

[Files]
Source: "D:\MyWeb\bin\Release\net6.0\publish\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"


[Run]
Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "create MyService start=auto binPath=""{app}\MyWeb.exe""" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "start MyService" ; Flags: runhidden

[UninstallRun]
Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhidden

8.打包編譯

點擊編譯按鈕,打包好后,雙擊exe安裝

9.檢驗安裝

首先去windows 服務查看是否安裝成功

 

然后訪問服務

 

 

 至此打包安裝完成,

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/522840.html

標籤:.NET技术

上一篇:【.NET生態系列】使用Hangfire+.NET 6實作定時任務管理

下一篇:合并兩個張量流資料集,盡管速度不同

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more