|
3 | 3 | import contextlib |
4 | 4 | import os.path |
5 | 5 | import re |
| 6 | +import tempfile |
6 | 7 | import xml.etree.ElementTree |
7 | 8 | import zipfile |
8 | 9 | from typing import Generator |
@@ -38,6 +39,22 @@ def in_env(prefix: Prefix) -> Generator[None, None, None]: |
38 | 39 | yield |
39 | 40 |
|
40 | 41 |
|
| 42 | +@contextlib.contextmanager |
| 43 | +def _nuget_config_no_sources() -> Generator[str, None, None]: |
| 44 | + with tempfile.TemporaryDirectory() as tmpdir: |
| 45 | + nuget_config = os.path.join(tmpdir, 'nuget.config') |
| 46 | + with open(nuget_config, 'w') as f: |
| 47 | + f.write( |
| 48 | + '<?xml version="1.0" encoding="utf-8"?>' |
| 49 | + '<configuration>' |
| 50 | + ' <packageSources>' |
| 51 | + ' <clear />' |
| 52 | + ' </packageSources>' |
| 53 | + '</configuration>', |
| 54 | + ) |
| 55 | + yield nuget_config |
| 56 | + |
| 57 | + |
41 | 58 | def install_environment( |
42 | 59 | prefix: Prefix, |
43 | 60 | version: str, |
@@ -85,15 +102,17 @@ def install_environment( |
85 | 102 | raise AssertionError('"id" element missing tool name') |
86 | 103 |
|
87 | 104 | # Install to bin dir |
88 | | - helpers.run_setup_cmd( |
89 | | - prefix, |
90 | | - ( |
91 | | - 'dotnet', 'tool', 'install', |
92 | | - '--tool-path', os.path.join(envdir, BIN_DIR), |
93 | | - '--add-source', build_dir, |
94 | | - tool_id, |
95 | | - ), |
96 | | - ) |
| 105 | + with _nuget_config_no_sources() as nuget_config: |
| 106 | + helpers.run_setup_cmd( |
| 107 | + prefix, |
| 108 | + ( |
| 109 | + 'dotnet', 'tool', 'install', |
| 110 | + '--configfile', nuget_config, |
| 111 | + '--tool-path', os.path.join(envdir, BIN_DIR), |
| 112 | + '--add-source', build_dir, |
| 113 | + tool_id, |
| 114 | + ), |
| 115 | + ) |
97 | 116 |
|
98 | 117 | # Clean the git dir, ignoring the environment dir |
99 | 118 | clean_cmd = ('git', 'clean', '-ffxd', '-e', f'{ENVIRONMENT_DIR}-*') |
|
0 commit comments