allowDefinition = 'MachineToApplication'VS2010에서 게시 할 때 오류 발생 (이전 빌드 이후에만)
로컬 컴퓨터에서 문제없이 Asp.Net MVC 2 애플리케이션을 실행할 수 있습니다. 그냥 실행 / 디버그하십시오.
하지만 이미 구축했다면 게시 할 수 없습니다! 솔루션을 정리하고 다시 게시해야합니다. 나는 이것이 시스템에 중요하지 않다는 것을 알고 있지만 정말 성가신 일입니다. "원 클릭 게시"는 "클린 솔루션 후 원 클릭 게시"가 아닙니다.
정확한 오류는 다음과 같습니다.
Error 11 애플리케이션 수준을 넘어서 allowDefinition = 'MachineToApplication'으로 등록 된 섹션을 사용하면 오류가 발생합니다. 이 오류는 IIS에서 응용 프로그램으로 구성되지 않은 가상 디렉터리로 인해 발생할 수 있습니다.
Views 폴더의 Web.Config와 관련이 있다고 생각하지만 이전에 한 번만 빌드 한 후에야합니다. 참고로 앱이 게시되면 정상적으로 작동합니다.
내 MVC 앱에서 동일한 문제가 발생했습니다. 나는 여전히 내 뷰를 확인하기를 원했기 때문에 실망 스러웠으므로 MvcBuildViews 를 끄고 싶지 않았습니다.
운 좋게도 나는 나에게 대답을 준 게시물 을 발견했습니다 . MvcBuildViews를 true 로 유지 한 다음 프로젝트 파일 아래에 다음 줄을 추가 할 수 있습니다.
<BaseIntermediateOutputPath>[SomeKnownLocationIHaveAccessTo]</BaseIntermediateOutputPath>
그리고 그 폴더를 프로젝트 폴더에 넣지 마십시오. 나를 위해 작동합니다. 완벽한 솔루션은 아니지만 현재로서는 좋습니다. 확실히 당신은 제거 확인 패키지 합니다 (내부에있는 폴더 OBJ \ 디버그 및 / 또는 OBJ \ 릴리스 그렇지 않으면 오류가 계속하겠습니다 프로젝트 폴더에서 폴더).
FWIW, MS는이 오류에 대해 알고 있습니다 ...
내 obj / Debug 폴더에서 모든 것을 삭제했고이 오류를 수정했습니다. 이것은 내가
<MvcBuildViews>true</MvcBuildViews>
내 프로젝트 파일의 옵션 (T4MVC T4 템플릿과 함께 유용함).
편집 : "Build"-> "Rebuild Solution"메뉴를 사용하면 훨씬 쉽게 수행 할 수 있습니다 (실제로 rebuild가 수행하는 작업은 obj / Debug 폴더를 지운 다음 솔루션을 빌드하기 때문입니다).
이 오류 에 대해 MS Connect 페이지 에서이 해결 방법을 사용하고 있습니다. AspNetCompiler를 실행하기 전에 프로젝트 (모든 구성)의 모든 obj 및 temp 파일을 정리합니다.
Visual Studio에서 만든 패키징 파일을 정리하는 대상에 따라 달라 지도록 프로젝트 파일에서 MvcBuildViews 대상을 수정합니다. 이러한 대상은 웹 애플리케이션 프로젝트에 자동으로 포함됩니다.
모든 패키징 파일은 MvcBuildViews 대상이 실행될 때마다 삭제됩니다.
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'" DependsOnTargets="CleanWebsitesPackage;CleanWebsitesPackageTempDir;CleanWebsitesTransformParametersFiles;">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(MSBuildProjectDirectory)" />
</Target>
이 문제는 obj 폴더에 웹 프로젝트 출력 (템플릿 web.config 또는 임시 게시 파일)이있을 때 발생합니다. 사용 된 ASP.NET 컴파일러는 obj 폴더의 내용을 무시할만큼 똑똑하지 않아 대신 오류가 발생합니다.
또 다른 수정 사항은 <AspNetCompiler>를 호출하기 직전에 게시 출력을 핵무기하는 것입니다. .csproj를 열고 다음을 변경하십시오.
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
이에:
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<ItemGroup>
<ExtraWebConfigs Include="$(BaseIntermediateOutputPath)\**\web.config" />
<ExtraPackageTmp Include="$([System.IO.Directory]::GetDirectories("$(BaseIntermediateOutputPath)", "PackageTmp", System.IO.SearchOption.AllDirectories))" />
</ItemGroup>
<Delete Files="@(ExtraWebConfigs)" />
<RemoveDir Directories="@(ExtraPackageTmp)" />
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
그러면 \ obj 아래의 모든 web.config와 \ obj 아래의 모든 PackageTmp 폴더가 삭제됩니다.
웹 게시를 사용 하는 경우 임시 폴더에 복사 한 후 (게시 / 패키지 직전에) 미리 컴파일되는 MvcBuildViews=false
및 을 설정할 수 있습니다 PrecompileBeforePublish=true
.
참고 : PrecompileBeforePublish
"새로운"웹 게시 파이프 라인 스택 (VS2010 SP1 + Azure SDK 또는 VS2012 RTM)에서만 지원됩니다. VS2010 RTM을 사용하는 경우 대체 방법 중 하나를 사용해야합니다.
jrummell의 솔루션과 관련하여 설정 :
DependsOnTargets="CleanWebsitesPackage;CleanWebsitesPackageTempDir;CleanWebsitesTransformParametersFiles;"
그것은 VS 2010에서 작동 하지만, 하지 VS에서 2012 년 . 2012 년에는 다음을 입력해야합니다.
DependsOnTargets="CleanWebsitesPackage;CleanWebsitesWPPAllFilesInSingleFolder;CleanWebPublishPipelineIntermediateOutput"
출처:
VS 2010: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets
VS 2012: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets
I know this has been answered but I just wanted to add something interesting I found.
I had set the "MvcBuildViews" to false in the project, deleted all bin and obj folders and I was still getting the error. I found that there was a ".csproj.user" file that still had "MvcBuildViews" set to true.
I deleted the ".csproj.user" file and then it all worked.
So make sure if you are changing your csproj file that you either change or delete the ".csproj.user" file also.
I had this problem as well, so I created a Pre-Build Event in the project properties to Clean the output directories(${projectPath}\bin,${projectPath}\obj\${ConfigurationName}
). On another project I was also getting this error, even with the cleaning event in place. On the second project I was compiling the views as listed in the project file:
<MvcBuildViews>true</MvcBuildViews>
I changed the true to false, and it no longer complained about that error, but still ran correctly. I won't claim I know exactly what was causing the second error, but at least it got me moving forward for the time being.
The problem has to do with the intermediate files, but there is another solution which consist in cleaning up those intermediate files before builnding the views.
This solution has been included in some version of VS, but I can only say that I had the problem in VS 2013 Update 5. (See the "Beware" below, it could be fixed in this version, but not working only in my particular non-standard case).
I borrowed the soltuion from Error: allowDefinition='MachineToApplication' beyond application level on Visual Studio Connect.
The solution consist in including these lines to the web application project (.csproj
file) which handle the deletion of the offedning intermediate files:
<!--Deal with http://connect.microsoft.com/VisualStudio/feedback/details/779737/error-allowdefinition-machinetoapplication-beyond-application-level,
we will need to clean up our temp folder before MVC project starts the pre-compile-->
<PropertyGroup>
<_EnableCleanOnBuildForMvcViews Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='' ">true</_EnableCleanOnBuildForMvcViews>
</PropertyGroup>
<Target Name="CleanupForBuildMvcViews" Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='true' and '$(MVCBuildViews)'=='true' " BeforeTargets="MvcBuildViews">
<ItemGroup>
<_PublishTempFolderNamesToCleanup Include="Database;TransformWebConfig;CSAutoParameterize;InsertAdditionalCS;ProfileTransformWebConfig;Package;AspnetCompileMerge" />
</ItemGroup>
<!--Force msbuild to expand all the wildcard characters so to get real file paths-->
<CreateItem Include="@(_PublishTempFolderNamesToCleanup->'$(BaseIntermediateOutputPath)**\%(identity)\**\*')">
<Output TaskParameter="Include" ItemName="_EvaluatedPublishTempFolderNamesToCleanup" />
</CreateItem>
<Delete Files="@(_EvaluatedPublishTempFolderNamesToCleanup)" />
</Target>
Beware: for some reason, probably because I included it myself in the project, my build target for building the views was named "BuildViews"
, instead of "MvcBuildViews"
, so I had to modify the BeforeTargets
attribute accordingly. I also simplified the target, by removing the PropertyGroup
and simplifying the condition, like this:
<Target Name="CleanupForBuildMvcViews" Condition="'$(MVCBuildViews)'=='true' " BeforeTargets="BuildViews">
<ItemGroup>
<_PublishTempFolderNamesToCleanup Include="Database;TransformWebConfig;CSAutoParameterize;InsertAdditionalCS;ProfileTransformWebConfig;Package;AspnetCompileMerge" />
</ItemGroup>
<!--Force msbuild to expand all the wildcard characters so to get real file paths-->
<CreateItem Include="@(_PublishTempFolderNamesToCleanup->'$(BaseIntermediateOutputPath)**\%(identity)\**\*')">
<Output TaskParameter="Include" ItemName="_EvaluatedPublishTempFolderNamesToCleanup" />
</CreateItem>
<Delete Files="@(_EvaluatedPublishTempFolderNamesToCleanup)" />
</Target>
In my case i saw that when i have MvcBuildViews and PrecompileDuringPublish as both true - was what was causing this issue.
So i removed the PrecompileDuringPublish and that solution worked for me and i have not faced this problem since.
'programing tip' 카테고리의 다른 글
Entity Framework 데이터 컨텍스트를 읽기 전용으로 만드는 방법 (0) | 2020.08.15 |
---|---|
자바에서지도의 얕은 사본 (0) | 2020.08.15 |
개체 참조가 개체의 인스턴스로 설정되지 않았습니다. .NET에서 어떤 개체가 'null'인지 표시하지 않는 이유는 무엇입니까? (0) | 2020.08.15 |
Kotlin의 단일 느낌표 (0) | 2020.08.15 |
NVIDIA vs AMD : GPGPU 성능 (0) | 2020.08.15 |