重新定位到.NET 4.7.2后无法编译CSCORE [英] Cannot compile CSCORE after retargeting to .NET 4.7.2

查看:78
本文介绍了重新定位到.NET 4.7.2后无法编译CSCORE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将类库重新定位为4.7.2,以便更新版本,并在其中使用 CSCORE 我正在构建的.NET Core 3.1应用程序.

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.

我无法编译,因为生成后事件返回-1:

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

在具有2004年更新的Windows 10计算机上构建.

Building on a Windows 10 machine with 2004 update.

构建后事件:

@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

推荐答案

CsCore编译使用了Post-Build脚本.其中包含对Microsoft SDK和Framework的引用:

The CsCore compilation used a Post-Build script. In it there is a reference to the Microsoft SDK and Framework:

set sdk=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools
set framework=%WINDIR%\Microsoft.NET\Framework\v2.0.50727

此sdk/framework的位置取决于Windows版本Windows 7或Windows 10.在Studio中,打开CsCore属性并编辑postbuild脚本(仅由于LF而不太可读):您将必须将SDK行更改为系统上的SDK.将ECHO OFF更改为ON,这样您会看到会发生什么.但这有效.

The location of this sdk/framework depends on the windows version Windows 7 or Windows 10. in Studio, open CsCore properties and edit the postbuild script (alas not very readable because of LF only): you will have to change the SDK line to the SDK on your system. Change the ECHO OFF in ON so you see what happens. But it works.

这篇关于重新定位到.NET 4.7.2后无法编译CSCORE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆