1. Install Web Deploy Projects
2. Right-click the Web Project in VS, Add the Web Deployment Project, and click OK.
3. Set the properties of the newly added project. The Output Path on the "Compilation" page is the directory to be published.
4. On the Deployment page of the project properties, select "Enable Web. config file section replacement", and enter "connectionStrings = connectionStrings. config;", OK
5. Add a connectionStrings. config file to the original Web project, and enter connectionStrings of the release/Production Environment version:
<ConnectionStrings>
<Add/>
</ConnectionStrings>
6. In the Web. config file of the original web project, the connectionStrings section only needs to contain the connection string used during development.
7. Execute the "generate" Operation of the deployment project to find the file and directory structure that can be directly released from the Output Path you have set.
In addition, if some files do not want to be published (such as file1.name and file2.name, dir1.name and dir2.name), you can open the project file of the deployment project and implement the following modifications: <ItemGroup>
<RemoveFileAfterBuild Include = "$ (OutputPath) \ file1.name"/>
<RemoveFileAfterBuild Include = "$ (OutputPath) \ file2.name"/>
<RemoveDirAfterBuild Include = "$ (OutputPath) \ dir1.name"/>
<RemoveDirAfterBuild Include = "$ (OutputPath) \ dir2.name"/>
</ItemGroup>
<Target Name = "AfterBuild">
<RemoveDir Directories = "@ (RemoveDirAfterBuild)"/>
<Delete Files = "@ (RemoveFileAfterBuild)"/>
</Target>