Unverified Commit fc7c75fc authored by Guolin Ke's avatar Guolin Ke Committed by GitHub
Browse files

fix nuget (#1569)

* try to fix nuget

* add exe copy

* Update create_nuget.py

* Update .vsts-ci.yml

* add build folder

* fix build folder

* Update create_nuget.py

* Update create_nuget.py

* Update create_nuget.py

* Update create_nuget.py

* update version to test on nuget.org
parent 2db6377a
...@@ -16,9 +16,13 @@ if __name__ == "__main__": ...@@ -16,9 +16,13 @@ if __name__ == "__main__":
windows_folder_path = os.path.join(current_dir, "runtimes", "win-x64", "native") windows_folder_path = os.path.join(current_dir, "runtimes", "win-x64", "native")
if not os.path.exists(windows_folder_path): if not os.path.exists(windows_folder_path):
os.makedirs(windows_folder_path) os.makedirs(windows_folder_path)
build_folder_path = os.path.join(current_dir, "build")
if not os.path.exists(build_folder_path):
os.makedirs(build_folder_path)
copy_file(os.path.join(source, "lib_lightgbm.so"), os.path.join(linux_folder_path, "lib_lightgbm.so")) copy_file(os.path.join(source, "lib_lightgbm.so"), os.path.join(linux_folder_path, "lib_lightgbm.so"))
copy_file(os.path.join(source, "lib_lightgbm.dylib"), os.path.join(osx_folder_path, "lib_lightgbm.dylib")) copy_file(os.path.join(source, "lib_lightgbm.dylib"), os.path.join(osx_folder_path, "lib_lightgbm.dylib"))
copy_file(os.path.join(source, "lib_lightgbm.dll"), os.path.join(windows_folder_path, "lib_lightgbm.dll")) copy_file(os.path.join(source, "lib_lightgbm.dll"), os.path.join(windows_folder_path, "lib_lightgbm.dll"))
copy_file(os.path.join(source, "lightgbm.exe"), os.path.join(windows_folder_path, "lightgbm.exe"))
version = open(os.path.join(current_dir, os.path.pardir, 'VERSION.txt')).read().strip() version = open(os.path.join(current_dir, os.path.pardir, 'VERSION.txt')).read().strip()
nuget_str = '''<?xml version="1.0"?> nuget_str = '''<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
...@@ -36,9 +40,47 @@ if __name__ == "__main__": ...@@ -36,9 +40,47 @@ if __name__ == "__main__":
<dependencies> </dependencies> <dependencies> </dependencies>
</metadata> </metadata>
<files> <files>
<file src="build\**" target="build"/>
<file src="runtimes\**" target="runtimes"/> <file src="runtimes\**" target="runtimes"/>
</files> </files>
</package> </package>
''' % version ''' % version
prop_str = '''
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="Exists('packages.config') OR
Exists('$(MSBuildProjectName).packages.config') OR
Exists('packages.$(MSBuildProjectName).config')">
<Content Include="$(MSBuildThisFileDirectory)/../runtimes/win-x64/native/*.dll"
Condition="'$(PlatformTarget)' == 'x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)/../runtimes/win-x64/native/*.exe"
Condition="'$(PlatformTarget)' == 'x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
</ItemGroup>
</Project>
'''
target_str = '''
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<EnableLightGBMUnsupportedPlatformTargetCheck Condition="'$(EnableLightGBMUnsupportedPlatformTargetCheck)' == ''">true</EnableLightGBMUnsupportedPlatformTargetCheck>
</PropertyGroup>
<Target Name="_LightGBMCheckForUnsupportedPlatformTarget"
Condition="'$(EnableLightGBMUnsupportedPlatformTargetCheck)' == 'true'"
AfterTargets="_CheckForInvalidConfigurationAndPlatform">
<Error Condition="'$(PlatformTarget)' != 'x64' AND
('$(OutputType)' == 'Exe' OR '$(OutputType)'=='WinExe') AND
!('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(PlatformTarget)' == '')"
Text="LightGBM currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'." />
</Target>
</Project>
'''
with open(os.path.join(current_dir, "LightGBM.nuspec"), "w") as nuget_file: with open(os.path.join(current_dir, "LightGBM.nuspec"), "w") as nuget_file:
nuget_file.write(nuget_str) nuget_file.write(nuget_str)
with open(os.path.join(current_dir, "build", "LightGBM.props"), "w") as prop_file:
prop_file.write(prop_str)
with open(os.path.join(current_dir, "build", "LightGBM.targets"), "w") as target_file:
target_file.write(target_str)
...@@ -131,6 +131,7 @@ phases: ...@@ -131,6 +131,7 @@ phases:
cd .. cd ..
pytest tests/c_api_test/test_.py pytest tests/c_api_test/test_.py
cp Release/lib_lightgbm.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY cp Release/lib_lightgbm.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp Release/lightgbm.exe $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} }
elseif ("$env:TASK" -eq "sdist"){ elseif ("$env:TASK" -eq "sdist"){
cd python-package; python setup.py sdist --formats gztar cd python-package; python setup.py sdist --formats gztar
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment