rider开发asp.net webform项目
环境
windows10
.net framework4.8
rider2025.3
新建类库项目

编辑aspxstudy01.csproj
添加 WebForms 项目类型 GUID
<!--下面一行代码表示是web项目--><ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>验证目标框架:确保<TargetFrameworkVersion>节点指向有效的.NET Framework 版本
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>保存.csproj文件后,右键项目 → 选择「重新加载项目」

查看项目属性就可以看到多了个web属性

填写url和端口号

新建web.config
<?xml version="1.0" encoding="utf-8"?><configuration><system.web><compilationdebug="true"targetFramework="4.8"/><httpRuntimetargetFramework="4.8"/></system.web><system.webServer></system.webServer></configuration>添加引用
添加对于web开发项目需要的dll
System.Web(WebForms 核心程序集,包含页面、服务器控件等核心类)。
System.Web.Extensions(可选,支持 AJAX 等扩展功能)。

下载aspx设计生成工具

打开设置->工具->自定义工具

点击+新增工具,输入工具名称、路径和执行参数

-r "$PROJECT_FOLDER$" -w "$PROJECT_FOLDER$\bin\$PROJECT_NAME$.dll" "$FILE$"
新建aspx

代码如下
<%@ Page Language="C#" CodeBehind="Index.aspx.cs" Inherits="aspxstudy01.Index" %> <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Title</title></head><body><formid="HtmlForm"runat="server"><div><asp:Buttonrunat="server"ID="myBtn"Text="我是按钮"/></div></form></body></html>编译成功之后,点击index.aspx右键执行Redesigner

上面执行没有反应,所以手动执行
cd E:\mycode\aspnetmvcstudy\aspnetpiplestudy # E:\Redesigner\Redesigner.exe -w .\bin\Debug\aspxstudy01.dll -r aspxstudy01 .\aspxstudy01\Index.aspx E:\Redesigner\Redesigner.exe -w .\aspxstudy01\bin\Debug\aspxstudy01.dll -r aspxstudy01 .\aspxstudy01\Index.aspx 
修改web.config
<?xml version="1.0" encoding="utf-8"?><configuration><system.web><compilationdebug="true"targetFramework="4.8"/><httpRuntimetargetFramework="4.8"/><pages><controls></controls></pages></system.web><system.webServer></system.webServer></configuration>再次就行就可以生成Index.aspx.designer.cs,点击显示所有文件包含到项目中

就可以使用aspx控件了

运行之后报错

了解了一下dll需要在bin目录下,但是目前是在bin/Debug目录下,把生成的dll复制到bin

再次访问就可以了

需要将输出目录修改为bin目录,修改outputpath
<OutputPath>bin\</OutputPath>使用工具也可以生成design.cs文件了,网站也可以访问了
发布
修改csproj
<!--新增代码--><PropertyGroup><VisualStudioVersionCondition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion><VSToolsPathCondition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath></PropertyGroup><!--$(MSBuildToolsPath)\Microsoft.CSharp.targets是原来就有的--><ImportProject="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/><ImportProject="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"Condition="'$(VSToolsPath)' != ''"/><ImportProject="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.targets"/>
新建FolderProfile.pubxml
<?xml version="1.0" encoding="utf-8"?><!-- https://go.microsoft.com/fwlink/?LinkID=208121. --><Project><PropertyGroup><DeleteExistingFiles>False</DeleteExistingFiles><ExcludeApp_Data>False</ExcludeApp_Data><LaunchSiteAfterPublish>True</LaunchSiteAfterPublish><LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration><LastUsedPlatform>Any CPU</LastUsedPlatform><PublishProvider>FileSystem</PublishProvider><PublishUrl>bin\app.publish\</PublishUrl><WebPublishMethod>FileSystem</WebPublishMethod></PropertyGroup></Project>安装vs_buildtools,要不然没法发布
https://visualstudio.microsoft.com/zh-hans/downloads/

安装所需要的模块
vs_buildtools.exe --quiet--wait--norestart--add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.WebDeploy --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.VisualStudio.Component.CoreBuildTools --add Microsoft.VisualStudio.Component.Roslyn.Compiler msbuild "xxx.csproj"/p:Configuration=Release /p:PublishProfile=FolderProfile.pubxml /p:DeployOnBuild=true 参考
https://github.com/seanofw/Redesigner
https://www.jetbrains.com/zh-cn/help/rider/Configuring_Third-Party_Tools.html#add-a-custom-msbuild-tool
https://learn.microsoft.com/zh-cn/visualstudio/msbuild/msbuild-command-line-reference?view=visualstudio
https://learn.microsoft.com/zh-cn/visualstudio/msbuild/common-msbuild-project-properties?view=visualstudio