Visual Studio重写网站的解决方案配置



我有一个有关网站项目的解决方案。有三种自定义解决方案配置:开发,测试,产品。但是,网站项目没有.csproj文件,也没有办法(或者我找不到)用于网站项目。我正在使用msbuild来构建解决方案:

MSBuild.exe MySolution.sln /m /p:Platform=x86;TargetFrameworkVersion=v4.6.2;OutputPath=bin;Configuration=Dev /ToolsVersion:14.0 

as .sln文件没有有关我的DEV配置的任何信息,只有调试和发布"部分":

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Web", "Web", "{1F81A0DB-6FF4-4F89-B988-6D327797C4FD}"
ProjectSection(WebsiteProperties) = preProject
    TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.6.2"
    ProjectReferences = "{12A625AA-8B5A-4336-AA4A-3630AAB3A27D}|MyLib.dll;"
    Debug.AspNetCompiler.VirtualPath = "/localhost_54141"
    Debug.AspNetCompiler.PhysicalPath = "Web"
    Debug.AspNetCompiler.TargetPath = "PrecompiledWeblocalhost_54141"
    Debug.AspNetCompiler.Updateable = "true"
    Debug.AspNetCompiler.ForceOverwrite = "true"
    Debug.AspNetCompiler.FixedNames = "false"
    Debug.AspNetCompiler.Debug = "True"
    Release.AspNetCompiler.VirtualPath = "/localhost_54141"
    Release.AspNetCompiler.PhysicalPath = "Web"
    Release.AspNetCompiler.TargetPath = "PrecompiledWeblocalhost_54141"
    Release.AspNetCompiler.Updateable = "true"
    Release.AspNetCompiler.ForceOverwrite = "true"
    Release.AspNetCompiler.FixedNames = "false"
    Release.AspNetCompiler.Debug = "False"
    VWDPort = "54141"
    SlnRelativePath = "Web"
    StartServerOnDebug = "false"
EndProjectSection

endProject

和网站没有建立。

好吧,我可以手动编辑解决方案文件,然后更改/添加dev.xxxx,test.xxx等相关设置,并且一切都很好地运行,直到您在Visual Studio中打开解决方案并保存它为止。Visual Studio释放您的所有更改,您再次面临着同样的问题。

作为解决方法,我可以创建.sln文件的副本,并将其与原始解决方案同步。有人有更好的主意吗?

您可以使用不同的自定义ASPNETCOMPILER MSBUILD任务来构建网站项目。这样:

dev.msbuild

<Project xmlns = "http://schemas.microsoft.com/developer/msbuild/2003">
        <Target Name = "PrecompileWeb">
                <AspNetCompiler
                        VirtualPath = "/dev" 
                        PhysicalPath = "D:ProjectWebSite1"
                        TargetPath = "PrecompiledWebdev"
                        Force = "true"           
                        Debug = "False"
                        Updateable = "true"/>
        </Target>
</Project>

test.msbuild

<Project xmlns = "http://schemas.microsoft.com/developer/msbuild/2003">
            <Target Name = "PrecompileWeb">
                    <AspNetCompiler
                            VirtualPath = "/test" 
                            PhysicalPath = "D:ProjectWebSite1"
                            TargetPath = "PrecompiledWebtest"
                            Force = "true"           
                            Debug = "False"
                            Updateable = "true"/>
            </Target>
    </Project>

这样的构建命令:

MSBuild.exe dev.msbuild /m /p:TargetFrameworkVersion=v4.6.2;OutputPath=bin /ToolsVersion:14.0