`大家好。我正在尝试通过控制台调用 msbuild 来构建 Web 应用程序的项目之一。
我使用 .net Framework 4.5 和 msbuild CLI。 我正在一台不需要安装 IIS 的单独计算机上构建一个项目。发布后,我将手动部署应用程序文件。
构建结束时,弹出错误
ASPCONFIG:使用节时出错 注册为超越应用程序级别的allowDefinition='MachineToApplication'。此错误可能是由于未将虚拟目录配置为 IIS 中的应用程序而导致的。
那些。放置构建文件的目录不是IIS虚拟目录。 由于该项目是在单独的机器上构建的,因此这是正确的。
实际上问题是 - 是否可以发布所有项目文件 - 使用 web.config 文件、!app.offline 等,但在常规文件夹中作为一组文件以便进一步传输到另一台计算机?事实上,关闭检查以确保包含输出文件的目录不是 IIS 的目标。
现在我使用 msbuild 命令:
& msbuild.exe MySolution.sln /t:MyProject /p:Configuration=Release /p:PublishProfile=FolderProfile /p:Platform="Any CPU" /nr:false /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=true /p:publishUrl=./Publish/myProject
发布个人资料:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WebPublishMethod>FileSystem</WebPublishMethod> <PublishProvider>FileSystem</PublishProvider> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedPlatform>Any CPU</LastUsedPlatform> <SiteUrlToLaunchAfterPublish /> <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> <ExcludeApp_Data>False</ExcludeApp_Data> <publishUrl>C:\dev\publish\myProject</publishUrl> <DeleteExistingFiles>True</DeleteExistingFiles> <PrecompileBeforePublish>True</PrecompileBeforePublish> <EnableUpdateable>True</EnableUpdateable> <DebugSymbols>False</DebugSymbols> <WDPMergeOption>MergeAllPagesAndControlToASingleAssembly</WDPMergeOption> <UseMerge>True</UseMerge> <ContentAssemblyName>Compiled</ContentAssemblyName> </PropertyGroup> </Project>
尝试:使用问题描述中的发布配置文件执行 msbuild 命令 预期:将构建应用程序文件(包括指定配置的 web.config 和 !app.offline)并放置在指定文件夹中。这不会检查该文件夹是否是 IIS 虚拟目录,并且在发布完成后不会抛出错误。`
通过删除参数解决问题
/p:DeployDefaultTarget=WebPublish