Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build using build.ps1 way #361

Closed
greenozon opened this issue Sep 18, 2024 · 6 comments
Closed

Can't build using build.ps1 way #361

greenozon opened this issue Sep 18, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@greenozon
Copy link

dnSpyEx version

6.5.1

Describe the Bug

according to readme step I"m trying to build the binaries
I"m using VS2022 17.11.4

How To Reproduce

inside powershell:

PS C:\Users\user\Downloads\dnSpy> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.1591
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.1591
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\Users\user\Downloads\dnSpy> .\build.ps1 netframework
Building .NET Framework x86 and x64 binaries
msbuild : The term 'msbuild' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\user\Downloads\dnSpy\build.ps1:28 char:3
+         msbuild -v:m -m -restore -t:Build -p:Configuration=$configura ...
+         ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (msbuild:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException



PS C:\Users\user\Downloads\dnSpy> dotnet --version
8.0.400

Expected Behavior

binaries got build without errors

Actual Behavior

can't find msbuild binary from VS

Additional Context

I didn't find the vcvars.bat file that I've used for ages to open up MSVS PATHs / etc

OS: Win11

@greenozon greenozon added the bug Something isn't working label Sep 18, 2024
@greenozon
Copy link
Author

greenozon commented Sep 19, 2024

Figured out the solution:

  1. read the article https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022
  2. open up powershell
  3. execute
 & "c:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Tools\Launch-VsDevShell.ps1"

Note: depending on your MS VS edition you might have different path!

  1. build the bits!
.\build.ps1 netframework

@greenozon
Copy link
Author

Another question on this issue:
why does the command

.\build.ps1 netframework

while asked to build only dotnet48 also builds .net8.0 artifacts?

@ElektroKill
Copy link
Member

The script is designed to run in a terminal session where msbuild and/or dotnet is in the path.

Building netframework builds both because it relies on some projects that target netstandard2.0 or net8.0 and if we specify a specific target framework, those won't be built.

@greenozon
Copy link
Author

the thing is that msbuild is not present (it was removed some time ago or so)
also do you really need netstandard2.0 in 2024/5? it was obsoleted long time ago AFAIK
.net6 will be dead in upcoming week (!) ..

image

@ElektroKill
Copy link
Member

.NET standard is used for some of the Rosyn packages since that is what Roslyn targets. dnSpy does some tricks to access Roslyn internals and if these files which do the tricks don't match exactly with runtime it can not work on some systems. There was an issue and PR to fix it a while back. .NET Standard is not a runtime so it being discontinued is not a big problem for now.

MSBuild is still part of VS and is the build pipeline used when you run dotnet build, it's just not present in path on most systems.
The script can build without msbuild with the -NoMsbuild flag.

Honestly, I'd like to kill .net framework at some point but it's not likely to happen since that's the only way we can ensure users on older operating systems can use dnSpy.

@greenozon
Copy link
Author

OK! makes sense
pardon I was having Linux in my mind, but you are right, on Windows msbuild should be definitely present
Feel free to close the ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants