C
Join ServerC#
help
❔ Net 7 How to output one exe without dlls
GGato2/26/2023
Halp $singlefile didnt worked
MMODiX2/26/2023
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:<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
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-publish
GGato2/26/2023
and the exe doenst run without the dll
GGato2/26/2023
sooo
Tthinker2272/26/2023
what did you try?
GGato2/26/2023
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Tthinker2272/26/2023
you have to replace
<runtime identifier>
with a... runtime identifierGGato2/26/2023
yes
GGato2/26/2023
i did
Tthinker2272/26/2023
translate plz
GGato2/26/2023
done
Tthinker2272/26/2023
Try adding
--self-contained
GGato2/26/2023
Task "ResolveComReference" is not supported on .NET Core version of MSBuild. Use the MSBuild version of the .NET Framework. See
Tthinker2272/26/2023
yeah idk what that's about :/
GGato2/26/2023
thaths because i have windows media player on proyect?
AAngius2/26/2023
For context: the project was migrated from Fx 4.8 to .NET 7 using the Upgrade Assistant ( #❔ nul )
Tthinker2272/26/2023
ah
GGato2/26/2023
finali i just created a new and do it all myself
GGato2/26/2023
Upgrade Assistant broke everything
GGato2/26/2023
the output is proyectname.exe and proyectname.dll
GGato2/26/2023
i just want both only one exe
Tthinker2272/26/2023

GGato2/26/2023
oh
GGato2/26/2023
-c release
Tthinker2272/26/2023

GGato2/26/2023
Doenst work :C
GGato2/26/2023
Tthinker2272/26/2023
have you tried
dotnet publish -c Release -r <rid> --self-contained -p:PublishSingleFile=true
?Tthinker2272/26/2023
Also can you show your csproj file?
GGato2/26/2023
thath i was gonna do
GGato2/26/2023
because i was modifyng it befotre
Tthinker2272/26/2023
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
Tthinker2272/26/2023
is that the entire file?
GGato2/26/2023
sry
Tthinker2272/26/2023
Looks like this is the issue
<ItemGroup>
<COMReference Include="WMPLib">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>6bf52a50-394a-11d3-b153-00c04f79faa6</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
GGato2/26/2023
yes
GGato2/26/2023
but i need it for the music
Tthinker2272/26/2023
are you... running an obfuscator<Exec Command="Obfuscar.Console.exe config.xml" />
GGato2/26/2023
yes 😭
Tthinker2272/26/2023
well you can get rid of that
GGato2/26/2023
why
Tthinker2272/26/2023
obfuscation in .NET is literally useless
GGato2/26/2023
hmm
GGato2/26/2023
on framework works
Tthinker2272/26/2023
yeah, the error message above says that
COMReference
isn't a thing you can use with modern versions of .NETGGato2/26/2023
you can steale whole proyect with a single decompiler
Tthinker2272/26/2023
yep
GGato2/26/2023
thaths because i use it then
Tthinker2272/26/2023
you can still do that with obfuscated code
Tthinker2272/26/2023
takes a bit more effort, but that ain't gonna stop a determined dataminer
AAngius2/26/2023
$obfuscation
MMODiX2/26/2023
"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
- 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
GGato2/26/2023
ok so i cant use windows media player
GGato2/26/2023
yea i nkow
Tthinker2272/26/2023
oh that's what
WMPLib
stands for lmaoTthinker2272/26/2023
yeah no I think you'll have to find some other way to play music in a console app (...?)
GGato2/26/2023
Naudio?
Tthinker2272/26/2023
looks like a start
Tthinker2272/26/2023
You probably want this
https://github.com/naudio/NAudio/blob/master/Docs/PlayAudioFileConsoleApp.md
https://github.com/naudio/NAudio/blob/master/Docs/PlayAudioFileConsoleApp.md
GGato2/26/2023
thaths what i said
GGato2/26/2023
yes
Tthinker2272/26/2023
(that specific tutorial)
GGato2/26/2023
this i think will be perfect
GGato2/26/2023
thanks
GGato2/26/2023
ok let me try again the compile with single file
GGato2/26/2023
dotnet publish -c Debug -r win-x64 -p:PublishSingleFile=true
GGato2/26/2023
i have to run this every time oln cimpile?
Tthinker2272/26/2023
well, every time you want to publish your app
GGato2/26/2023
but just i want to compile in just one file
Tthinker2272/26/2023
ex. when you release a new version
Tthinker2272/26/2023
yeah,
dotnet publish -c Release -r <rid> --self-contained -p:PublishSingleFile=true
will publish your entire app into a single executable fileGGato2/26/2023
now i got another error
Tthinker2272/26/2023
--self-contained
GGato2/26/2023
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
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
GGato2/26/2023
oh nothing
GGato2/26/2023
im stupid
GGato2/26/2023
dotnet publish -c Debug -r win-x64 -p:PublishSingleFile=true --self-contained
GGato2/26/2023
wtf 147 MB of file
Tthinker2272/26/2023
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
Tthinker2272/26/2023
and that's just an inherent part of single-file executables
GGato2/26/2023
on framework and costura fody was 2 mb
GGato2/26/2023
....
GGato2/26/2023
a couple
GGato2/26/2023
i got this error

GGato2/26/2023
i cant start thath
GGato2/26/2023
on framework worked
Tthinker2272/26/2023
afaik you have to use the Powershell setting for
Process
to be able to start URLsGGato2/26/2023
what
Tthinker2272/26/2023
Process.Start(new ProcessStartInfo()
{
UseShellExecute = true,
FileName = "https://github.com/dotnet/roslyn"
});
GGato2/26/2023
process start doenst have use shell executed enabled by default?
Tthinker2272/26/2023
apparently not
GGato2/26/2023
but on framework yes
GGato2/26/2023
😭
Tthinker2272/26/2023
idk
Tthinker2272/26/2023
Framework is weird
GGato2/26/2023
there is no way to be packed as 1 file without packing whole net libraries
GGato2/26/2023
just the program dll and the nuget dependencyes
Tthinker2272/26/2023
well, .NET libraries are essentially the same as Nuget dependencies
Tthinker2272/26/2023
They're all just... DLLs
GGato2/26/2023
but