Created
May 30, 2024 08:42
-
-
Save luoxufeiyan/b3c245ed461350235072f0ced85b17af to your computer and use it in GitHub Desktop.
递归地检查目录及其子目录中是否存在NuGet文件,并在找到NuGet文件时将其推送到指定的源中
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
def push_nuget_packages(directory, source): | |
for root, dirs, files in os.walk(directory): | |
for file in files: | |
if file.endswith(".nupkg"): | |
nuget_file_path = os.path.join(root, file) | |
command = f"dotnet nuget push {nuget_file_path} -s {source}" | |
try: | |
subprocess.run(command, check=True, shell=True) | |
print(f"Successfully pushed {nuget_file_path} to {source}") | |
except subprocess.CalledProcessError as e: | |
print(f"Failed to push {nuget_file_path}: {e}") | |
if __name__ == "__main__": | |
directory_to_check = "/path/to/your/directory" # 替换为你要检查的目录路径 | |
nuget_source = "mytest" # 替换为你的NuGet源 | |
push_nuget_packages(directory_to_check, nuget_source) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment