Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

.net - How to convert a Class Library project to a Web Application project?

Long story short, because of some issues with architecture and the fact that someone already put a few .aspx files in a class library, I'd like to just finish off the change and convert a class library to a web application. This is using Visual Studio 2010 and .NET 4.0. Is there an easy way of doing this? Thanks!

EDIT: I was hoping for a better method than recreating the project, I had too many issues with broken references when I tried just creating a new project, including one I could never seem to fix.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I did this by hand today in Visual Studio 2005 because it seemed easier and faster than the above. I just diffed a working web application .csproj file with my class library to determine the relevant differences. Based on that, I made the following changes. Keep in mind that it may be different for other versions or your individual project.

1) Right after the <ProjectGuid> element near the top, I added

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> 

2) I removed <ProjectType>Local</ProjectType>
3) At the bottom of the file, right before the closing </Project>, I added

<Import Project="$(MSBuildExtensionsPath)MicrosoftVisualStudiov8.0WebApplicationsMicrosoft.WebApplication.targets" />
      <ProjectExtensions>
        <VisualStudio>
          <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
            <WebProjectProperties>
              <UseIIS>False</UseIIS>
              <AutoAssignPort>True</AutoAssignPort>
              <DevelopmentServerPort>3291</DevelopmentServerPort>
              <DevelopmentServerVPath>/</DevelopmentServerVPath>
              <IISUrl>
              </IISUrl>
              <NTLMAuthentication>False</NTLMAuthentication>
            </WebProjectProperties>
          </FlavorProperties>
        </VisualStudio>
</ProjectExtensions>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...