asp.net webform項(xiàng)目)
環(huán)境windows10.net framework4.8rider2025.3新建類庫項(xiàng)目編輯aspxstudy01.csproj添加 WebForms 項(xiàng)目類型 GUID!--下面一行代碼表示是web項(xiàng)目--ProjectTypeGuids{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}/ProjectTypeGuids驗(yàn)證目標(biāo)框架確保TargetFrameworkVersion節(jié)點(diǎn)指向有效的.NET Framework 版本TargetFrameworkVersionv4.8/TargetFrameworkVersion保存.csproj文件后右鍵項(xiàng)目 → 選擇「重新加載項(xiàng)目」查看項(xiàng)目屬性就可以看到多了個(gè)web屬性填寫url和端口號(hào)新建web.config?xml version1.0 encodingutf-8?configurationsystem.webcompilationdebugtruetargetFramework4.8/httpRuntimetargetFramework4.8//system.websystem.webServer/system.webServer/configuration添加引用添加對(duì)于web開發(fā)項(xiàng)目需要的dllSystem.WebWebForms 核心程序集包含頁面、服務(wù)器控件等核心類。System.Web.Extensions可選支持 AJAX 等擴(kuò)展功能。下載aspx設(shè)計(jì)生成工具下載地址打開設(shè)置-工具-自定義工具點(diǎn)擊新增工具輸入工具名稱、路徑和執(zhí)行參數(shù)-r $PROJECT_FOLDER$ -w $PROJECT_FOLDER$\bin\$PROJECT_NAME$.dll $FILE$新建aspx代碼如下% Page LanguageC# CodeBehindIndex.aspx.cs Inheritsaspxstudy01.Index %!DOCTYPEhtmlPUBLIC-//W3C//DTD XHTML 1.0 Transitional//ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhtmlxmlnshttp://www.w3.org/1999/xhtmlheadrunatservertitleTitle/title/headbodyformidHtmlFormrunatserverdivasp:ButtonrunatserverIDmyBtnText我是按鈕//div/form/body/html編譯成功之后點(diǎn)擊index.aspx右鍵執(zhí)行Redesigner上面執(zhí)行沒有反應(yīng)所以手動(dòng)執(zhí)行cdE:\mycode\aspnetmvcstudy\aspnetpiplestudy# E:\Redesigner\Redesigner.exe -w .\bin\Debug\aspxstudy01.dll -r aspxstudy01 .\aspxstudy01\Index.aspxE:\Redesigner\Redesigner.exe-w.\aspxstudy01\bin\Debug\aspxstudy01.dll-raspxstudy01 .\aspxstudy01\Index.aspx修改web.config?xml version1.0 encodingutf-8?configurationsystem.webcompilationdebugtruetargetFramework4.8/httpRuntimetargetFramework4.8/pagescontrols/controls/pages/system.websystem.webServer/system.webServer/configuration再次就行就可以生成Index.aspx.designer.cs點(diǎn)擊顯示所有文件包含到項(xiàng)目中就可以使用aspx控件了運(yùn)行之后報(bào)錯(cuò)了解了一下dll需要在bin目錄下但是目前是在bin/Debug目錄下把生成的dll復(fù)制到bin再次訪問就可以了需要將輸出目錄修改為bin目錄修改outputpathOutputPathbin\/OutputPath使用工具也可以生成design.cs文件了網(wǎng)站也可以訪問了發(fā)布修改csproj!--新增代碼--PropertyGroupVisualStudioVersionCondition$(VisualStudioVersion) 10.0/VisualStudioVersionVSToolsPathCondition$(VSToolsPath) $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)/VSToolsPath/PropertyGroup!--$(MSBuildToolsPath)\Microsoft.CSharp.targets是原來就有的--ImportProject$(MSBuildToolsPath)\Microsoft.CSharp.targets/ImportProject$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targetsCondition$(VSToolsPath) ! /ImportProject$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.targets/新建FolderProfile.pubxml?xml version1.0 encodingutf-8?!-- https://go.microsoft.com/fwlink/?LinkID208121. --ProjectPropertyGroupDeleteExistingFilesFalse/DeleteExistingFilesExcludeApp_DataFalse/ExcludeApp_DataLaunchSiteAfterPublishTrue/LaunchSiteAfterPublishLastUsedBuildConfigurationRelease/LastUsedBuildConfigurationLastUsedPlatformAny CPU/LastUsedPlatformPublishProviderFileSystem/PublishProviderPublishUrlbin\app.publish\/PublishUrlWebPublishMethodFileSystem/WebPublishMethod/PropertyGroup/Project安裝vs_buildtools要不然沒法發(fā)布https://visualstudio.microsoft.com/zh-hans/downloads/安裝所需要的模塊vs_buildtools.exe--quiet--wait--norestart--addMicrosoft.VisualStudio.Workload.MSBuildTools--addMicrosoft.VisualStudio.Component.WebDeploy--addMicrosoft.VisualStudio.Workload.WebBuildTools--addMicrosoft.VisualStudio.Component.CoreBuildTools--addMicrosoft.VisualStudio.Component.Roslyn.Compilerhttps://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?viewvisualstudiopreserve-viewtrue#msbuild-tools執(zhí)行如下命令進(jìn)行發(fā)布msbuildxxx.csproj/p:ConfigurationRelease/p:PublishProfileFolderProfile.pubxml/p:DeployOnBuildtruerider中使用設(shè)置-工具包和構(gòu)建MSBuild設(shè)置最新的版本C:\Program Files (x86)\Microsoft Visual Studio\2026\BuildTools\MSBuild\Current\Bin\MSBuild.exe右鍵就有發(fā)布了參考https://github.com/seanofw/Redesignerhttps://www.jetbrains.com/zh-cn/help/rider/Configuring_Third-Party_Tools.html#add-a-custom-msbuild-toolhttps://learn.microsoft.com/zh-cn/visualstudio/msbuild/msbuild-command-line-reference?viewvisualstudiohttps://learn.microsoft.com/zh-cn/visualstudio/msbuild/common-msbuild-project-properties?viewvisualstudio