
环境windows10.net framework4.8rider2025.3新建类库项目编辑aspxstudy01.csproj添加 WebForms 项目类型 GUID!--下面一行代码表示是web项目--ProjectTypeGuids{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}/ProjectTypeGuids验证目标框架确保TargetFrameworkVersion节点指向有效的.NET Framework 版本TargetFrameworkVersionv4.8/TargetFrameworkVersion保存.csproj文件后右键项目 → 选择「重新加载项目」查看项目属性就可以看到多了个web属性填写url和端口号新建web.config?xml version1.0 encodingutf-8?configurationsystem.webcompilationdebugtruetargetFramework4.8/httpRuntimetargetFramework4.8//system.websystem.webServer/system.webServer/configuration添加引用添加对于web开发项目需要的dllSystem.WebWebForms 核心程序集包含页面、服务器控件等核心类。System.Web.Extensions可选支持 AJAX 等扩展功能。下载aspx设计生成工具下载地址打开设置-工具-自定义工具点击新增工具输入工具名称、路径和执行参数-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编译成功之后点击index.aspx右键执行Redesigner上面执行没有反应所以手动执行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点击显示所有文件包含到项目中就可以使用aspx控件了运行之后报错了解了一下dll需要在bin目录下但是目前是在bin/Debug目录下把生成的dll复制到bin再次访问就可以了需要将输出目录修改为bin目录修改outputpathOutputPathbin\/OutputPath使用工具也可以生成design.cs文件了网站也可以访问了发布修改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要不然没法发布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执行如下命令进行发布msbuildxxx.csproj/p:ConfigurationRelease/p:PublishProfileFolderProfile.pubxml/p:DeployOnBuildtruerider中使用设置-工具包和构建MSBuild设置最新的版本C:\Program Files (x86)\Microsoft Visual Studio\2026\BuildTools\MSBuild\Current\Bin\MSBuild.exe右键就有发布了参考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