filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.15k stars 451 forks source link

Build failed when updating .NET to 4.7.2 #417

Open e4rthdog opened 4 years ago

e4rthdog commented 4 years ago

I retargeted to 4.7.2 in order to be more recent and use CSCORE in a .NET Core 3.1 application that i am building.

I cant compile cause the post-build event returns -1:

On a Windows 10 2004 machine.

`@echo off & setLocal EnableDELAYedeXpansion chcp 65001

  set errorCode=0

  set target=$(TargetPath)
  set project=$(ProjectPath)

  set sdk=%PROGRAMFILES(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools
  set framework=%WINDIR%\Microsoft.NET\Framework\v2.0.50727
  set inlineILCompiler=$(SolutionDir)Tools\InlineILCompiler\InlineILCompiler\bin\$(ConfigurationName)\InlineILCompiler.exe
  set cscli=$(SolutionDir)Tools\CSCli\bin\$(ConfigurationName)\CSCli.exe

  IF exist "%sdk%\." (
  echo OK: The Microsoft Windows SDK was found.
  ) else (
  echo FAILED: The Microsoft Windows SDK Dir was not found. Check the following path: "%sdk%"
  goto EXIT_ERR
  )
  IF exist "%framework%\." (
  echo OK: The .NET Framework Dir was found.
  ) else (
  echo FAILED: The Framework-Dir was not found. Check the following path: "%framework%"
  goto EXIT_ERR
  )
  IF exist "%inlineILCompiler%" (
  echo OK: Found the inline-il-compiler.
  ) else (
  echo FAILED: The inline-il-compiler was not found. Check the following path: "%inlineILCompiler%"
  goto EXIT_ERR
  )
  IF exist "%cscli%" (
  echo OK: Found the cscli-compiler.
  ) else (
  echo FAILED: The cscli was not found. Check the following path: "%cscli%"
  goto EXIT_ERR
  )

  if $(ConfigurationName) == Debug (
  echo Build-Configuration: DEBUG
  echo    DEBUG=IMPL
  echo    NO OPTIMIZE
  set ilasm_args=/DLL /DEBUG=IMPL
  ) else (
  if $(ConfigurationName) == Release (
  echo Build-Configuration: RELEASE
  echo    NO DEBUG
  echo    OPTIMIZE
  set ilasm_args=/DLL /OPTIMIZE
  ) else (
  echo FAILED: Invalid Configuration.
  goto EXIT_ERR
  )
  )

  echo.
  echo.
  echo Calling the inline-il-compiler ...
  call "%inlineILCompiler%"

  echo.
  echo.
  echo Calling CSCli ...
  call "%cscli%" -file:"$(TargetPath)" -r:"RemoveObjAttribute" -c:"CSCalliAttribute"

  :EXIT
  EXIT /B %errorCode%

  :EXIT_ERR
  set errorCode=-1
  goto EXIT

`

priowrea commented 4 years ago

This batch script ist part of the post build event in the project file. You have to edit it and correct the pathes for sdk etc.

e.g The Windows 10 netfx sdk folder would be: set sdk=%PROGRAMFILES(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools

Furthermore you can change the inlineILCompiler and cscli path by using $(ProjectDir) instead of SolutionDir, and $(OutDir) instead of the bin\$(ConfigurationName), because netCore3.1 has another output directory e.g.: set inlineILCompiler=$(ProjectDir)..\Tools\InlineILCompiler\$(OutDir)InlineILCompiler.exe set cscli=$(ProjectDir)..\Tools\CSCli\$(OutDir)CSCli.exe

This fixes it for me.