Compile ASPX/ASCX into DLL? (i.e. compile on client instead of server?) - asp.net

If I understand correctly with our deployments most code gets compiled on the workstation, and the aspx/ascx files get compiled on first access on the server. Is there anyway to precompile these?
I would like to do this to trigger compile errors at workstation compile time, rather than at "run-time" and also to potentially allow C# 4 features to work in views as we use .NET 3.5 on the servers.

Visual Studio provides the command-line tools aspnet_compiler and aspnet_merge, and I blogged about how to call them from a batch file.
You can also add aspnet_compiler as a Post-Build event in the project to find compilation errors, but it slows down build times.
If you develop for .Net 4, you need to have the .Net 4 framework installed on the web server.

Follow this link for precompilation overview: ASP.NET Precompilation Overview
Also, if on server 4th framework doesn't installed you can't use C#4 features in your project even if you will precompile application on your dev machine.

Related

Obfuscator for .NET Core Single Publish Files

Is there an obfuscation tool that can work well on the exe and pdb files that result from a dotnet core single file publish?
I am using dotnet core single file publish with the command: dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true. This works great in giving me just two neat files an exe and a pdb file, which I am able to give to a client to run my application.
However, I am still concerned about its ability to be decompiled.
I tried using ILSpy and JustCompile on both the files and they luckily could not be decompiled with these tools. Is it then that my files are safe, or it is that the tools have not yet caught up?
If the latter, what obfuscation tool can I use to protect these files? I attempted to use Obfuscar which did not work specifically on the single file publish outputs, the exe and pdb.
Any suggestions on the obfuscation tools to use for this?
Disclosure: I work for the Dotfuscator team at PreEmptive.
We have tested and verified that Dotfuscator Professional handles this scenario on both .NET Core 3 and .NET 5.
Specifically, you must use Dotfuscator Professional's MSBuild integration, which is now our recommended method of using Dotfuscator Professional for new projects. However, Dotfuscator will not update .pdb files on .NET Core or .NET 5, so you will not be able to debug builds which use Dotfuscator (e.g., Release builds). You should not ship .pdb files to untrusted users.
You can decompile .NET Core self-contained executables if you manually unpack them:
Can .Net Core 3 self-contained single executable be decompiled?
You would have to run the obfuscator as part of the build process, before the individual assemblies are compressed into the single file. That's probably possible if you add a custom MSBuild target that executes the obfuscator, and use the BeforeTargets attribute to integrate it at the correct point in the build process. But I haven't looked at the .NET core build system in detail.
You can use Obfuscar.
Use it in obj directory after target Compile and then copy obfuscated files to directory.(replace with original files)

Was the ability to run a .NET Core app from source code removed?

In previous versions of what is now .NET Core, using the dnx toolchain, it was possible to run an application straight from source code, without compiling to a DLL on disk. This capability was also present on Azure, allowing you to edit code on the server and have those changes reflected in the live site.
The new dotnet CLI run command seems to automatically create the familiar bin and obj folders with compiled DLLs in them, and the publish process from Visual Studio to Azure now no longer includes the C# source, just the DLL.
Is it no longer possible with the new CLI and other tools to run .NET Core code without creating a DLL on disk?
Short David Fowler response:
Dynamic compilation is gone in RC2. It only exists for views now. There are no plans to bring it back.
Why?
Architectural challenges and changes require to implement it on both .NET Framework and .NET Core. We did it with dnx and there were some problems (like some things being completely broken with in memory assemblies) that we chose to just avoid.

asp mvc deployment with msbuild and rake

I have an asp mvc project. I'm wondering, what's the difference between building the solution and then copying bin and all other views/scripts/images/style sheets and publishing (besides the obvious work of copying files). I'm asking because i want to automate my deployment with rake and I can't use web deployment because it's not compatible with mono.
Depending on your version of Visual Studio and settings, Publishing typically does two main things in addition to the build
Packages the solution
-- usually into some standard format (WebDeploy, Web Project)
Automates deployment
-- typically hooks something like MSdeploy ("web deploy") to synchronize the site with a local or remote IIS setting
So in terms of what you are deploying, there is no difference. The build and output files are the same. Publishing is simply allowing a developer a simple path of packaging + deploy, which you are handling with rake.
BTW Have you looked Uppercut this tool could be very useful in your build process.

What do I need to install to compile Silverlight 2.0 applications on my build server

What's the minimum that I need to have installed on my Build Server (in addition to the standard .Net 3.5 stuff) to allow it to compile Silverlight 2.0 applications?
I have a Silverlight application that seems to be building correctly, but is not playing nicely with a related Web Application project - see this related question that I asked earlier: Silverlight xap file not being copied to ClientBin on Build Server
AFAIK you need Microsoft Silverlight 2 SDK to install on the build server.
HTH
Your build server should be pretty much an exact replication of your development machine as far as plug-ins, assemblies, run-times, SDK's etc.
You build server will be building your app via MSBuild.
In your particular case I suspect that you need to install the Silverlight Toolkit. This will give you the SL development runtime and the appropriate project build requisites for your XAP files to build and be deployed properly.

ASP.NET Application Deployment Question

I'm creating an asp.net application/plug-in to run on a asp.net website/e-commerce solution. I want to make deployment easy for the user so that all they have to do is double click on an icon and all of my apps files will be placed into the proper folders on their asp.net website and all the necessary third-party files, like Microsoft's Visual Fox Pro 9 dll, will be installed. Is there a good tutorial or reference I can view to learn how to handle these deployment issues and are they even possible?
thanks
You can make an MSI (Microsoft Installer) which will do most of the work for them.
From Programming Microsoft ASP.NET 3.5 by Dino Esposito
Precompilation for deployment creates
a file representation of the site made
of assemblies and static files. This
representation can be generated on any
machine, and it can be packaged to MSI
and deployed.
Create an MSI is definitely a good
option to do this.
If you already have all the output
with dependencies, then a batch copy
script can do that for you.
If you are building from your
source, then take a look at
MsBuild/NAnt,and you can moidfy some
post-build script to do that batch
process for you.
You can also take a look at web
deployment project.

Resources