Why does this call to aspnet_compiler not produce new .NET assemblies?
Asked Answered
S

1

1

I'm trying to make Visual Studio precompile my ASP.NET application that will be deployed on Azure. I've added the following to my .csproj file:

<Target Name="AfterBuild">
    <Message Text="Starting AspNetCompiler for $(ProjectDir)" Importance="high" />
    <AspNetCompiler
        VirtualPath="/"
        PhysicalPath="$(ProjectDir)"
    />
</Target>

Now when I ask Visual Studio to prepare a service package the following appears in the build output:

Starting AspNetCompiler for [PathToMyProject]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p [PathToMyProject]

If I plant an error in any of the view files that error is identified and breaks the build so clearly the precompilation is perfomed.

Yet I don't see any new .NET assemblies anywhere in the results.

How do I make ASP.NET compiler create the .NET assemblies for the views?

Screwy answered 5/10, 2012 at 9:6 Comment(0)
G
4

If you don't specify an output directory you should find the output in this folder:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\some-random-id (try sorting on the date modified to find the latest directory).

When calling the aspnet_compiler.exe you can also append an output folder to the command:

aspnet_compiler -v "/" -p "C:\Projects\WebApplication1\WebApplication1" C:\CompileOutput

Here you see the output in my C:\CompiledOutput folder

enter image description here

Grieg answered 5/10, 2012 at 10:57 Comment(2)
Is it possible to obtain that random folder path after the precompilation and copy the stuff from there? I'm not very optimistic about hardcoding the path.Screwy
I don't know how to access the random folder, but since you're using MSBuild you can simply modify the task like this: <AspNetCompiler VirtualPath="/" PhysicalPath="$(ProjectDir)" TargetPath="$(ProjectDir)..\PreCompiledOutput" />. This will output everything to a PreCompiledOutput folder in your Solution Directory and you can copy the files from that folder and clean it up afterwards.Grieg

© 2022 - 2024 — McMap. All rights reserved.