Thanks to visit codestin.com
Credit goes to github.com

Skip to content

langversion 6 is not recognized with msbuild or csc compiler in VS 2017 #539

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

Closed
den-run-ai opened this issue Sep 11, 2017 · 5 comments
Closed

Comments

@den-run-ai
Copy link
Contributor

CSC : error CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

Click to expand
python setup.py install
running install
running bdist_egg
running egg_info
writing pythonnet.egg-info\PKG-INFO
writing top-level names to pythonnet.egg-info\top_level.txt
writing dependency_links to pythonnet.egg-info\dependency_links.txt
reading manifest file 'pythonnet.egg-info\SOURCES.txt'
writing manifest file 'pythonnet.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.3.0.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '15.3.409.57025' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'.
All packages listed in packages.config are already installed.
Scanning for projects...
MSBuild auto-detection: using msbuild version '15.3.409.57025' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'.
Found 2 projects with a packages.config file. (clrmodule.csproj, Python.EmbeddingTest.csproj)
Feeds used:
  https://api.nuget.org/v3/index.json
  C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\



Attempting to gather dependency information for multiple packages with respect to project 'C:\Users\denis.akhiyarov\Downloads\pythonnet\src\clrmodule\clrmodule.csproj', targeting '.NETFramework,Version=v4.0'
Gathering dependency information took 694.65 ms
Attempting to resolve dependencies for multiple packages.
Resolving dependency information took 0 ms
Resolving actions install multiple packages
Resolution was successful but resulted in no action
There are no new updates available.
No package updates are available from the current package source for project 'C:\Users\denis.akhiyarov\Downloads\pythonnet\src\clrmodule\clrmodule.csproj'.
Executing nuget actions took 5.2 ms
Feeds used:
  https://api.nuget.org/v3/index.json
  C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\



Attempting to gather dependency information for multiple packages with respect to project 'C:\Users\denis.akhiyarov\Downloads\pythonnet\src\embed_tests\Python.EmbeddingTest.csproj', targeting '.NETFramework,Version=v4.0'
Gathering dependency information took 180.1 ms
Attempting to resolve dependencies for multiple packages.
Resolving dependency information took 0 ms
Resolving actions install multiple packages
Retrieving package 'NUnit 3.8.1' from 'nuget.org'.
Retrieving package 'NUnit.ConsoleRunner 3.7.0' from 'nuget.org'.
  GET https://api.nuget.org/v3-flatcontainer/nunit/3.8.1/nunit.3.8.1.nupkg
  GET https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.7.0/nunit.consolerunner.3.7.0.nupkg
Removed package 'NUnit.ConsoleRunner 3.6.0' from 'packages.config'
Successfully uninstalled 'NUnit.ConsoleRunner 3.6.0' from Python.EmbeddingTest.csproj
  OK https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.7.0/nunit.consolerunner.3.7.0.nupkg 52ms
Installing NUnit.ConsoleRunner 3.7.0.
Removed package 'NUnit 3.6.0' from 'packages.config'
Successfully uninstalled 'NUnit 3.6.0' from Python.EmbeddingTest.csproj
  OK https://api.nuget.org/v3-flatcontainer/nunit/3.8.1/nunit.3.8.1.nupkg 144ms
Installing NUnit 3.8.1.
Adding package 'NUnit.3.8.1' to folder 'C:\Users\denis.akhiyarov\Downloads\pythonnet\packages'
Added package 'NUnit.3.8.1' to folder 'C:\Users\denis.akhiyarov\Downloads\pythonnet\packages'
Added package 'NUnit.3.8.1' to 'packages.config'
Successfully installed 'NUnit 3.8.1' to Python.EmbeddingTest.csproj
Adding package 'NUnit.ConsoleRunner.3.7.0', which only has tools group, to project 'Python.EmbeddingTest.csproj'
Adding package 'NUnit.ConsoleRunner.3.7.0' to folder 'C:\Users\denis.akhiyarov\Downloads\pythonnet\packages'
Added package 'NUnit.ConsoleRunner.3.7.0' to folder 'C:\Users\denis.akhiyarov\Downloads\pythonnet\packages'
Added package 'NUnit.ConsoleRunner.3.7.0' to 'packages.config'
Successfully installed 'NUnit.ConsoleRunner 3.7.0' to Python.EmbeddingTest.csproj
Executing nuget actions took 1.61 sec
Microsoft (R) Manifest Tool version 10.0.10011.16384
Copyright (c) Microsoft Corporation 2012.
All rights reserved.
Microsoft (R) Build Engine version 4.7.2046.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) Build Engine version 4.7.2046.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

CSC : error CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default [C:\Users\denis.akhiy
arov\Downloads\pythonnet\src\runtime\Python.Runtime.csproj]
CSC : error CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default [C:\Users\denis.akhiy
arov\Downloads\pythonnet\src\clrmodule\clrmodule.csproj]
Traceback (most recent call last):
  File "setup.py", line 417, in <module>
    zip_safe=False,
  File "C:\Python\Python27-32\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Python\Python27-32\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python\Python27-32\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python\Python27-32\lib\site-packages\setuptools\command\install.py", line 67, in run
    self.do_egg_install()
  File "C:\Python\Python27-32\lib\site-packages\setuptools\command\install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "C:\Python\Python27-32\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python\Python27-32\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python\Python27-32\lib\site-packages\setuptools\command\bdist_egg.py", line 161, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "C:\Python\Python27-32\lib\site-packages\setuptools\command\bdist_egg.py", line 147, in call_command
    self.run_command(cmdname)
  File "C:\Python\Python27-32\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python\Python27-32\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python\Python27-32\lib\distutils\command\install_lib.py", line 92, in run
    self.build()
  File "C:\Python\Python27-32\lib\distutils\command\install_lib.py", line 111, in build
    self.run_command('build_ext')
  File "C:\Python\Python27-32\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python\Python27-32\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python\Python27-32\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "C:\Python\Python27-32\lib\distutils\command\build_ext.py", line 449, in build_extensions
    self.build_extension(ext)
  File "setup.py", line 225, in build_extension
    subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
  File "C:\Python\Python27-32\lib\subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" pythonnet.sln /p:Configuration=ReleaseWin /p:Platform=x86 /p:DefineConstants="PYTHON27%3BPYTHON2%3BUCS2" /p:PythonBuildDir="C:\Users\denis.akhiyarov\Downloads\pythonnet\build\lib.win32-2.7" /p:PythonInteropFile="interop27.cs" /verbosity:minimal /p:PythonManifest="C:\Users\denis.akhiyarov\Downloads\pythonnet\build\lib.win32-2.7\app.manifest" /t:Build' returned non-zero exit status 1
@den-run-ai
Copy link
Contributor Author

related #480 and #521

@dmitriyse
Copy link
Contributor

This is a common problem with old msbuild detection methods and VS 2017 installation.
Fix example is provided here https://github.com/jhaker/nodejs-msbuild/pull/19/files

@dmitriyse
Copy link
Contributor

But this is a trickly way. We can rely on a new MS supported tool: https://github.com/Microsoft/vswhere.
It should allow to find a valid msbuild by a specified minimal version:

basePathes = subprocess.check_output(
                ["vswhere", "-latest",
                 "-version", "[15.0, 16.0)", 
                 "-requires", "Microsoft.Component.MSBuild",
                 "-property", "InstallationPath"]).splitlines()

This code should do all the magic either for VS2017 msbuilds or old msbuild.
If we pass all tests with vswhere.exe we can remove all msbuild detection code from the setup.py.

@den-run-ai
Copy link
Contributor Author

@dmitriyse exactly! msbuild is not using registry keys anymore for some reason. That vswhere is a nice tool. One problem is that VS 2008 is not supported, but this is what is used for Python 2.7. microsoft/vswhere#89

In the meantime we can use vswhere for msbuild versions not in registry.

dmitriyse pushed a commit to dmitriyse/pythonnet that referenced this issue Sep 22, 2017
dmitriyse pushed a commit to dmitriyse/pythonnet that referenced this issue Sep 22, 2017
dmitriyse pushed a commit to dmitriyse/pythonnet that referenced this issue Sep 22, 2017
dmitriyse pushed a commit to dmitriyse/pythonnet that referenced this issue Sep 22, 2017
den-run-ai pushed a commit that referenced this issue Nov 7, 2017
…ssues. (#546)

* vswhere.exe tool now distributed with the pythonnet sources, dotnet-core-2.0-x86 installation step removed.

* .travis.yaml file simplification.

* PYTHONNET_INTEROP_FILE env var introduced to allow working with custom interop*.cs file inside IDE.

* pdb generation improved for all conditions Net 4.0/NetStandard 2.0 x Debug/Release.

* Fix for the #539 classic build fails when VS 2017 installed.

* Build fixes for the fresh Windows 10 SDKS.

* Workaround: Mono downgrade to 5.2.0 to avoid broken mono 5.4.0.201
@filmor
Copy link
Member

filmor commented Aug 30, 2018

I guess this is solved by @dmitriyse build improvements, feel free to reopen if it's not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants