1.在VS中发布Web应用,进行发布相关的设置后,在发布过程中出现如下截图的错误信息


2.查看错误输出信息后发现,在发布过程中,VS会在系统临时目录中创建文件进行预编译,并将预编译后的文件存储于另一个目录。猜测可能是目录名的问题

3.在发布的网站根目录中找到*.publishproj文件,在<PropertyGroup>节点内添加<IntermediateOutputPath>..\Temp</IntermediateOutputPath>,将可以设置发布过程中的临时文件存放目录,这里设置的..\Temp将会在项目目录中自动创建一个Temp文件夹,如下图所示是在发布过程中Temp文件夹下自动创建的文件

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.30319</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{931b5de2-a433-45c0-a8f1-b320be80eebe}</ProjectGuid>
<SourceWebPhysicalPath>$(MSBuildThisFileDirectory)</SourceWebPhysicalPath>
<SourceWebVirtualPath>/WebSite</SourceWebVirtualPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SourceWebProject>http://localhost:4354</SourceWebProject>
<SourceWebMetabasePath>/IISExpress/7.5/LM/W3SVC/9/ROOT</SourceWebMetabasePath>
<!--指定发布过程中临时文件的存放目录-->
<IntermediateOutputPath>..\Temp</IntermediateOutputPath>
</PropertyGroup>