117 Replies
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -r
|--runtime
implies --self-contained true
. Add --self-contained false
to publish as runtime-dependent.
-r RID
and -p:PublishSingleFile=true
can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish
with the -r
option for each RID.
You can also add -p:IncludeNativeLibrariesForSelfExtract=true
to include native libraries (like Common Language Runtime dlls) in the output executable.
You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot.
https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publishCreate a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
.NET Runtime Identifier (RID) catalog
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
and the exe doenst run without the dll
sooo
what did you try?
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
you have to replace
<runtime identifier>
with a... runtime identifieryes
i did
translate plz
done
Try adding
--self-contained
Task "ResolveComReference" is not supported on .NET Core version of MSBuild. Use the MSBuild version of the .NET Framework. See
yeah idk what that's about :/
thaths because i have windows media player on proyect?
For context: the project was migrated from Fx 4.8 to .NET 7 using the Upgrade Assistant ( #β nul )
ah
finali i just created a new and do it all myself
Upgrade Assistant broke everything
the output is proyectname.exe and proyectname.dll
i just want both only one exe
oh
-c release
Doenst work :C
ResolveComReference Task - MSBuild
Learn how MSBuild uses the ResolveComReference task to take a list of one or more type library names or .tlb files and resolve them to locations on disk.
have you tried
dotnet publish -c Release -r <rid> --self-contained -p:PublishSingleFile=true
?
Also can you show your csproj file?thath i was gonna do
because i was modifyng it befotre
Well afaik you can delete
StartupObject
, ApplicationIcon
, and PlatformTarget
, and you can also delete PublishSingleFile
and RuntimeIdentifier
since you can specify those when running dotnet publish
is that the entire file?sry
Looks like this is the issue
yes
but i need it for the music
<Exec Command="Obfuscar.Console.exe config.xml" />
are you... running an obfuscatoryes π
well you can get rid of that
why
obfuscation in .NET is literally useless
hmm
on framework works
yeah, the error message above says that
COMReference
isn't a thing you can use with modern versions of .NETyou can steale whole proyect with a single decompiler
yep
thaths because i use it then
you can still do that with obfuscated code
takes a bit more effort, but that ain't gonna stop a determined dataminer
$obfuscation
"Then finally, there is that question of code privacy. This is a lost cause. There is no transformation that will keep a determined hacker from understanding your program. This turns out to be true for all programs in all languages, it is just more obviously true with JavaScript because it is delivered in source form. The privacy benefit provided by obfuscation is an illusion. If you donβt want people to see your programs, unplug your server."
- Douglas Crockford
https://softwareengineering.stackexchange.com/a/155133
* Spend your effort on putting proprietary things in your api, and keeping the distributed code as empty as possible
* Use AuthN/AuthZ to control who/what/when/etc...
* Free obfuscation is worth the amount your paid for it -- it's already broken and most decompilers out there can make sense of it.
* Paid ofbuscation will bankrupt you unless you have a very strong revenue stream and can justify the additional cost with gained sales
* The "threat" of someone hijacking your UI and shimming it to make it provide them money is not a real threat. If this is legitimate software, you can ruin their business with lawsuits
- Cisien
Software Engineering Stack Exchange
Is it important to obfuscate C++ application code?
In the Java world, sometimes it seems to be a problem, but what about C++? Are there different solutions?
I was thinking about the fact that someone can replace the C++ library of a specific OS wit...
ok so i cant use windows media player
yea i nkow
oh that's what
WMPLib
stands for lmao
yeah no I think you'll have to find some other way to play music in a console app (...?)Naudio?
looks like a start
You probably want this
https://github.com/naudio/NAudio/blob/master/Docs/PlayAudioFileConsoleApp.md
thaths what i said
yes
(that specific tutorial)
this i think will be perfect
thanks
ok let me try again the compile with single file
dotnet publish -c Debug -r win-x64 -p:PublishSingleFile=true
i have to run this every time oln cimpile?
well, every time you want to publish your app
but just i want to compile in just one file
ex. when you release a new version
yeah,
dotnet publish -c Release -r <rid> --self-contained -p:PublishSingleFile=true
will publish your entire app into a single executable filenow i got another error
--self-contained
PM> Send a message on "Net 7 How to output one exe without dlls"
Submit : The term 'Submit' is not recognized as the name of a cmdlet, function, script file, or executable program. Check if you typed the name correctly, or if you included a path, check that the path is correct and try again.
Online: 1 Character: 1
+ Send a message on "Net 7 How to output one exe without dlls"
+~~
+ CategoryInfo : ObjectNotFound: (Send:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
oh nothing
im stupid
dotnet publish -c Debug -r win-x64 -p:PublishSingleFile=true --self-contained
wtf 147 MB of file
yeah, since single-file app have to pack all the DLLs as well as the entire runtime into the exe, the file sizes tend to be a couple orders of magnitudes larger than regular apps
and that's just an inherent part of single-file executables
on framework and costura fody was 2 mb
....
a couple
i got this error
i cant start thath
on framework worked
afaik you have to use the Powershell setting for
Process
to be able to start URLswhat
process start doenst have use shell executed enabled by default?
apparently not
but on framework yes
π
idk
Framework is weird
there is no way to be packed as 1 file without packing whole net libraries
just the program dll and the nuget dependencyes
well, .NET libraries are essentially the same as Nuget dependencies
They're all just... DLLs
but
are alredy installed on computer
What is?
yes
like framework
is alredy installed on windows
What exactly do you want? Do you just want to publish the app as a single exe file? Do you want the end user to have to install the .NET runtime or not?
Do you want the end user to have to install the .NET runtime > yesi prefere thath thath sending half gigabyte file
Then you can get rid of the
-p:PublishSingleFile=true
thingbut i just want the exe and the dll in a single file
hold on
just theese 2
If you do
dotnet publish -c Release -r <rid> --no-self-contained
then you'll get only the exe and app DLL
and all the runtime dependencies will be required to exist on the system
but as far as I can tell, you can't only get the app DLL into the exe
@Angius you know anything?i just want the exe
So you want the exe, but not any libraries packed into it?
i just want to run an silgle exe and work
without any other dll on the folder
like a single exe you download
and you run
Well, that's what single-file does, but the resulting exe is massive
Still, it's not very difficult to do a regular publish, put everything into a zip file, send that, then have your users decompress the zip and run your app from there.
not the same :c
It's either a single massive exe file, or a folder with one exe and at least one DLL. Pick one.
there must be another way
Again, if you do this, you'll get only two rather small files: an exe and a DLL, which still requires the user to have the .NET runtime installed.
on net 7 where are the packages saved?
~/.nuget
is the Nuget cache afaik?
I think the .NET libraries are downloaded somewhere to your appdata or something, but I'm unsure of where Nuget packages go
why they arent saved on proyect
to prevent duplication of packages on diferent proyects?
probably
But again, if you publish an app the regular way, it'll just dump all the DLLs in the output folder
I used chatgpt to create a bash script to pipe tar archives without persisting them on the filesystem, and then grabbed the artifact I wanted out of it. Maybe you could try that (I dont have the code available to me atm)
and for windows
I dunno your use case, and this doesn't answer your question, but... why not just use an installer?
if you know the users will already have .NET runtime, then doing framework-dependent single-file is probably your best bet.
https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?source=recommendations&tabs=cli
Create a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
yes thath or just create another program on framework thath loads the dll from memmory like reflective injection
second option sounds bad, if you're going to introduce a 2nd program it may as well just be the installer
I have a secret technique protecting against decompilation of your project
(but others are gonna eat me for suggesting that)
@Gato I made a cheatsheet for NAOT
https://wbg.gg/misc/naot/
you can try those commands
they return one single smol executable file (but you need to test it to ensure it works)
notably Native AOT breaks reflection and some other things
Winforms being Winforms I see
but winform is ez π
and without begin design expert you can do decent beautifully things
>beautiful
>winforms
Pick one lol
beautiful?
I'm not familiar with the word
biutifil
so I assumed you misspelled beautiful
or beautifully
yes mb
Ah, you were making your choice lol
I misunderstood, sorry
If you wanna make beautiful apps, or at least apps with a decent degree of visual customization, then WinForms is absolutely awful
WPF or Avelonia allows much more freedom
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.no is not
tl;dr Native AOT doesn't support WinForms, and the other options have already been discussed. there's no way to get only the exe without at least one DLL.
I actually know how to fix this
Let me check sec
How to: Generate Interop Assemblies from Type Libraries - .NET Fram...
Generate interop assemblies from type libraries. Use Type Library Importer (Tlbimp.exe) to convert coclasses and interfaces from a COM type library to metadata.
You can generate your own .NET DLL from your C++/native library
And then you can include it via
in your
.csproj
file.
Replace WUApiLib
with your managed (.NET) DLL file name that you generated using the tool linked above.
That way you don't have any comreferences in your project and can use the full functionality of the dotnet cliI dont use thath anymore
i just want a single light weight exe
and if its posible every time i compile
oh okay
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.i dont care if i loose support to linxu or other os
Just publish self-contained, zip up the files, give that zip to your users, then they just have to unzip it and run the exe. Simple.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.