The answer from Matej was useful to me, but I could not use it as it is, and still get it working both for local assemblies in Visual Studio and for automatic assemblies via TFS.
I had to add additional msbuild settings. In fact, I had two different scenarios. One of the projects was a web application embedded in the _PublishedWebsites folder, and one of them was an MVC web application that was not embedded in the _PublishedWebsites folder.
First add the following if it is not already in the project file:
<PropertyGroup> <MvcBuildViews>true</MvcBuildViews> </PropertyGroup>
For one WITH _PublishedWebsites:
<Choose> <When Condition="'$(BuildingInsideVisualStudio)' == true"> <PropertyGroup> <AspNetCompilerPhysicalPath>$(ProjectDir)</AspNetCompilerPhysicalPath> </PropertyGroup> </When> <Otherwise> <PropertyGroup> <AspNetCompilerPhysicalPath>$(WebProjectOutputDir)</AspNetCompilerPhysicalPath> </PropertyGroup> </Otherwise> </Choose> <Target Name="PrecompileWeb" AfterTargets="build" Condition="'$(MvcBuildViews)'=='true'"> <Message Text="Starting AspNetCompiler for $(ProjectName) at $(AspNetCompilerPhysicalPath)" Importance="high" /> <AspNetCompiler VirtualPath="/" PhysicalPath="$(AspNetCompilerPhysicalPath)" TargetPath="$(AspNetCompilerPhysicalPath)\bin_precompile" Force="true" /> </Target>
For one WITHOUT _PublishedWebsites:
<Choose> <When Condition="'$(BuildingInsideVisualStudio)' == true"> <PropertyGroup> <AspNetCompiler_CopyFilesFirst>false</AspNetCompiler_CopyFilesFirst> </PropertyGroup> </When> <Otherwise> <PropertyGroup> <AspNetCompiler_CopyFilesFirst>true</AspNetCompiler_CopyFilesFirst> </PropertyGroup> <ItemGroup> <AllOutputFiles Include="$(OutDir)\\**\*.*" /> </ItemGroup> </Otherwise> </Choose> <Target Name="PrecompileWeb" AfterTargets="build" Condition="'$(MvcBuildViews)'=='true'"> <Message Text="Before running AspNetCompiler, copy files from $(OutDir) to $(ProjectDir)\bin" Importance="high" /> <Exec Command="( robocopy.exe /mir $(OutDir) $(ProjectDir)\bin ) ^& IF %25ERRORLEVEL%25 LEQ 1 exit 0" Condition="'$(AspNetCompiler_CopyFilesFirst)'=='true'" /> <Message Text="Starting AspNetCompiler for $(ProjectName) at $(ProjectDir)" Importance="high" /> <AspNetCompiler VirtualPath="/" PhysicalPath="$(ProjectDir)" TargetPath="$(ProjectDir)\bin_precompile" Force="true" /> </Target>
kevinpo
source share