问题
I retargeted the class library 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:
Building on a Windows 10 machine with 2004 update.
Post-Build event :
@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
回答1:
Just keep these 2 folders shown in the image on the directory of the directory of CSCore.csproj. I've been gone through this problem. I solved this way. If you need any more clarification on that please let me know.
Now make sure that the project build order is like shown in the image.
来源:https://stackoverflow.com/questions/62227471/cannot-compile-cscore-after-retargeting-to-net-4-7-2