Publishing a single .cs compiled file

Donald Symmons 2,881 Reputation points
2024-02-13T03:20:16.4666667+00:00

Hi, May I please ask if it is possible to publish .cs file to make it a compiled DLL which will be in the bin folder of a live hosting, without having to publish the whole project? I asked this because I may need to make some changes to some C# codes and it takes longer period of time to publish the whole project. So I was thinking if maybe there's a way that I can publish some .cs files after I make some corrections to them

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,877 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,494 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 29,591 Reputation points Microsoft Vendor
    2024-02-13T06:24:25.49+00:00

    Hi @Donald Symmons,

    This is actually not recommended as you might have made a change to aspx but forgotten about it between deployments. It’s best to send the entire content.

    But if you insist, I found a tool that can help you: CSC.EXE (.NET Framework Executable).

    You could try the following steps to use csc.exe to convert .cs file to an dll file.

    Enter cmd in the C:\Windows\Microsoft.NET\Framework64\v4.0.30319 directory. Then enter the following command line(Change the path based on your own project).

    csc.exe /t:library -out:C:\Test\Project\test.dll C:\Test\Project\Program.cs

    User's image

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.