8422 references to File
aspire (490)
Acquisition\InstallationCandidateSources.cs (2)
61if (File.Exists(releaseBinary)) 94if (File.Exists(binary))
Acquisition\InstallSidecarReader.cs (3)
52if (!File.Exists(sidecarPath)) 100if (!File.Exists(sidecarPath)) 156using var stream = File.OpenRead(sidecarPath);
Acquisition\InstallSidecarWriter.cs (7)
30if (!File.Exists(sidecarPath)) 74if (File.Exists(temporaryPath)) 76File.Delete(temporaryPath); 92using var stream = File.OpenRead(sidecarPath); 121File.Move(_temporaryPath, sidecarPath, overwrite: true); 127if (_temporaryPath is not null && File.Exists(_temporaryPath)) 129File.Delete(_temporaryPath);
Acquisition\PeerInstallProbe.cs (1)
69if (string.IsNullOrEmpty(binaryPath) || !File.Exists(binaryPath))
Acquisition\WingetFirstRunProbe.cs (4)
42if (File.Exists(sidecarPath)) 67File.WriteAllBytes(tempPath, s_wingetSidecarContent); 77File.Move(tempPath, sidecarPath, overwrite: false); 96File.Delete(tempPath);
Agents\AspireSkills\AspireSkillsBundleProvider.cs (10)
120if (!File.Exists(manifestPath)) 128await using var manifestStream = File.OpenRead(manifestPath); 280if (!File.Exists(fullPath)) 287var bytes = File.ReadAllBytes(fullPath); 455using var stream = File.OpenRead(archivePath); 484using var fileStream = File.OpenRead(tarballPath); 578if (File.Exists(rootManifestPath)) 585if (File.Exists(packageManifestPath)) 592.Where(directory => File.Exists(Path.Combine(directory, ManifestFileName))) 622File.Copy(sourceFile, targetFile, overwrite: true);
Agents\AspireSkills\AspireSkillsInstaller.cs (24)
538await using var fileStream = File.Create(archivePath); 670!File.Exists(Path.Combine(cacheDirectory, GitHubAttestationVerifiedFileName))) 681var cachedArchiveSha512 = File.Exists(cachedArchiveSha512Path) 682? TryNormalizeArchiveSha512(File.ReadAllText(cachedArchiveSha512Path).Trim()) 694var cachedGitHubArchiveSha256 = File.Exists(cachedGitHubArchiveSha256Path) 695? TryNormalizeArchiveSha256(File.ReadAllText(cachedGitHubArchiveSha256Path).Trim()) 765await File.WriteAllTextAsync( 774await File.WriteAllTextAsync( 782await File.WriteAllTextAsync( 827File.Delete(Path.Combine(bundleDirectory, ArchiveSha512FileName)); 828File.Delete(Path.Combine(bundleDirectory, GitHubArchiveSha256FileName)); 829File.Delete(Path.Combine(bundleDirectory, GitHubAttestationVerifiedFileName)); 830File.Delete(Path.Combine(bundleDirectory, LastUsedFileName)); 934using var stream = File.OpenRead(archivePath); 940using var stream = File.OpenRead(archivePath); 1068File.Exists(Path.Combine(versionCacheDirectory, "skill-manifest.json")) || 1069File.Exists(Path.Combine(versionCacheDirectory, ArchiveSha512FileName)) || 1070File.Exists(Path.Combine(versionCacheDirectory, GitHubArchiveSha256FileName)) || 1071File.Exists(Path.Combine(versionCacheDirectory, GitHubAttestationVerifiedFileName)) || 1072File.Exists(Path.Combine(versionCacheDirectory, LastUsedFileName)); 1109File.WriteAllText(Path.Combine(directory, LastUsedFileName), DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture)); 1120if (File.Exists(markerPath) && 1121long.TryParse(File.ReadAllText(markerPath), NumberStyles.Integer, CultureInfo.InvariantCulture, out var unixTime) && 1161File.Delete(path);
Agents\AspireSkills\EmbeddedAspireSkillsBundleProvider.cs (1)
81await using (var fileStream = File.Create(archivePath))
Agents\AspireSkills\GitHubArtifactAttestationVerifier.cs (1)
188using var stream = File.OpenRead(artifactPath);
Agents\ClaudeCode\ClaudeCodeAgentEnvironmentScanner.cs (3)
157if (!File.Exists(configFilePath)) 164var content = File.ReadAllText(configFilePath); 223await File.WriteAllTextAsync(configFilePath, jsonContent, cancellationToken);
Agents\CopilotCli\CopilotCliAgentEnvironmentScanner.cs (3)
144if (!File.Exists(configFilePath)) 151var content = File.ReadAllText(configFilePath); 229await File.WriteAllTextAsync(configFilePath, jsonContent, cancellationToken);
Agents\DeprecatedMcpCommandScanner.cs (13)
46File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] Scanning context.RepositoryRoot: {context.RepositoryRoot.FullName}\n"); 51File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] Checking {location.AgentName}: {configPath}\n"); 53if (!File.Exists(configPath)) 55File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> File does not exist\n"); 59File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> File EXISTS!\n"); 63var content = File.ReadAllText(configPath); 64File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> Content: {content.Substring(0, Math.Min(200, content.Length))}\n"); 69File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> JSON parse returned null\n"); 74File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> HasDeprecatedMcpCommand: {hasDeprecated}\n"); 83File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> Added applicator\n"); 88File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> JsonException: {ex.Message}\n"); 93File.AppendAllText(debugPath, $"[{DateTime.UtcNow:O}] -> IOException: {ex.Message}\n"); 214await File.WriteAllTextAsync(configPath, jsonContent, cancellationToken);
Agents\Hooks\TelemetryHookConfigurator.cs (4)
159if (File.Exists(settingsPath)) 164content = await File.ReadAllTextAsync(settingsPath, cancellationToken); 386await File.WriteAllTextAsync(tempPath, json, cancellationToken); 387File.Move(tempPath, path, overwrite: true);
Agents\Hooks\TelemetryHookInstaller.cs (6)
75if (File.Exists(path)) 79var existing = await File.ReadAllTextAsync(path, s_utf8NoBom, cancellationToken); 94await File.WriteAllTextAsync(tempPath, content, s_utf8NoBom, cancellationToken); 95File.Move(tempPath, path, overwrite: true); 107var mode = File.GetUnixFileMode(path); 108File.SetUnixFileMode(path, mode | UnixFileMode.UserExecute | UnixFileMode.GroupExecute | UnixFileMode.OtherExecute);
Agents\McpConfigFileHelper.cs (4)
26if (!File.Exists(configFilePath)) 33var content = File.ReadAllText(configFilePath); 70if (!File.Exists(configFilePath)) 75var content = await File.ReadAllTextAsync(configFilePath, cancellationToken);
Agents\OpenCode\OpenCodeAgentEnvironmentScanner.cs (3)
50var configFileExists = File.Exists(configFilePath); 109var content = File.ReadAllText(configFilePath); 215await File.WriteAllTextAsync(configFilePath, jsonOutput, cancellationToken);
Agents\Playwright\PlaywrightCliInstaller.cs (4)
435File.Copy(sourceFile, targetFile, overwrite: true); 446if (!File.Exists(sourceFile)) 448File.Delete(targetFile); 469using var stream = File.OpenRead(filePath);
Agents\VsCode\VsCodeAgentEnvironmentScanner.cs (3)
196if (!File.Exists(mcpConfigPath)) 203var content = File.ReadAllText(mcpConfigPath); 269await File.WriteAllTextAsync(mcpConfigPath, jsonContent, cancellationToken);
Backchannel\AppHostCliBackchannel.cs (1)
582var data = await File.ReadAllBytesAsync(filePath, cancellationToken).ConfigureAwait(false);
Backchannel\AuxiliaryBackchannelMonitor.cs (1)
405File.Delete(socketPath);
Bundles\BundleService.cs (9)
601if (!Directory.Exists(managedDir) || !File.Exists(managedExe)) 621if (!Directory.Exists(dcpDir) || !File.Exists(dcpExe)) 837File.WriteAllText(markerPath, version); 847if (!File.Exists(markerPath)) 852var content = File.ReadAllText(markerPath).Trim(); 918File.SetUnixFileMode(fullPath, (UnixFileMode)entry.Mode); 939if (File.Exists(fullPath)) 941File.Delete(fullPath); 943File.CreateSymbolicLink(fullPath, entry.LinkName);
Caching\AppHostInfoDiskCache.cs (5)
140if (!File.Exists(path)) 146var json = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false); 220await File.WriteAllTextAsync(tempPath, payload, cancellationToken).ConfigureAwait(false); 225File.Move(tempPath, path, overwrite: true); 243File.Delete(tempPath);
Caching\DiskCache.cs (5)
69return await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false); 108await File.WriteAllTextAsync(tempFile, content, cancellationToken).ConfigureAwait(false); 110if (File.Exists(fullPath)) 114File.Delete(fullPath); 122File.Move(tempFile, fullPath);
Certificates\CertificateCacheWriter.cs (4)
48File.Move(temporaryPath, outputPath); 50catch (IOException) when (File.Exists(outputPath)) 59File.Delete(temporaryPath); 78File.SetUnixFileMode(directory, DirectoryPermissions);
Certificates\CertificateGeneration\CertificateManager.cs (5)
538if (!File.Exists(certificatePath)) 746File.Move(tempFilename, path, overwrite: true); 749File.WriteAllBytes(path, bytes); 774File.Move(tempFilename, keyPath, overwrite: true); 777File.WriteAllBytes(keyPath, pemEnvelope);
Certificates\CertificateGeneration\MacOSCertificateManager.cs (10)
130File.Delete(tmpFile); 143return File.Exists(GetCertificateFilePath(candidate)) ? 190File.Delete(tmpFile); 222File.WriteAllBytes(certificatePath, certBytes); 243File.Delete(certificatePath); 351File.WriteAllBytes(certificatePath, certBytes); 392if (!File.Exists(onDiskPfxPath)) 417File.WriteAllBytes(keyPath, Encoding.UTF8.GetBytes(pem)); 515if (File.Exists(certificatePath)) 517File.Delete(certificatePath);
Certificates\CertificateGeneration\UnixCertificateManager.cs (8)
130if (File.Exists(certPath)) 271if (File.Exists(certPath)) 497if (File.Exists(certPath)) 648if (File.Exists(WslInteropPath) || File.Exists(WslInteropLatePath)) 819File.Delete(certPath); 1048if (!File.Exists(linkPath)) 1051File.CreateSymbolicLink(linkPath, cert.Name);
Certificates\NativeCertificateToolRunner.cs (1)
249if (File.Exists(outputPath))
Commands\AddCommand.cs (1)
341if (!File.Exists(nugetConfigPath))
Commands\AgentInitCommand.cs (3)
725if (File.Exists(fullPath)) 727var existingContent = await File.ReadAllTextAsync(fullPath, cancellationToken); 734await File.WriteAllTextAsync(fullPath, skillFile.Content, cancellationToken);
Commands\AppHostLauncher.cs (4)
981if (maxLines <= 0 || !File.Exists(childLogFile)) 990using var reader = File.OpenText(childLogFile); 1047if (maxLines <= 0 || !File.Exists(childLogFile)) 1053using var reader = File.OpenText(childLogFile);
Commands\DashboardRunCommand.cs (1)
112if (managedPath is null || !File.Exists(managedPath))
Commands\DcpWorkloadCleanupService.cs (1)
35if (!File.Exists(dcpPath))
Commands\InitCommand.cs (9)
276if (File.Exists(appHostPath)) 300File.WriteAllText(appHostPath, appHostContent); 488.FirstOrDefault(pattern => File.Exists(Path.Combine(workingDirectory.FullName, pattern))); 497if (File.Exists(appHostPath)) 538if (File.Exists(configPath)) 541var existingContent = File.ReadAllText(configPath); 647File.WriteAllText(configPath, JsonSerializer.Serialize(settings, JsonSourceGenerationContext.RelaxedEscaping.JsonObject)); 794if (File.Exists(path)) 841File.WriteAllText(path, JsonSerializer.Serialize(settings, JsonSourceGenerationContext.RelaxedEscaping.JsonObject));
Commands\PipelineCommandBase.cs (1)
1248if (!File.Exists(fullPath))
Commands\RenderCommand.cs (1)
446await File.WriteAllTextAsync(filePath, "This file is used to smoke test SafeFileLink rendering.", cancellationToken).ConfigureAwait(false);
Commands\Sdk\SdkDumpCommand.cs (2)
232await File.WriteAllTextAsync(outputFile.FullName, output, cancellationToken); 361await File.WriteAllTextAsync(outputPath, output, cancellationToken);
Commands\Sdk\SdkGenerateCommand.cs (1)
187await File.WriteAllTextAsync(filePath, content, cancellationToken);
Commands\UpdateCommand.cs (10)
784if (!File.Exists(newExePath)) 800if (File.Exists(targetExePath)) 808File.Move(targetExePath, backupPath); 815File.Copy(newExePath, targetExePath, overwrite: true); 856if (backupPath is not null && File.Exists(backupPath)) 858if (File.Exists(targetExePath)) 860File.Delete(targetExePath); 862File.Move(backupPath, targetExePath); 904var mode = File.GetUnixFileMode(filePath); 906File.SetUnixFileMode(filePath, mode);
Configuration\AspireConfigFile.cs (6)
133if (!File.Exists(filePath)) 140var json = File.ReadAllText(filePath); 161File.WriteAllText(filePath, json); 233if (!File.Exists(apphostRunPath)) 238var json = File.ReadAllText(apphostRunPath); 393return File.Exists(Path.Combine(directory, FileName));
Configuration\AspireJsonConfiguration.cs (3)
100if (!File.Exists(filePath)) 105var json = File.ReadAllText(filePath); 141File.WriteAllText(filePath, json);
Configuration\ConfigurationService.cs (13)
33if (File.Exists(settingsFilePath)) 35var existingContent = await File.ReadAllTextAsync(settingsFilePath, cancellationToken); 56if (!File.Exists(settingsFilePath)) 63var existingContent = await File.ReadAllTextAsync(settingsFilePath, cancellationToken); 115if (File.Exists(newSettingsPath)) 125if (File.Exists(legacySettingsPath)) 150if (!File.Exists(aspireConfigPath)) 189var content = await File.ReadAllTextAsync(filePath, cancellationToken); 387else if (File.Exists(configFilePath) && !continueSearchWhenKeyMissing) 397else if (File.Exists(legacySettingsPath) && !continueSearchWhenKeyMissing) 411if (File.Exists(globalSettingsFile.FullName)) 428if (!File.Exists(settingsFilePath)) 455content = File.ReadAllText(filePath);
Diagnostics\StartupErrorWriter.cs (1)
61if (!_hasOutput || !File.Exists(_logFilePath))
Documentation\FileBackedDocumentContentCache.cs (10)
190if (!File.Exists(filePath)) 196await using var stream = File.OpenRead(filePath); 238await using (var stream = File.Create(tempPath)) 243File.Move(tempPath, filePath, overwrite: true); 276if (!File.Exists(filePath)) 281return await File.ReadAllTextAsync(filePath, cancellationToken).ConfigureAwait(false); 297await File.WriteAllTextAsync(tempPath, content, cancellationToken).ConfigureAwait(false); 298File.Move(tempPath, filePath, overwrite: true); 328if (File.Exists(filePath)) 330File.Delete(filePath);
DotNet\DotNetCliRunner.cs (5)
653if (!File.Exists(cliAssemblyPath)) 667return File.Exists(Path.Combine(cliDirectory, ".aspire-install.json")); 1186if (File.Exists(sourcePath) && string.Equals(Path.GetExtension(sourcePath), ".nupkg", StringComparison.OrdinalIgnoreCase)) 1420if (!File.Exists(filePath)) 1428using var stream = File.OpenRead(filePath);
Git\GitWorktree.cs (5)
70if (File.Exists(gitPath)) 154if (File.Exists(gitPath)) 241File.Exists(checkoutGitFile) && 310contents = File.ReadAllText(filePath); 374if (!File.Exists(candidate) && !Directory.Exists(candidate))
Layout\LayoutDiscovery.cs (10)
263_logger.LogDebug(" {Dir}/{Managed}/{Exe}: {Exists}", BundleDiscovery.BundleDirectoryName, BundleDiscovery.ManagedDirectoryName, managedExeName, File.Exists(bundleManagedExe) ? "exists" : "MISSING"); 264_logger.LogDebug(" {Dir}/{Dcp}/{Exe}: {Exists}", BundleDiscovery.BundleDirectoryName, BundleDiscovery.DcpDirectoryName, Path.GetFileName(bundleDcpExe), File.Exists(bundleDcpExe) ? "exists" : "MISSING"); 266if (File.Exists(bundleManagedExe) && File.Exists(bundleDcpExe)) 297_logger.LogDebug(" managed/{ManagedExe}: {Exists}", managedExeName, File.Exists(managedExePath) ? "exists" : "MISSING"); 298_logger.LogDebug(" dcp/{DcpExe}: {Exists}", Path.GetFileName(dcpExePath), File.Exists(dcpExePath) ? "exists" : "MISSING"); 300if (!File.Exists(managedExePath) || !File.Exists(dcpExePath)) 337if (managedPath is null || !File.Exists(managedPath)) 347!File.Exists(BundleDiscovery.GetDcpExecutablePath(dcpPath)))
Migrations\TypeScriptAppHostMigration.cs (14)
161var modernAppHostContent = LegacyTypeScriptAppHost.RewriteAppHostContent(File.ReadAllText(legacyAppHostFile.FullName)); 178File.WriteAllText(modernAppHostFile.FullName, modernAppHostContent); 193if (!File.Exists(configPath)) 200if (JsonNode.Parse(File.ReadAllText(configPath)) is not JsonObject root || 221File.WriteAllText(configPath, root.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 232if (!File.Exists(tsConfigPath)) 242File.ReadAllText(tsConfigPath), 269File.WriteAllText(tsConfigPath, root.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 280if (!File.Exists(packageJsonPath)) 287if (JsonNode.Parse(File.ReadAllText(packageJsonPath)) is not JsonObject root || 311File.WriteAllText(packageJsonPath, root.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 325if (!File.Exists(configPath)) 330var current = File.ReadAllText(configPath); 334File.WriteAllText(configPath, rewritten);
Npm\NpmRunner.cs (1)
120if (!File.Exists(tarballPath))
NuGet\BundleNuGetPackageCache.cs (1)
148if (managedPath is null || !File.Exists(managedPath))
NuGet\BundleNuGetService.cs (2)
91if (managedPath is null || !File.Exists(managedPath)) 118if (File.Exists(manifestPath) && TryValidatePackageManifest(manifestPath, _logger))
Packaging\NuGetConfigMerger.cs (1)
112File.Copy(tmpConfig.ConfigFile.FullName, targetPath, overwrite: true);
Packaging\TemporaryNuGetConfig.cs (1)
147await File.WriteAllTextAsync(configFile.FullName, content);
Processes\DcpExecutableResolver.cs (1)
37if (!File.Exists(dcpPath))
Profiling\ProfileCaptureService.cs (5)
76if (managedPath is null || !File.Exists(managedPath)) 173File.Exists(dashboardPath)) 182if (File.Exists(managedPath)) 188if (File.Exists(managedExecutable)) 215return File.Exists(managedPath) ? managedPath : null;
Program.cs (3)
175if (!File.Exists(newPath) && File.Exists(legacyPath)) 179var legacyJson = File.ReadAllText(legacyPath);
Projects\AppHostCandidateFinder.cs (1)
207if (!File.Exists(absolutePath))
Projects\AppHostServerClosureSnapshots.cs (7)
118if (!File.Exists(normalizedSourcePath)) 261using var stream = File.OpenRead(path); 384!File.Exists(manifestPath)) 438File.Copy(entry.SourcePath, destinationPath, overwrite: false); 488if (!File.ReadLines(manifestPath).SequenceEqual(expectedManifest.GetProjectLayoutManifestLines(), StringComparer.Ordinal)) 496if (!File.Exists(copiedPath) || 528await File.WriteAllLinesAsync(path, manifest.GetProjectLayoutManifestLines(), cancellationToken).ConfigureAwait(false);
Projects\AppHostServerProject.cs (1)
62if (layout is not null && layout.GetManagedPath() is string serverPath && File.Exists(serverPath))
Projects\DotNetAppHostProject.cs (11)
300if (!File.Exists(filePath)) 728if (!File.Exists(filePath)) 1896if (!File.Exists(resolvedTargetPath)) 1906if (!File.Exists(runtimeConfigPath)) 1920if (!File.Exists(resolvedRunCommand)) 2065if (File.Exists(propertiesLaunchSettingsPath)) 2072if (File.Exists(runJsonPath)) 2088using var stream = File.OpenRead(launchSettingsPath); 2202if (File.Exists(runJsonFilePath)) 2625File.Exists(BundleDiscovery.GetDcpExecutablePath(path)); 2628=> !string.IsNullOrWhiteSpace(path) && File.Exists(path);
Projects\DotNetBasedAppHostServerProject.cs (18)
113if (File.Exists(hashFilePath)) 115return File.ReadAllText(hashFilePath); 124File.WriteAllText(hashFilePath, hash); 195if (File.Exists(projectPath) && addedProjects.Add(integration.Name)) 214if (File.Exists(hostingPath) && addedProjects.Add("Aspire.Hosting")) 238if (File.Exists(appHostInTargets)) 242if (File.Exists(sdkInTargets)) 249if (File.Exists(dashboardProject)) 256if (File.Exists(remoteHostProject)) 282File.WriteAllText(Path.Combine(_projectModelPath, "Program.cs"), programCs); 322? File.ReadAllText(userNugetConfig) 464if (!File.Exists(Path.Combine(_projectModelPath, fileName))) 473if (!File.Exists(Path.Combine(_projectModelPath, "obj", "project.assets.json"))) 506File.WriteAllText(Path.Combine(_projectModelPath, fileName), content); 516if (File.Exists(staleNugetConfig)) 518File.Delete(staleNugetConfig); 756if (File.Exists(configPath)) 803if (!File.Exists(versionsPropsPath))
Projects\FallbackProjectParser.cs (1)
99var fileContent = File.ReadAllText(projectFile.FullName);
Projects\GeneratedFileWriter.cs (3)
31if (File.Exists(path)) 35var existing = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false); 46await File.WriteAllTextAsync(path, content, cancellationToken).ConfigureAwait(false);
Projects\GuestAppHostProject.cs (12)
927var configPath = File.Exists(apphostRunPath) ? apphostRunPath : launchSettingsPath; 929if (!File.Exists(configPath)) 938var json = File.ReadAllText(configPath); 1717await File.WriteAllTextAsync(filePath, content, cancellationToken); 1933if (File.Exists(manifestPath)) 1937foreach (var line in await File.ReadAllLinesAsync(manifestPath, cancellationToken).ConfigureAwait(false)) 1957await File.WriteAllLinesAsync(manifestPath, current.Order(StringComparer.Ordinal), cancellationToken).ConfigureAwait(false); 1990File.Delete(fullPath); 2005File.WriteAllText(hashPath, hash); 2248var devCertificateContents = await File.ReadAllBytesAsync(devCertPemPath, cancellationToken); 2249var existingBundleContents = await File.ReadAllBytesAsync(existingBundlePath, cancellationToken); 2262if (!File.Exists(bundlePath))
Projects\GuestRuntime.cs (7)
327if (File.Exists(path)) 333if (File.GetLastWriteTimeUtc(path) > stampWriteTime) 371if (MatchesExtension(check, file) && File.GetLastWriteTimeUtc(file) > stampWriteTime) 406if (File.GetLastWriteTimeUtc(file) > stampWriteTime) 521File.WriteAllBytes(stampFile.FullName, []); 589if (!File.Exists(filePath)) 592await File.WriteAllTextAsync(filePath, content, cancellationToken);
Projects\ILanguageDiscovery.cs (1)
97/// <see cref="File.Exists"/> call.
Projects\JavaAppHostToolchainResolver.cs (11)
131if (File.Exists(Path.Combine(candidate.FullName, MavenPomFileName))) 138if (File.Exists(Path.Combine(candidate.FullName, gradleBuildFileName))) 194if (File.Exists(candidate) 205if (Directory.Exists(gitPath) || File.Exists(gitPath)) 221JavaAppHostToolchain.Gradle => File.Exists(Path.Combine(directory, GradleSettingsFileName)) 222|| File.Exists(Path.Combine(directory, GradleKotlinSettingsFileName)), 225JavaAppHostToolchain.Maven => File.Exists(Path.Combine(directory, MavenPomFileName)), 257return (File.GetUnixFileMode(path) & UnixFileMode.OtherWrite) != 0; 417await File.WriteAllTextAsync(temporaryPath, GradleInitScript, cancellationToken).ConfigureAwait(false); 418File.Move(temporaryPath, scriptPath, overwrite: true); 424File.Delete(temporaryPath);
Projects\LegacyTypeScriptAppHost.cs (2)
41return File.Exists(Path.Combine(appPath, LegacyAppHostFileName)) && 42!File.Exists(Path.Combine(appPath, ModernAppHostFileName));
Projects\PrebuiltAppHostServer.cs (19)
135if (managedPath is null || !File.Exists(managedPath)) 413if (!File.Exists(projectPath)) 418var projectBytes = await File.ReadAllBytesAsync(projectPath, cancellationToken).ConfigureAwait(false); 431var importBytes = await File.ReadAllBytesAsync(importPath, cancellationToken).ConfigureAwait(false); 474if (!File.Exists(projectPath)) 482using var stream = File.OpenRead(projectPath); 547if (File.Exists(candidate)) 624if (!File.Exists(assetsPath) || !File.Exists(stampPath)) 631return string.Equals(File.ReadAllText(stampPath), expectedFingerprint, StringComparison.Ordinal); 649await File.WriteAllTextAsync(Path.Combine(objDir, RestoreStampFileName), fingerprint, cancellationToken).ConfigureAwait(false); 856await File.WriteAllLinesAsync( 1542if (!File.Exists(filePath)) 1548var lines = await File.ReadAllLinesAsync(filePath, cancellationToken); 1554if (!File.Exists(filePath)) 1559var lines = await File.ReadAllLinesAsync(filePath, cancellationToken).ConfigureAwait(false); 1587if (!File.Exists(assetsFilePath)) 1592await using var stream = File.OpenRead(assetsFilePath); 1709await File.WriteAllTextAsync(
Projects\ProjectLocator.cs (2)
992else if (File.Exists(projectFile.FullName)) 1254if (shouldPreserveExistingDefault && File.Exists(resolvedPath))
Projects\ProjectUpdater.cs (6)
870var fileContent = await File.ReadAllTextAsync(projectFile.FullName); 892await File.WriteAllTextAsync(projectFile.FullName, updatedContent); 909var fileContent = File.ReadAllText(projectFile.FullName); 922var fileContent = await File.ReadAllTextAsync(projectFile.FullName); 927await File.WriteAllTextAsync(projectFile.FullName, updatedContent); 1034if (File.Exists(directoryPackagesPropsPath))
Projects\TypeScriptAppHostToolchainResolver.cs (9)
59if (File.Exists(Path.Combine(candidateDirectory.FullName, BunLockFileName))) 64if (File.Exists(Path.Combine(candidateDirectory.FullName, BunBinaryLockFileName))) 69if (File.Exists(Path.Combine(candidateDirectory.FullName, PnpmLockFileName))) 75if (File.Exists(yarnLockFilePath)) 85if (File.Exists(Path.Combine(candidateDirectory.FullName, YarnConfigFileName))) 90if (File.Exists(Path.Combine(candidateDirectory.FullName, PackageLockFileName))) 303if (!File.Exists(packageJsonPath)) 310var packageJson = JsonNode.Parse(File.ReadAllText(packageJsonPath), documentOptions: ConfigurationHelper.ParseOptions) as JsonObject; 381foreach (var line in File.ReadLines(yarnLockFilePath))
Scaffolding\ScaffoldingService.cs (15)
192if (fileName.Equals(PackageJsonFileName, StringComparison.OrdinalIgnoreCase) && File.Exists(filePath)) 194var existingContent = await File.ReadAllTextAsync(filePath, cancellationToken); 201else if (IsGitIgnoreFile(fileName) && File.Exists(filePath)) 203var existingContent = await File.ReadAllTextAsync(filePath, cancellationToken); 206else if (IsVsCodeSettingsFile(fileName) && File.Exists(filePath)) 208var existingContent = await File.ReadAllTextAsync(filePath, cancellationToken); 212await File.WriteAllTextAsync(filePath, contentToWrite, cancellationToken); 245if (profiles is not null && File.Exists(appHostRunPath)) 250File.Delete(appHostRunPath); 268if (IsTypeScriptLanguage(language) && File.Exists(Path.Combine(directory.FullName, PackageJsonFileName))) 295var existingContent = await File.ReadAllTextAsync(packageJsonPath, cancellationToken); 322await File.WriteAllTextAsync(packageJsonPath, serializedPackageJson, cancellationToken); 496await File.WriteAllTextAsync(filePath, content, cancellationToken); 509!File.Exists(Path.Combine(directory.FullName, PackageJsonFileName)) || 550if (File.Exists(filePath) || Directory.Exists(filePath))
src\Shared\BackchannelConstants.cs (1)
470File.Delete(socketPath);
src\Shared\BundleDiscovery.cs (3)
138if (File.Exists(dcpExePath)) 169if (File.Exists(managedExe)) 282return File.Exists(managedPath) ? managedPath : null;
src\Shared\DirectoryHelper.cs (1)
29File.SetUnixFileMode(path, OwnerOnlyMode);
src\Shared\Export\ExportArchive.cs (1)
56using var fileStream = File.Create(filePath);
src\Shared\IntegrationPackageProbeManifest.cs (4)
112if (!File.Exists(normalizedManifestPath)) 117using var stream = File.OpenRead(normalizedManifestPath); 173return File.WriteAllBytesAsync(path, stream.ToArray(), cancellationToken); 341if (!File.Exists(normalizedPath))
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
src\Shared\ProcessStartTimeHelper.cs (1)
345contents = File.ReadAllText(statPath);
src\Shared\UserSecrets\IsolatedUserSecretsHelper.cs (4)
26if (!File.Exists(originalSecretsPath)) 43File.Copy(originalSecretsPath, isolatedSecretsPath, overwrite: true); 64if (File.Exists(secretsPath)) 66File.Delete(secretsPath);
src\Shared\UserSecrets\SecretsStore.cs (7)
93File.WriteAllText(tempFilename, json); 94File.Move(tempFilename, _secretsFilePath, overwrite: true); 99if (File.Exists(tempFilename)) 101File.Delete(tempFilename); 107File.WriteAllText(_secretsFilePath, json); 116if (!File.Exists(path)) 121var json = File.ReadAllText(path);
Telemetry\InternalMicrosoftDetector.cs (12)
301if (!File.Exists(_cacheFilePath)) 308var json = await File.ReadAllTextAsync(_cacheFilePath, cancellationToken).ConfigureAwait(false); 352await File.WriteAllTextAsync(tempPath, json, cancellationToken).ConfigureAwait(false); 353File.Move(tempPath, _cacheFilePath, overwrite: true); 405if (!File.Exists(accountStore)) 478if (!File.Exists(stateDatabasePath)) 1008if (!File.Exists(filePath)) 1016text = File.ReadAllText(filePath); 1054if (File.Exists(path)) 1130if (!File.Exists("/proc/sys/kernel/osrelease")) 1135var osRelease = File.ReadAllText("/proc/sys/kernel/osrelease"); 1162if (File.Exists(candidate))
Telemetry\UnixMachineInformationProvider.cs (4)
84File.Delete(fullPath); 86await File.WriteAllTextAsync(fullPath, value, Encoding.UTF8); 106if (!File.Exists(path)) 113var contents = await File.ReadAllTextAsync(path, Encoding.UTF8);
Templating\CliTemplateFactory.cs (2)
366var mode = File.GetUnixFileMode(filePath); 367File.SetUnixFileMode(filePath, mode | UnixFileMode.UserExecute | UnixFileMode.GroupExecute | UnixFileMode.OtherExecute);
Templating\CliTemplateFactory.EmptyTemplate.cs (3)
153if (!File.Exists(aspireConfigPath)) 159var content = await File.ReadAllTextAsync(aspireConfigPath, cancellationToken); 163await File.WriteAllTextAsync(aspireConfigPath, updatedContent, cancellationToken);
Templating\DotNetTemplateFactory.cs (1)
117if (File.Exists(Path.Combine(directory, dotnetFileName)))
Utils\AppHostHelper.cs (2)
179if (File.Exists(socketPath)) 181File.Delete(socketPath);
Utils\ArchiveHelper.cs (4)
112File.SetUnixFileMode(fullPath, (UnixFileMode)entry.Mode); 133if (File.Exists(fullPath)) 135File.Delete(fullPath); 137File.CreateSymbolicLink(fullPath, entry.LinkName);
Utils\AspireRepositoryDetector.cs (2)
97if (File.Exists(Path.Combine(currentDirectory, AspireSolutionFileName))) 117if (File.Exists(fullPath))
Utils\CliDownloader.cs (2)
144if (File.Exists(lddPath)) 208var expectedChecksum = (await File.ReadAllTextAsync(checksumPath, cancellationToken)).Trim().ToLowerInvariant();
Utils\CliPathHelper.cs (4)
219/// the directory directly and <see cref="File.ResolveLinkTarget(string, bool)"/> 329var lastWrite = File.GetLastWriteTimeUtc(path); 332File.Delete(path); 369var resolved = File.ResolveLinkTarget(path, returnFinalTarget: true);
Utils\ConfigurationHelper.cs (11)
37if (File.Exists(newSettingsPath)) 64if (File.Exists(legacySettingsPath)) 74if (File.Exists(globalSettingsFile.FullName)) 155if (File.Exists(configPath)) 161if (File.Exists(legacyPath)) 176if (!File.Exists(filePath)) 183var content = File.ReadAllText(filePath); 230await File.WriteAllTextAsync(filePath, jsonContent, cancellationToken); 241File.WriteAllText(filePath, jsonContent); 265var content = File.ReadAllText(filePath); 292var content = File.ReadAllText(filePath);
Utils\EnvironmentChecker\DcpConnectionChecker.cs (1)
383while (!File.Exists(_kubeconfigPath))
Utils\EnvironmentChecker\DcpConnectionHealthCheck.cs (1)
47if (!File.Exists(dcpExecutablePath))
Utils\EnvironmentChecker\DcpDeveloperCertificateCache.cs (1)
33certificateManager.ExportCertificate(certificate, certificatePath, includePrivateKey: !File.Exists(keyPath), password: null, CertificateKeyExportFormat.Pem);
Utils\EnvironmentChecker\DcpKubeconfig.cs (1)
29var content = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
Utils\EnvironmentChecker\DeprecatedAgentConfigCheck.cs (2)
48if (!File.Exists(configPath)) 55var content = File.ReadAllText(configPath);
Utils\EnvironmentChecker\DevCertsCheck.cs (2)
294if (!File.Exists(certificateFile)) 391if (!File.Exists(certificateFile))
Utils\EnvironmentChecker\LegacySettingsFileCheck.cs (2)
41if (File.Exists(modernConfigPath)) 48if (File.Exists(legacySettingsPath))
Utils\EnvironmentChecker\OperatingSystemCheck.cs (1)
163return File.ReadAllText("/etc/os-release");
Utils\EnvironmentChecker\WslEnvironmentCheck.cs (2)
226return File.Exists(ProcVersionPath) ? File.ReadAllText(ProcVersionPath) : null;
Utils\FileDeleteHelper.cs (4)
69if (!File.Exists(path)) 76File.Delete(path); 83File.Move(path, renamedPath); 126File.Delete(oldFile);
Utils\FileSystemHelper.cs (2)
20return await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false); 35return await File.ReadAllBytesAsync(path, cancellationToken).ConfigureAwait(false);
Utils\FirstTimeUseNoticeSentinel.cs (2)
27return File.Exists(_sentinelFilePath); 45File.WriteAllText(_sentinelFilePath, string.Empty);
Utils\ReparsePoint.cs (7)
107return Directory.Exists(path) || File.Exists(path); 118var attributes = File.GetAttributes(path); 154var attributes = File.GetAttributes(path); 188var attributes = File.GetAttributes(path); 197File.Delete(path); 236if (File.Exists(path)) 238File.Delete(path);
aspire-managed (24)
NuGet\Commands\LayoutCommand.cs (5)
76if (!File.Exists(assetsPath)) 139if (File.Exists(destPath) && 140File.GetLastWriteTimeUtc(sourcePath) <= File.GetLastWriteTimeUtc(destPath)) 150File.Copy(sourcePath, destPath, overwrite: true);
NuGet\Commands\NuGetPackageAssetResolver.cs (8)
52if (!File.Exists(assetsPath)) 201if (!File.Exists(sourcePath)) 215if (File.Exists(xmlSourcePath)) 260if (runtimeIdentifierGraphPath is not null && File.Exists(runtimeIdentifierGraphPath)) 282using var stream = File.OpenRead(assetsPath); 333if (!File.Exists(sourcePath)) 364if (!File.Exists(sourcePath)) 405if (!File.Exists(sourcePath))
NuGet\Commands\RestoreCommand.cs (2)
335if (File.Exists(graphPath)) 342using var fileStream = File.Create(graphPath);
NuGet\Commands\SearchCommand.cs (1)
181if (!string.IsNullOrEmpty(configPath) && File.Exists(configPath))
src\Shared\BundleDiscovery.cs (3)
138if (File.Exists(dcpExePath)) 169if (File.Exists(managedExe)) 282return File.Exists(managedPath) ? managedPath : null;
src\Shared\IntegrationPackageProbeManifest.cs (4)
112if (!File.Exists(normalizedManifestPath)) 117using var stream = File.OpenRead(normalizedManifestPath); 173return File.WriteAllBytesAsync(path, stream.ToArray(), cancellationToken); 341if (!File.Exists(normalizedPath))
src\Shared\ProcessStartTimeHelper.cs (1)
345contents = File.ReadAllText(statPath);
Aspire.Acquisition.Tests (141)
Scripts\Common\FakeArchiveHelper.cs (9)
32await File.WriteAllTextAsync(binaryPath, "#!/bin/bash\necho \"aspire mock v1.0\"\n"); 49await File.WriteAllTextAsync(checksumPath, hashHex); 67await File.WriteAllTextAsync(path, "fake-nupkg-content"); 74await File.WriteAllTextAsync(archive.ChecksumPath, "0000000000000000000000000000000000000000000000000000000000000000"); 117await File.WriteAllTextAsync(binaryPath, FakeVerifyAspireScript); 126await File.WriteAllTextAsync(sidecarPath, "{\"source\":\"stray\"}"); 132await File.WriteAllTextAsync(checksumPath, hashHex); 194await using var fileStream = File.Create(archivePath); 213using var stream = File.OpenRead(filePath);
Scripts\Common\FileHelper.cs (1)
18File.SetUnixFileMode(path,
Scripts\Common\ScriptFunctionCommand.cs (3)
64if (!File.Exists(fullScriptPath)) 114File.WriteAllText(tempScript, wrapperContent); 157File.WriteAllText(tempScript, scriptContent);
Scripts\Common\ScriptHostFixture.cs (2)
185if (!File.Exists(filePath)) 192var content = await File.ReadAllBytesAsync(filePath);
Scripts\Common\ScriptToolCommand.cs (1)
70if (!File.Exists(fullScriptPath))
Scripts\Common\TestEnvironment.cs (2)
277await File.WriteAllTextAsync(tempGhScriptPath, scriptContent); 284File.Move(tempGhScriptPath, ghScriptPath, overwrite: true);
Scripts\LocalHiveScriptFunctionTests.cs (6)
18var source = File.ReadAllText(GetRepoPath(GetScriptPath(scriptPathName))); 30var source = File.ReadAllText(GetRepoPath(GetScriptPath(scriptPathName))); 43var source = File.ReadAllText(GetRepoPath(ScriptPaths.LocalHiveShell)); 55var source = File.ReadAllText(GetRepoPath(ScriptPaths.LocalHivePowerShell)); 69var source = File.ReadAllText(GetRepoPath(GetScriptPath(scriptPathName))); 84var source = File.ReadAllText(GetRepoPath(ScriptPaths.LocalHivePowerShell));
Scripts\PRScriptFunctionTests.cs (5)
231File.WriteAllText(Path.Combine(tempDir, "artifact.tar.gz"), "fake"); 251File.WriteAllText(Path.Combine(tempDir, "artifact.tar.gz"), "fake"); 271File.WriteAllText(Path.Combine(tempDir, "artifact.tar.gz"), "fake"); 373File.WriteAllText(configFile, "# existing config\n"); 387var contents = File.ReadAllText(configFile);
Scripts\PRScriptInstallE2ETests.cs (3)
57Assert.True(File.Exists(Path.Combine(binDir, "aspire")), $"CLI binary missing under {binDir}"); 60Assert.True(File.Exists(sidecarPath), $"Route sidecar missing at {sidecarPath}"); 62var sidecarContent = await File.ReadAllTextAsync(sidecarPath, cancellationToken);
Scripts\PRScriptInstallerModeTests.cs (35)
37await File.WriteAllTextAsync(Path.Combine(root, "aspire.rb"), "cask \"aspire\" do\n version \"13.3.0\"\nend\n"); 38await File.WriteAllTextAsync(Path.Combine(root, "dogfood.sh"), "#!/usr/bin/env bash\nexit 0\n"); 47await File.WriteAllTextAsync(Path.Combine(root, "Microsoft.Aspire.installer.yaml"), "PackageIdentifier: Microsoft.Aspire\nPackageVersion: 13.3.0\nInstallers: []\n"); 48await File.WriteAllTextAsync(Path.Combine(root, "dogfood.ps1"), "exit 0\n"); 94await File.WriteAllTextAsync(Path.Combine(manifestDir, "Microsoft.Aspire.installer.yaml"), installerYaml); 95await File.WriteAllTextAsync(Path.Combine(manifestDir, "Microsoft.Aspire.yaml"), $"PackageIdentifier: Microsoft.Aspire\nPackageVersion: {version}\nManifestType: version\nManifestVersion: 1.10.0\n"); 96await File.WriteAllTextAsync(Path.Combine(manifestDir, "Microsoft.Aspire.locale.en-US.yaml"), $"PackageIdentifier: Microsoft.Aspire\nPackageVersion: {version}\nPackageLocale: en-US\nManifestType: defaultLocale\nManifestVersion: 1.10.0\n"); 97await File.WriteAllTextAsync(Path.Combine(manifestDir, "dogfood.ps1"), "exit 0\n"); 121await File.WriteAllTextAsync(brewPath, $$""" 195await File.WriteAllTextAsync(curlPath, """ 235await File.WriteAllTextAsync(implPath, $$""" 370await File.WriteAllTextAsync(wingetCmd, """ 376await File.WriteAllTextAsync(aspireCmd, $$""" 388await File.WriteAllTextAsync(Path.Combine(root, "aspire-cli-osx-arm64-13.3.0.tar.gz"), "fake arm64 archive"); 389await File.WriteAllTextAsync(Path.Combine(root, "aspire-cli-osx-x64-13.3.0.tar.gz"), "fake x64 archive"); 405var bytes = await File.ReadAllBytesAsync(path); 422if (File.Exists(path)) 424File.Delete(path); 427await using var fs = File.Create(path); 581await File.WriteAllTextAsync(caskPath, "cask \"aspire\" do\n version \"13.3.0\"\nend\n"); 616var brewLog = await File.ReadAllTextAsync(Path.Combine(env.TempDirectory, "brew.log")); 642var cask = await File.ReadAllTextAsync(Path.Combine(outputDir, "aspire.rb")); 649Assert.True(File.Exists(Path.Combine(outputDir, "dogfood.sh"))); 658var brewLog = await File.ReadAllTextAsync(Path.Combine(env.TempDirectory, "brew.log")); 772var installerManifest = await File.ReadAllTextAsync(Path.Combine(outputDir, "Microsoft.Aspire.installer.yaml")); 781var localeManifest = await File.ReadAllTextAsync(Path.Combine(outputDir, "Microsoft.Aspire.locale.en-US.yaml")); 783Assert.True(File.Exists(Path.Combine(outputDir, "Microsoft.Aspire.yaml"))); 784Assert.True(File.Exists(Path.Combine(outputDir, "dogfood.ps1"))); 801var wingetLog = await File.ReadAllTextAsync(Path.Combine(env.TempDirectory, "winget.log")); 848var wingetLog = await File.ReadAllTextAsync(Path.Combine(env.TempDirectory, "winget.log")); 853var originalInstaller = await File.ReadAllTextAsync(Path.Combine(manifestDir, "Microsoft.Aspire.installer.yaml")); 921var installerYaml = await File.ReadAllTextAsync(Path.Combine(outputDir, "Microsoft.Aspire.installer.yaml")); 932Assert.True(File.Exists(expected), 954File.Delete(x64Archive); 955await using (var fs = File.Create(x64Archive))
Scripts\PRScriptPowerShellTests.cs (5)
215await File.WriteAllTextAsync(Path.Combine(localDir, "aspire"), "#!/bin/sh\necho fake\n"); 477File.Exists(sidecarPath), 573File.Exists(sidecarPath), 588Assert.False(File.Exists(globalConfig), $"Unexpected global config at {globalConfig}"); 621Assert.False(File.Exists(binSidecar), $"--local-dir install must not write sidecar at {binSidecar} (unmanaged route).");
Scripts\PRScriptPSFunctionTests.cs (7)
104Assert.Contains(cliBinDir, await File.ReadAllLinesAsync(githubPath)); 262File.WriteAllText(Path.Combine(tempDir, "artifact.tar.gz"), "fake"); 282File.WriteAllText(Path.Combine(tempDir, "artifact.tar.gz"), "fake"); 302File.WriteAllText(Path.Combine(tempDir, "artifact.tar.gz"), "fake"); 326await File.WriteAllTextAsync(Path.Combine(downloadDir, "README.txt"), "no archive here"); 348await File.WriteAllTextAsync(Path.Combine(downloadDir, "aspire-cli-linux-x64.tar.gz"), "fake1"); 349await File.WriteAllTextAsync(Path.Combine(downloadDir, "aspire-cli-osx-arm64.tar.gz"), "fake2");
Scripts\PRScriptShellTests.cs (6)
173await File.WriteAllTextAsync(Path.Combine(localDir, "aspire"), "#!/bin/sh\necho fake\n"); 552File.Exists(sidecarPath), 636File.Exists(sidecarPath), 651Assert.False(File.Exists(globalConfig), $"Unexpected global config at {globalConfig}"); 686Assert.False(File.Exists(binSidecar), $"--local-dir install must not write sidecar at {binSidecar} (unmanaged route)."); 728File.Exists(sidecarPath),
Scripts\PRScriptToolModeTests.cs (22)
120await File.WriteAllTextAsync(dotnetScriptPath, scriptContent); 407var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 436var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 446Assert.True(File.Exists(Path.Combine(prHive, "Aspire.Hosting.13.3.0-pr.5678.deadbeef.nupkg")), 476var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 507Assert.False(File.Exists(sidecarPath), $"Tool mode must not write the PR-route sidecar at {sidecarPath}."); 512Assert.True(File.Exists(Path.Combine(prHive, "Aspire.Hosting.13.3.0-pr.5678.deadbeef.nupkg")), 515var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 631await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.13.3.0-pr.5678.deadbeef.symbols.nupkg"), "fake-symbols-nupkg-content"); 632await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.13.3.0-pr.5678.deadbeef.snupkg"), "fake-symbols-package-content"); 634await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.13_3_0.nupkg"), "fake-invalid-version-content"); 657await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.1_0.nupkg"), "fake-invalid-version-content"); 983var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 1012var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 1022Assert.True(File.Exists(Path.Combine(prHive, "Aspire.Hosting.13.3.0-pr.5678.deadbeef.nupkg")), 1051Assert.False(File.Exists(sidecarPath), $"Tool mode must not write the PR-route sidecar at {sidecarPath}."); 1056Assert.True(File.Exists(Path.Combine(prHive, "Aspire.Hosting.13.3.0-pr.5678.deadbeef.nupkg")), 1059var dotnetCommands = await File.ReadAllTextAsync(dotnetCommandsPath, TestContext.Current.CancellationToken); 1158await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.13.3.0-pr.5678.deadbeef.symbols.nupkg"), "fake-symbols-nupkg-content"); 1159await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.13.3.0-pr.5678.deadbeef.snupkg"), "fake-symbols-package-content"); 1161await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.13_3_0.nupkg"), "fake-invalid-version-content"); 1183await File.WriteAllTextAsync(Path.Combine(pkgDir, "Aspire.Cli.1_0.nupkg"), "fake-invalid-version-content");
Scripts\ReleaseScriptFunctionTests.cs (12)
316Assert.True(File.Exists(Path.Combine(destPath, "aspire")), 337Assert.True(File.Exists(Path.Combine(destPath, "aspire.exe")), 439await File.WriteAllTextAsync(cliPath, ($$""" 455Assert.Equal("setup", (await File.ReadAllTextAsync(capturePath)).Trim()); 513File.WriteAllText(Path.Combine(env.MockHome, ".bashrc"), "# existing config\n"); 525var bashrcContent = File.ReadAllText(Path.Combine(env.MockHome, ".bashrc")); 537File.WriteAllText(Path.Combine(env.MockHome, ".zshrc"), "# existing config\n"); 549var zshrcContent = File.ReadAllText(Path.Combine(env.MockHome, ".zshrc")); 562File.WriteAllText( 576var bashrcContent = File.ReadAllText(Path.Combine(env.MockHome, ".bashrc")); 613await File.WriteAllTextAsync(mockCurl, 650await File.WriteAllTextAsync(mockCurl,
Scripts\ReleaseScriptPowerShellTests.cs (8)
198await File.ReadAllBytesAsync(Path.Combine(installPath, ".aspire-install.json"))); 221await File.WriteAllTextAsync(sidecarPath, """{"source":"old"}"""); 235using var document = JsonDocument.Parse(await File.ReadAllBytesAsync(sidecarPath)); 276await File.ReadAllBytesAsync(Path.Combine(installPath, ".aspire-install.json"))); 365File.Exists(globalConfig), 387File.Exists(configPath), 410File.Exists(sidecarPath), 428File.Exists(sidecarPath),
Scripts\ReleaseScriptPSFunctionTests.cs (6)
283Assert.True(File.Exists(Path.Combine(destPath, "aspire")), 304Assert.True(File.Exists(Path.Combine(destPath, "aspire.exe")), 421await File.WriteAllTextAsync(cliPath, contents.ReplaceLineEndings(OperatingSystem.IsWindows() ? "\r\n" : "\n")); 424File.SetUnixFileMode(cliPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 437Assert.Equal("setup", (await File.ReadAllTextAsync(capturePath)).Trim()); 463Assert.False(File.Exists(cliPath));
Scripts\ReleaseScriptShellTests.cs (7)
153await File.ReadAllBytesAsync(Path.Combine(installPath, ".aspire-install.json"))); 182Assert.True(File.Exists(Path.Combine(installPath, ".aspire-install.json"))); 212await File.ReadAllBytesAsync(Path.Combine(installPath, ".aspire-install.json"))); 299File.Exists(globalConfig), 321File.Exists(configPath), 344File.Exists(sidecarPath), 364File.Exists(sidecarPath),
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
Aspire.Cli.EndToEnd.Tests (368)
AgentCommandTests.cs (8)
105File.WriteAllText(configPath, """{"mcpServers":{"aspire":{"command":"aspire","args":["mcp","start"]}}}"""); 108var fileContent = File.ReadAllText(configPath); 128fileContent = File.ReadAllText(configPath); 157File.WriteAllText(configPath, """{"mcpServers":{"aspire":{"command":"aspire","args":["mcp","start"]}}}"""); 216var fileContent = File.ReadAllText(skillFilePath); 219var deploymentFileContent = File.ReadAllText(deploymentSkillFilePath); 266Assert.True(File.Exists(skillFile), $"Expected {skillName} SKILL.md at {skillFile}"); 267Assert.Contains($"name: {skillName}", File.ReadAllText(skillFile));
AgentMcpExcludeFromMcpTests.cs (2)
38var content = File.ReadAllText(appHostFilePath); 43File.WriteAllText(appHostFilePath, modified);
AppHostSyntaxErrorOutputTests.cs (6)
145var recordingOffset = File.Exists(recordingPath) ? new FileInfo(recordingPath).Length : 0; 259File.WriteAllText(Path.Combine(projectDirectory, "BrokenDotNetApp.csproj"), $$""" 270File.WriteAllText(appHostPath, """ 282File.WriteAllText(Path.Combine(projectDirectory, "MissingSdkAppHost.csproj"), """ 294var firstLine = File.ReadLines(appHostPath).First(); 304File.WriteAllText(Path.Combine(projectDirectory, "apphost.mts"), "const value = ;");
BundleSmokeTests.cs (20)
71Assert.True(File.Exists(appHostProjectPath), $"Expected AppHost project file to exist at: {appHostProjectPath}"); 72Assert.True(File.Exists(appHostSourcePath), $"Expected AppHost source file to exist at: {appHostSourcePath}"); 74var appHostProject = File.ReadAllText(appHostProjectPath); 78File.WriteAllText( 102Assert.True(File.Exists(argsOutputPath), $"Expected AppHost to write forwarded args to: {argsOutputPath}"); 103Assert.Equal("--from-dotnet-run", File.ReadAllText(argsOutputPath)); 136Assert.True(File.Exists(appHostProjectPath), $"Expected AppHost project file to exist at: {appHostProjectPath}"); 137Assert.True(File.Exists(appHostSourcePath), $"Expected AppHost source file to exist at: {appHostSourcePath}"); 139var appHostProject = File.ReadAllText(appHostProjectPath); 147File.WriteAllText(appHostProjectPath, appHostProject); 149var appHostSource = File.ReadAllText(appHostSourcePath); 150File.WriteAllText( 197Assert.True(File.Exists(argsOutputPath), $"Expected AppHost to write forwarded args to: {argsOutputPath}"); 198Assert.Equal("--from-real-dnx", File.ReadAllText(argsOutputPath)); 227Assert.True(File.Exists(appHostSourcePath), $"Expected AppHost source file to exist at: {appHostSourcePath}"); 229var appHostSource = File.ReadAllText(appHostSourcePath); 230var sdkDirective = File.ReadLines(appHostSourcePath).First(); 235File.WriteAllText( 258Assert.True(File.Exists(argsOutputPath), $"Expected AppHost to write forwarded args to: {argsOutputPath}"); 259Assert.Equal("--from-dotnet-run-file", File.ReadAllText(argsOutputPath));
CentralPackageManagementTests.cs (13)
52File.WriteAllText(appHostCsprojPath, """ 66File.WriteAllText(Path.Combine(appHostDir, "Program.cs"), """ 71File.WriteAllText(directoryPackagesPropsPath, """ 95var content = File.ReadAllText(directoryPackagesPropsPath); 166File.WriteAllText(appHostCsprojPath, """ 177File.WriteAllText(Path.Combine(appHostDir, "Program.cs"), """ 183File.WriteAllText(directoryPackagesPropsPath, """ 203var migratedCsproj = File.ReadAllText(appHostCsprojPath); 218File.WriteAllText(directoryPackagesPropsPath, $$""" 244var content = File.ReadAllText(directoryPackagesPropsPath); 287File.WriteAllText(appHostCsprojPath, """ 297File.WriteAllText(Path.Combine(appHostDir, "Program.cs"), """ 302File.WriteAllText(directoryPackagesPropsPath, """
ChannelUpdateWorkflowTests.cs (7)
138await File.WriteAllTextAsync(appHostPath, 488if (!File.Exists(aspireConfigPath)) 493using var doc = JsonDocument.Parse(File.ReadAllText(aspireConfigPath)); 502if (!File.Exists(aspireConfigPath)) 507using var doc = JsonDocument.Parse(File.ReadAllText(aspireConfigPath)); 526if (!File.Exists(aspireConfigPath)) 531using var doc = JsonDocument.Parse(File.ReadAllText(aspireConfigPath));
ConfigDiscoveryTests.cs (17)
59Assert.True(File.Exists(primaryConfigPath), $"Expected Primary config at: {primaryConfigPath}"); 60Assert.True(File.Exists(alternateConfigPath), $"Expected Alternate config at: {alternateConfigPath}"); 61Assert.True(File.Exists(alternateAppHostPath), $"Expected Alternate AppHost source file to exist at: {alternateAppHostPath}"); 65File.Delete(primaryConfigPath); 66File.Delete(alternateConfigPath); 71var alternateAppHostSource = File.ReadAllText(alternateAppHostPath); 73File.WriteAllText( 93File.WriteAllBytes(workspaceConfigPath, originalWorkspaceConfigBytes); 123Assert.True(File.Exists(alternateRunMarkerPath), $"Expected the Alternate AppHost to run and write: {alternateRunMarkerPath}"); 124Assert.Equal("alternate", File.ReadAllText(alternateRunMarkerPath)); 125Assert.Equal(originalWorkspaceConfigBytes, File.ReadAllBytes(workspaceConfigPath)); 126Assert.False(File.Exists(alternateConfigPath), $"Explicit alternate AppHost should not create a local config at: {alternateConfigPath}"); 167Assert.True(File.Exists(projectConfigPath), 170var originalContent = File.ReadAllText(projectConfigPath); 200Assert.False(File.Exists(parentConfigPath), 205Assert.True(File.Exists(projectConfigPath), 208var currentContent = File.ReadAllText(projectConfigPath);
ConfigHealingTests.cs (3)
61File.WriteAllText(configFilePath, malformedConfig); 76if (!File.Exists(configFilePath)) 82var content = File.ReadAllText(configFilePath);
ConfigMigrationTests.cs (21)
63if (!File.Exists(filePath)) 68var content = File.ReadAllText(filePath); 85if (!File.Exists(filePath)) 90var content = File.ReadAllText(filePath); 128File.WriteAllText(legacyPath, 132if (File.Exists(newConfigPath)) 134File.Delete(newConfigPath); 191File.WriteAllText(newConfigPath, 193File.WriteAllText(legacyPath, 234File.WriteAllText( 238if (File.Exists(newConfigPath)) 240File.Delete(newConfigPath); 291File.WriteAllText(legacyPath, 302if (File.Exists(newConfigPath)) 304File.Delete(newConfigPath); 363if (File.Exists(f)) 365File.Delete(f); 397if (File.Exists(legacyPath)) 441File.WriteAllText(legacyPath, 456if (File.Exists(newConfigPath)) 458File.Delete(newConfigPath);
CSharpInitTests.cs (3)
58Assert.True(File.Exists(appHostCs), $"Expected apphost.cs to exist at: {appHostCs}"); 59Assert.True(File.Exists(aspireConfigJson), $"Expected aspire.config.json to exist at: {aspireConfigJson}"); 61var configText = await File.ReadAllTextAsync(aspireConfigJson);
CSharpProjectModeInitTests.cs (8)
68File.WriteAllText(solutionPath, "Fake solution file"); 89File.Exists(workspaceNuGetConfig), 92Assert.True(File.Exists(appHostCsproj), $"Expected AppHost csproj at: {appHostCsproj}"); 140File.WriteAllText(solutionPath, "Fake solution file"); 144File.WriteAllText(leftoverPath, LeftoverContent); 161File.Exists(workspaceNuGetConfig), 165Assert.True(File.Exists(leftoverPath), $"Pre-existing AppHost file should be preserved: {leftoverPath}"); 166Assert.Equal(LeftoverContent, File.ReadAllText(leftoverPath));
DescribeCommandTests.cs (2)
117var content = File.ReadAllText(appHostFilePath); 136File.WriteAllText(appHostFilePath, content);
DockerDeploymentTests.cs (4)
63var content = File.ReadAllText(appHostFilePath); 75File.WriteAllText(appHostFilePath, content); 163var content = File.ReadAllText(appHostFilePath); 175File.WriteAllText(appHostFilePath, content);
DocsCommandE2ETests.cs (1)
21File.WriteAllText(docsFilePath, """
DoctorCommandTests.cs (2)
115File.Delete(recordingPath); 127var recordingOffset = File.Exists(recordingPath) ? new FileInfo(recordingPath).Length : 0;
EmulatedLocalReleaseBuildTests.cs (8)
312if (!File.Exists(csprojPath)) 318var content = File.ReadAllText(csprojPath); 327if (!File.Exists(csprojPath)) 337var content = File.ReadAllText(csprojPath); 351if (!File.Exists(configPath)) 356using var document = JsonDocument.Parse(File.ReadAllText(configPath)); 371if (!File.Exists(configPath)) 379using var document = JsonDocument.Parse(File.ReadAllText(configPath));
EmulatedReleasedBuildTests.cs (4)
225if (!File.Exists(csprojPath)) 231var content = File.ReadAllText(csprojPath); 240if (!File.Exists(configPath)) 245using var document = JsonDocument.Parse(File.ReadAllText(configPath));
EmulatedStagingBuildTests.cs (8)
272$"Dropped NuGet.config ({configPath}) does not contain a package source for the staging feed '{feedFragment}'. Content:\n{File.ReadAllText(configPath)}"); 284$"Dropped NuGet.config ({configPath}) does not map the 'Aspire*' pattern to the staging feed '{feedFragment}'. Content:\n{File.ReadAllText(configPath)}"); 289if (!File.Exists(csprojPath)) 295var content = File.ReadAllText(csprojPath); 308if (!File.Exists(configPath)) 313using var document = System.Text.Json.JsonDocument.Parse(File.ReadAllText(configPath)); 335if (!File.Exists(configPath)) 340using var document = System.Text.Json.JsonDocument.Parse(File.ReadAllText(configPath));
EntityFrameworkCoreDeploymentTests.cs (4)
135var targetRuntime = File.ReadAllText(targetRuntimePath).Trim(); 136File.Delete(targetRuntimePath); 157File.WriteAllText( 208File.WriteAllText(
Helpers\CaptureWorkspaceOnFailureAttribute.cs (2)
74File.Exists(filePath)) 107File.Exists(filePath))
Helpers\CliE2ETestHelpers.cs (6)
607if (File.Exists(Path.Combine(dir.FullName, "Aspire.slnx"))) 1114var config = File.Exists(configPath) 1115? JsonNode.Parse(File.ReadAllText(configPath))?.AsObject() ?? new JsonObject() 1124File.WriteAllText(configPath, config.ToJsonString()); 1169File.Copy(sourcePath, destFile, overwrite: true); 1195File.Copy(file, destFile, overwrite: true);
Helpers\CliInstallStrategyTests.cs (7)
480File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.13.3.0-preview.1.25175.1.nupkg"), ""); 481File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.linux-x64.13.3.0-preview.1.25175.1.nupkg"), ""); 777File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.13.3.0-preview.1.12345.1.nupkg"), ""); 795File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.linux-x64.13.3.0.nupkg"), ""); 813File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.13.3.0.nupkg"), ""); 814File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.13.4.0.nupkg"), ""); 833File.WriteAllText(Path.Combine(tempDir.FullName, "Aspire.Cli.linux-x64.13.3.0.nupkg"), "");
Helpers\GitIgnoreAssertions.cs (2)
13Assert.True(File.Exists(gitIgnorePath), $"Expected generated .gitignore at {gitIgnorePath}"); 15var gitIgnoreLines = File.ReadAllLines(gitIgnorePath);
Helpers\KubernetesDeployTestHelpers.cs (2)
340File.WriteAllText(Path.Combine(appHostDir, "AppHost.cs"), appHostCode); 341File.WriteAllText(Path.Combine(apiDir, "Program.cs"), apiProgramCode);
Helpers\TerminalRun.cs (1)
129File.Copy(file, Path.Combine(destination, Path.GetFileName(file)), overwrite: true);
Helpers\TestDirectoryHelpers.cs (1)
23File.Copy(file, Path.Combine(destination, Path.GetFileName(file)));
Helpers\TypeScriptAppHostToolchainTestHelpers.cs (9)
37var packageJson = JsonNode.Parse(File.ReadAllText(packageJsonPath))?.AsObject() 41File.WriteAllText(packageJsonPath, $"{packageJson.ToJsonString(s_packageJsonSerializerOptions)}{Environment.NewLine}"); 52if (File.Exists(lockFilePath)) 54File.Delete(lockFilePath); 160File.WriteAllText(yarnConfigPath, $"{YarnNodeModulesConfiguration}{Environment.NewLine}"); 163if (!File.Exists(yarnLockPath)) 167File.WriteAllText(yarnLockPath, string.Empty); 170else if (File.Exists(yarnConfigPath)) 172File.Delete(yarnConfigPath);
JavaCodegenValidationTests.cs (9)
64var initialCodegenHash = File.Exists(codegenHashPath) ? File.ReadAllText(codegenHashPath) : null; 67if (File.Exists(builderPath) && File.ReadAllText(builderPath).Contains("addSqlServer")) 97if (!File.Exists(filePath)) 102var content = File.ReadAllText(filePath); 109var builderJava = File.ReadAllText(Path.Combine(modulesDir, "aspire", "IDistributedApplicationBuilder.java")); 119var restoredCodegenHash = File.Exists(codegenHashPath) ? File.ReadAllText(codegenHashPath) : null;
JavaPolyglotApphostDirectoryTests.cs (1)
86File.WriteAllText(appHostPath, newContent);
JavaPolyglotTests.cs (1)
68File.WriteAllText(appHostPath, newContent);
JavaScriptPublishTests.cs (7)
146File.WriteAllText(appHostPath, """ 179File.WriteAllText(appHostPath, $$""" 220File.WriteAllText(Path.Combine(appDir, "package.json"), $$""" 235File.WriteAllText(Path.Combine(appDir, "yarn.lock"), $$""" 252File.WriteAllText(Path.Combine(appDir, "server.js"), $$""" 277File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "verify-runtime.sh"), $$""" 330File.Copy(file, Path.Combine(workspace.WorkspaceRoot.FullName, Path.GetFileName(file)));
KubernetesDeployTypeScriptTests.cs (2)
81var content = File.ReadAllText(appHostFilePath); 107File.WriteAllText(appHostFilePath, content);
KubernetesDeployTypeScriptWithPersistentVolumeTests.cs (4)
103var appHostContent = File.ReadAllText(appHostFilePath); 137File.WriteAllText(appHostFilePath, appHostContent); 146var apiIndexContent = File.ReadAllText(apiIndexFilePath); 182File.WriteAllText(apiIndexFilePath, apiIndexContent);
KubernetesPublishRequiresExternalEndpointTests.cs (2)
92var content = File.ReadAllText(appHostFilePath); 96File.WriteAllText(appHostFilePath, content);
KubernetesPublishTests.cs (3)
139var content = File.ReadAllText(appHostFilePath); 151File.WriteAllText(appHostFilePath, content); 346File.WriteAllText(
LaunchProfileTests.cs (7)
27File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "LaunchProfile.sln"), "Fake solution file"); 45Assert.True(File.Exists(appHostSourcePath), $"Expected AppHost source file to exist at: {appHostSourcePath}"); 46Assert.True(File.Exists(launchSettingsPath), $"Expected launch settings to exist at: {launchSettingsPath}"); 48File.WriteAllText( 62File.WriteAllText( 97Assert.True(File.Exists(profileOutputPath), $"Expected AppHost to write selected profile details to: {profileOutputPath}"); 98Assert.Equal("selected-profile|E2E|--profile-argument|selected-profile", File.ReadAllText(profileOutputPath));
LocalConfigMigrationTests.cs (4)
91while (!File.Exists(configPath) && DateTime.UtcNow < deadline) 103Assert.True(File.Exists(configPath), "aspire.config.json was not created by migration"); 104var content = File.ReadAllText(configPath); 147content = File.ReadAllText(configPath);
McpDocsE2ETests.cs (1)
32if (!File.Exists(cliProjectPath))
NewChannelNuGetConfigTests.cs (2)
67Assert.True(File.Exists(nugetConfigPath), 72Assert.False(File.Exists(nugetConfigPath),
OllamaIntegrationTests.cs (2)
58var content = File.ReadAllText(appHostFilePath); 67File.WriteAllText(appHostFilePath, content);
PodmanDeploymentTests.cs (2)
70var content = File.ReadAllText(appHostFilePath); 81File.WriteAllText(appHostFilePath, content);
ProjectReferenceTests.cs (6)
49var configJson = File.ReadAllText(configPath); 57File.WriteAllText(Path.Combine(integrationDir, "MyIntegration.csproj"), $$""" 97File.WriteAllText(Path.Combine(workDir, "nuget.config"), nugetConfig); 100File.WriteAllText(Path.Combine(integrationDir, "MyIntegrationExtensions.cs"), """ 123File.WriteAllText(configPath, updatedJson); 133File.WriteAllText(Path.Combine(workDir, "apphost.mts"), """
PsCommandTests.cs (1)
109var content = File.ReadAllText(outputFilePath).Trim();
RadiusDeployTests.cs (4)
119var content = File.ReadAllText(appHostFilePath); 129File.WriteAllText(appHostFilePath, content); 145Assert.True(File.Exists(appBicepPath), $"Expected generated Bicep at '{appBicepPath}'."); 146var appBicep = File.ReadAllText(appBicepPath);
RadiusPublishTests.cs (6)
84var content = File.ReadAllText(appHostFilePath); 92File.WriteAllText(appHostFilePath, content); 115Assert.True(File.Exists(appBicepPath), $"Expected generated Bicep at '{appBicepPath}'."); 116var appBicep = File.ReadAllText(appBicepPath); 127Assert.True(File.Exists(bicepConfigPath), $"Expected generated bicepconfig.json at '{bicepConfigPath}'."); 133using var bicepConfig = JsonDocument.Parse(File.ReadAllText(bicepConfigPath));
ResourceCommandTests.cs (8)
41var content = File.ReadAllText(appHostFilePath); 54File.WriteAllText(appHostFilePath, newContent); 139var content = File.ReadAllText(appHostFilePath); 184File.WriteAllText(appHostFilePath, newContent); 236var content = File.ReadAllText(appHostFilePath); 265File.WriteAllText(appHostFilePath, newContent); 344var content = File.ReadAllText(appHostFilePath); 366File.WriteAllText(appHostFilePath, newContent);
SdkExportTests.cs (2)
27await File.WriteAllTextAsync( 69using var document = JsonDocument.Parse(await File.ReadAllTextAsync(
SelfUpdateChannelPersistenceTests.cs (2)
49File.WriteAllText(configPath, createdConfig.ToJsonString()); 92return JsonNode.Parse(File.ReadAllText(path))?.AsObject()
SingleFileAppHostInitDotnetRunTests.cs (5)
70Assert.True(File.Exists(appHostCs), $"Expected apphost.cs to exist at: {appHostCs}"); 71Assert.True(File.Exists(aspireConfigJson), $"Expected aspire.config.json to exist at: {aspireConfigJson}"); 72Assert.Contains("#:property AspireUseCliBundle=true", File.ReadAllText(appHostCs)); 74File.Exists(appHostRunJson), 83var runJson = JsonNode.Parse(File.ReadAllText(appHostRunJson))?.AsObject();
SmokeTests.cs (5)
170if (!File.Exists(appHostPath)) 184if (!File.Exists(appHostPath)) 189var appHostContent = File.ReadAllText(appHostPath); 198if (!File.Exists(configPath)) 205using var config = JsonDocument.Parse(File.ReadAllText(configPath));
StartStopTests.cs (2)
250File.WriteAllText(assertionScript, $$""" 480using var document = JsonDocument.Parse(File.ReadAllText(path));
StopForceTests.cs (2)
44var content = File.ReadAllText(appHostFilePath); 47File.WriteAllText(appHostFilePath, $$"""
TerminalCommandTests.cs (2)
36var appHostContent = File.ReadAllText(appHostPath); 48File.WriteAllText(appHostPath, appHostContent.Replace(oldFrontendLine, newFrontendLine, StringComparison.Ordinal));
tests\Aspire.Hosting.TestUtilities\Utils\MSBuildUtils.cs (1)
13while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
tests\Shared\CliInstallStrategy.cs (1)
297if (!File.Exists(archivePath))
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
TypeScriptBlazorGatewayTests.cs (2)
78await File.WriteAllTextAsync(appHostPath, """ 128await File.WriteAllTextAsync(verificationScriptPath, verificationScript.ReplaceLineEndings("\n"));
TypeScriptCodegenValidationTests.cs (17)
82if (!File.Exists(lockFilePath)) 103if (!File.Exists(filePath)) 108var content = File.ReadAllText(filePath); 115var aspireTs = File.ReadAllText(Path.Combine(modulesDir, "aspire.mts")); 171if (!File.Exists(aspireModulePath)) 176var initialAspireTs = File.ReadAllText(aspireModulePath); 188var initialCodegenHash = File.Exists(codegenHashPath) ? File.ReadAllText(codegenHashPath) : null; 207if (!File.Exists(filePath)) 212var content = File.ReadAllText(filePath); 219var restoredAspireTs = File.ReadAllText(aspireModulePath); 226var configJson = File.ReadAllText(configPath); 232var restoredCodegenHash = File.Exists(codegenHashPath) ? File.ReadAllText(codegenHashPath) : null; 239File.WriteAllText(appHostPath, """ 317File.WriteAllText(appHostPath, newContent); 396File.WriteAllText(appHostPath, newContent);
TypeScriptEmptyAppHostTemplateTests.cs (8)
41var appHostContents = await File.ReadAllTextAsync(appHostPath, TestContext.Current.CancellationToken); 58await File.WriteAllTextAsync(appHostPath, appHostContents, TestContext.Current.CancellationToken); 108File.WriteAllText(Path.Combine(extensionDirectory.FullName, "DeadlockExtension.csproj"), $$""" 123File.WriteAllText(Path.Combine(extensionDirectory.FullName, "DeadlockExtensions.cs"), """ 163File.WriteAllText(Path.Combine(appDirectory, "apphost.mts"), """ 178var config = JsonNode.Parse(File.ReadAllText(configPath))?.AsObject() 184File.WriteAllText(configPath, config.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 190using var doc = JsonDocument.Parse(File.ReadAllText(configPath));
TypeScriptLegacyAppHostTests.cs (10)
109if (File.Exists(mtsPath)) 111File.Delete(mtsPath); 123File.WriteAllText(Path.Combine(projectRoot, "apphost.ts"), """ 136var configJson = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 139File.WriteAllText( 146File.WriteAllText(Path.Combine(projectRoot, "tsconfig.apphost.json"), """ 192if (!File.Exists(filePath)) 197var content = File.ReadAllText(filePath); 219if (File.Exists(filePath)) 230var aspireTs = File.ReadAllText(Path.Combine(legacyModulesDir, "aspire.ts"));
TypeScriptMigrateAppHostTests.cs (12)
99if (File.Exists(mtsPath)) 101File.Delete(mtsPath); 112File.WriteAllText(Path.Combine(projectRoot, "apphost.ts"), """ 123var configJson = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 126File.WriteAllText( 130File.WriteAllText(Path.Combine(projectRoot, "tsconfig.apphost.json"), """ 158if (File.Exists(legacyAppHost)) 166if (!File.Exists(modernAppHost)) 172var appHostContent = File.ReadAllText(modernAppHost); 199if (!File.Exists(filePath)) 206var aspireMts = File.ReadAllText(Path.Combine(modernModulesDir, "aspire.mts")); 215var tsconfig = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "tsconfig.apphost.json")))!.AsObject();
TypeScriptPolyglotApphostDirectoryTests.cs (1)
92File.WriteAllText(appHostPath, newContent);
TypeScriptPolyglotTests.cs (20)
111File.WriteAllText(appHostPath, newContent); 123File.Exists(appHostLockFilePath), 130File.Exists(viteLockFilePath), 207File.WriteAllText(appHostPath, """ 229File.Exists(appHostLockFilePath), 236File.Exists(guestLockFilePath), 285File.Exists(lockFilePath), 330File.WriteAllText( 353var packageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "package.json")))!.AsObject(); 359originalTsConfig = File.ReadAllText(Path.Combine(projectRoot, "tsconfig.json")); 361File.WriteAllText(Path.Combine(projectRoot, "package.json"), packageJson.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 384packageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "package.json")))!.AsObject(); 401Assert.Equal(originalTsConfig, File.ReadAllText(Path.Combine(projectRoot, "tsconfig.json"))); 402Assert.False(File.Exists(Path.Combine(projectRoot, "tsconfig.apphost.json"))); 403Assert.False(File.Exists(Path.Combine(projectRoot, "apphost.mts"))); 407Assert.True(File.Exists(appHostPath)); 409var appHostPackageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(appHostDirectory, "package.json")))!.AsObject(); 421Assert.True(File.Exists(Path.Combine(appHostDirectory, "tsconfig.apphost.json"))); 425var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 447File.WriteAllText(appHostPath, newContent);
TypeScriptPublishTests.cs (11)
80File.WriteAllText(appHostPath, newContent); 148var composeContent = await File.ReadAllTextAsync(Path.Combine(artifactsPath, "docker-compose.yaml")); 256File.WriteAllText(appHostPath, newContent); 267Assert.True(File.Exists(dockerComposePath), $"Expected docker-compose output at {dockerComposePath}"); 269var dockerComposeContent = await File.ReadAllTextAsync(dockerComposePath); 334File.WriteAllText(appHostPath, newContent); 345Assert.True(File.Exists(envFilePath), $"Expected env file at {envFilePath}"); 347var envFileContent = await File.ReadAllTextAsync(envFilePath); 355File.WriteAllText(appHostPath, """ 395Assert.True(File.Exists(dockerfilePath), $"Expected Dockerfile for resource '{resourceName}' at {dockerfilePath}"); 397var content = File.ReadAllText(dockerfilePath);
TypeScriptReusablePackageTests.cs (10)
45Assert.True(File.Exists(appAppHostPath), $"Expected the CLI-created app to contain {appAppHostPath}."); 58Assert.False(File.Exists(helperAppHostPath), $"Config-only helper package unexpectedly contained {helperAppHostPath}."); 71Assert.Contains("addRedis", File.ReadAllText(Path.Combine(helperModulesDirectory, "aspire.mts"))); 94using var doc = JsonDocument.Parse(File.ReadAllText(configPath)); 101File.WriteAllText(Path.Combine(appDirectory.FullName, "apphost.mts"), """ 113File.WriteAllText(Path.Combine(appDirectory.FullName, "tsconfig.json"), """ 141File.WriteAllText(Path.Combine(helperDirectory.FullName, "aspire.config.json"), $$""" 155File.WriteAllText(Path.Combine(helperDirectory.FullName, "package.json"), """ 171File.WriteAllText(Path.Combine(helperDirectory.FullName, "tsconfig.json"), """ 194File.WriteAllText(Path.Combine(helperSourceDirectory.FullName, "index.ts"), """
TypeScriptSqlServerNativeAssetsBundleTests.cs (1)
55File.WriteAllText(appHostPath, """
TypeScriptStarterSmokeTests.cs (3)
60if (!File.Exists(aspireModulePath)) 101if (!File.Exists(configPath)) 106using var doc = JsonDocument.Parse(File.ReadAllText(configPath));
TypeScriptStarterTemplateTests.cs (1)
47if (!File.Exists(aspireModulePath))
UpdateChannelNuGetConfigOrderingTests.cs (6)
99Assert.True(File.Exists(appHostCsPath), $"Expected apphost.cs at: {appHostCsPath}"); 100Assert.True(File.Exists(aspireConfigPath), $"Expected aspire.config.json at: {aspireConfigPath}"); 111await File.WriteAllTextAsync(appHostCsPath, 128await File.WriteAllTextAsync(nugetConfigPath, 165var updatedAppHostCs = await File.ReadAllTextAsync(appHostCsPath); 166var updatedNuGetConfig = await File.ReadAllTextAsync(nugetConfigPath);
Aspire.Cli.Tests (2017)
Acquisition\IdentityResolverTests.cs (1)
508=> File.WriteAllText(Path.Combine(directory, InstallSidecarReader.SidecarFileName), json);
Acquisition\InstallationDiscoveryDiscoverAllTests.cs (26)
73File.WriteAllText(sidecarPath, "{\"source\":\"script\"}"); 74var originalMode = File.GetUnixFileMode(sidecarPath); 78File.SetUnixFileMode(sidecarPath, UnixFileMode.None); 93File.SetUnixFileMode(sidecarPath, originalMode | UnixFileMode.UserRead | UnixFileMode.UserWrite); 105File.WriteAllText(sidecarPath, "{not valid json"); 131File.WriteAllText(Path.Combine(binDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"script\"}"); 279File.WriteAllText(Path.Combine(prDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"pr\"}"); 303File.WriteAllText(Path.Combine(binDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"script\"}"); 328File.WriteAllText(Path.Combine(binDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"script\"}"); 369File.WriteAllText(Path.Combine(prDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"pr\"}"); 403File.WriteAllText(Path.Combine(prDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"pr\"}"); 438File.WriteAllText(Path.Combine(brewDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"brew\"}"); 474File.WriteAllText(Path.Combine(brewDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"brew\"}"); 639var originalMode = File.GetUnixFileMode(dogfoodRoot); 643File.SetUnixFileMode(dogfoodRoot, UnixFileMode.None); 666File.SetUnixFileMode(dogfoodRoot, originalMode | UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 682var originalMode = File.GetUnixFileMode(toolStore); 686File.SetUnixFileMode(toolStore, UnixFileMode.None); 716File.SetUnixFileMode(toolStore, originalMode | UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 765File.WriteAllText(Path.Combine(releaseBinDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"script\"}"); 795File.WriteAllText(Path.Combine(releaseBinDir, InstallSidecarReader.SidecarFileName), "{\"source\":\"localhive\"}"); 862Assert.True(File.Exists(firmlinkedProcessPath), "firmlinked /private/var path should resolve to the same file"); 957var resolved = File.ResolveLinkTarget(path, returnFinalTarget: true); 1010File.WriteAllBytes(path, [0x00]); // existence is what matters 1016File.SetUnixFileMode(path, 1027File.WriteAllText(Path.Combine(dir, InstallSidecarReader.SidecarFileName), $"{{\"source\":\"{source}\"}}");
Acquisition\InstallSidecarReaderTests.cs (11)
77var originalMode = File.GetUnixFileMode(sidecarPath); 81File.SetUnixFileMode(sidecarPath, UnixFileMode.None); 92File.SetUnixFileMode(sidecarPath, originalMode | UnixFileMode.UserRead | UnixFileMode.UserWrite); 191var originalMode = File.GetUnixFileMode(sidecarPath); 195File.SetUnixFileMode(sidecarPath, UnixFileMode.None); 203File.SetUnixFileMode(sidecarPath, originalMode | UnixFileMode.UserRead | UnixFileMode.UserWrite); 237File.WriteAllText(sidecarPath, $"{{\"source\":\"{oversized}\"}}"); 253File.WriteAllText(sidecarPath, $"{{\"source\":\"{oversized}\"}}"); 269File.WriteAllBytes(sidecarPath, bytes); 287File.WriteAllBytes(sidecarPath, bytes); 364File.WriteAllText(path, content);
Acquisition\InstallSidecarWriterTests.cs (10)
16File.WriteAllText( 31using (var originalDocument = JsonDocument.Parse(File.ReadAllBytes(sidecarPath))) 38using var document = JsonDocument.Parse(File.ReadAllBytes(sidecarPath)); 56Assert.False(File.Exists(sidecarPath)); 65File.WriteAllText(sidecarPath, malformedContent); 69Assert.Equal(malformedContent, File.ReadAllText(sidecarPath)); 82File.WriteAllText(sidecarPath, originalContent); 89Assert.Equal(originalContent, File.ReadAllText(sidecarPath)); 99File.WriteAllText(sidecarPath, originalContent); 103Assert.Equal(originalContent, File.ReadAllText(sidecarPath));
Acquisition\PeerInstallProbeTests.cs (8)
92Assert.True(File.Exists(fakePeer.ArgvFile), $"Expected argv recorder file at {fakePeer.ArgvFile} to exist."); 93var argv = await File.ReadAllLinesAsync(fakePeer.ArgvFile, TestContext.Current.CancellationToken); 431if (File.Exists(pidFile)) 433var pidText = await File.ReadAllTextAsync(pidFile, cancellationToken); 527File.WriteAllText(path, content); 531File.SetUnixFileMode(path, 549File.WriteAllText(path, content); 555File.SetUnixFileMode(path,
Acquisition\WingetRegistryProbeTests.cs (6)
26Assert.Equal(expectSidecar, File.Exists(sidecarPath)); 30using var doc = JsonDocument.Parse(File.ReadAllBytes(sidecarPath)); 52File.WriteAllText(sidecarPath, preSeededContent); 59Assert.Equal(preSeededContent, File.ReadAllText(sidecarPath)); 90Assert.True(File.Exists(sidecarPath)); 96using var doc = JsonDocument.Parse(File.ReadAllBytes(sidecarPath));
Agents\AspireSkillsBundleTests.cs (14)
146await File.WriteAllTextAsync(skillPath, CreateSkillFileContent()); 189await File.WriteAllTextAsync(Path.Combine(skillDirectory, "SKILL.md"), CreateSkillFileContent()); 232await File.WriteAllTextAsync(Path.Combine(bundleDirectory, "skill-manifest.json"), "{"); 510await File.WriteAllTextAsync(Path.Combine(bundleDirectory, "skills", CommonAgentApplicators.AspireSkillName, "SKILL.md"), CreateSkillFileContent()); 558await File.WriteAllTextAsync(skillPath, CreateSkillFileContent()); 640await File.WriteAllTextAsync(skillPath, skillContent); 663await File.WriteAllTextAsync(Path.Combine(bundleDirectory, "skill-manifest.json"), manifestJson); 685await File.WriteAllTextAsync(skillPath, CreateSkillFileContent()); 805await File.WriteAllTextAsync(skillPath, "tampered"); 844await File.WriteAllTextAsync(fullPath, content); 885await File.WriteAllTextAsync(Path.Combine(skillDirectory, "SKILL.md"), content); 908return File.WriteAllTextAsync(Path.Combine(bundleDirectory, "skill-manifest.json"), manifestJson); 913using var stream = File.OpenRead(path); 919using var stream = File.OpenRead(path);
Agents\AspireSkillsInstallerTests.cs (29)
229Assert.True(File.Exists(Path.Combine( 282Assert.False(File.Exists(Path.Combine( 345await File.ReadAllTextAsync(Path.Combine( 350await File.ReadAllTextAsync(Path.Combine( 407await File.ReadAllTextAsync(Path.Combine( 457Assert.False(File.Exists(Path.Combine(cachedBundleDirectory, "skill-manifest.json"))); 464await File.ReadAllTextAsync(Path.Combine( 487await File.WriteAllTextAsync(Path.Combine(cachedBundleDirectory, "skill-manifest.json"), "{"); 560await File.WriteAllTextAsync( 878Assert.True(File.Exists(Path.Combine( 1037Assert.False(File.Exists($"{activeTemporaryDirectory}.lock")); 1460Assert.True(File.Exists(Path.Combine(targetDirectory, "skill-manifest.json"))); 1479await File.WriteAllBytesAsync(archivePath, archiveBytes); 1508await File.WriteAllBytesAsync(archivePath, archiveBytes); 1609await File.ReadAllTextAsync(Path.Combine( 1614await File.ReadAllTextAsync(Path.Combine( 1776Assert.False(File.Exists(Path.Combine( 2015await File.WriteAllTextAsync(skillPath, 2048await File.WriteAllTextAsync(Path.Combine(bundleDirectory, "skill-manifest.json"), manifestJson); 2052await File.WriteAllTextAsync(Path.Combine(bundleDirectory, AspireSkillsInstaller.ArchiveSha512FileName), archiveSha512); 2057await File.WriteAllTextAsync( 2064await File.WriteAllTextAsync( 2072return File.WriteAllTextAsync( 2101await File.WriteAllTextAsync( 2107await File.WriteAllTextAsync(Path.Combine(bundleDirectory, "skill-manifest.json"), "{"); 2111File.Delete(Path.Combine(bundleDirectory, "skills", CommonAgentApplicators.AspireSkillName, "SKILL.md")); 2135using var stream = File.OpenRead(path); 2286await File.WriteAllBytesAsync(archivePath, ArchiveBytes, cancellationToken); 2296File.Delete(archivePath);
Agents\ClaudeCodeAgentEnvironmentScannerTests.cs (4)
26await File.WriteAllTextAsync(mcpJsonPath, "{ invalid json content"); 54await File.WriteAllTextAsync(mcpJsonPath, ""); 80await File.WriteAllTextAsync(mcpJsonPath, originalContent); 96var currentContent = await File.ReadAllTextAsync(mcpJsonPath);
Agents\CopilotCliAgentEnvironmentScannerTests.cs (9)
58Assert.True(File.Exists(mcpConfigPath)); 60var content = await File.ReadAllTextAsync(mcpConfigPath); 111await File.WriteAllTextAsync(mcpConfigPath, existingConfig.ToJsonString()); 121var content = await File.ReadAllTextAsync(mcpConfigPath); 151await File.WriteAllTextAsync(mcpConfigPath, existingConfig.ToJsonString()); 209await File.WriteAllTextAsync(mcpConfigPath, "{ invalid json content"); 237await File.WriteAllTextAsync(mcpConfigPath, ""); 263await File.WriteAllTextAsync(mcpConfigPath, originalContent); 279var currentContent = await File.ReadAllTextAsync(mcpConfigPath);
Agents\OpenCodeAgentEnvironmentScannerTests.cs (4)
24await File.WriteAllTextAsync(configPath, "{ invalid json content"); 50await File.WriteAllTextAsync(configPath, ""); 74await File.WriteAllTextAsync(configPath, originalContent); 89var currentContent = await File.ReadAllTextAsync(configPath);
Agents\PlaywrightCliInstallerTests.cs (24)
196await File.WriteAllBytesAsync(tarballPath, content); 242await File.WriteAllBytesAsync(tarballPath, content); 287await File.WriteAllBytesAsync(tarballPath, content); 331await File.WriteAllBytesAsync(tarballPath, content); 380File.WriteAllBytes(tempPath, content); 471await File.WriteAllBytesAsync(tarballPath, [10, 20, 30]); 637File.WriteAllText(Path.Combine(skillDir, "SKILL.md"), "# Playwright CLI Skill"); 639File.WriteAllText(Path.Combine(skillDir, "subdir", "extra.md"), "Extra content"); 661Assert.True(File.Exists(Path.Combine(tempDir, ".agents", "skills", "playwright-cli", "SKILL.md"))); 662Assert.True(File.Exists(Path.Combine(tempDir, ".agents", "skills", "playwright-cli", "subdir", "extra.md"))); 663Assert.Equal("# Playwright CLI Skill", await File.ReadAllTextAsync(Path.Combine(tempDir, ".agents", "skills", "playwright-cli", "SKILL.md"))); 666Assert.True(File.Exists(Path.Combine(tempDir, ".github", "skills", "playwright-cli", "SKILL.md"))); 667Assert.True(File.Exists(Path.Combine(tempDir, ".github", "skills", "playwright-cli", "subdir", "extra.md"))); 689File.WriteAllText(Path.Combine(sourceDir, "keep.md"), "keep"); 693File.WriteAllText(Path.Combine(targetDir, "keep.md"), "old content"); 694File.WriteAllText(Path.Combine(targetDir, "stale.md"), "should be removed"); 696File.WriteAllText(Path.Combine(targetDir, "stale-dir", "old.md"), "should be removed"); 701Assert.Equal("keep", File.ReadAllText(Path.Combine(targetDir, "keep.md"))); 704Assert.False(File.Exists(Path.Combine(targetDir, "stale.md"))); 734File.WriteAllText(Path.Combine(skillDir, "SKILL.md"), "# Playwright CLI Skill"); 755Assert.True(File.Exists(Path.Combine(tempDir, ".agents", "skills", "playwright-cli", "SKILL.md"))); 780await File.WriteAllTextAsync(Path.Combine(preExistingDir, "SKILL.md"), "# User's existing skill"); 835File.WriteAllText(Path.Combine(skillDir, "SKILL.md"), "# Playwright CLI Skill"); 1025File.WriteAllBytes(PackResult, [1, 2, 3]);
Agents\TelemetryHookConfiguratorTests.cs (12)
28Assert.True(File.Exists(hookFile)); 30var root = JsonNode.Parse(await File.ReadAllTextAsync(hookFile).DefaultTimeout())!.AsObject(); 57Assert.True(File.Exists(Path.Combine(copilotHome.FullName, "hooks", "aspire-telemetry.json"))); 138await File.WriteAllTextAsync(settingsPath, existing.ToJsonString()).DefaultTimeout(); 143var root = JsonNode.Parse(await File.ReadAllTextAsync(settingsPath).DefaultTimeout())!.AsObject(); 159await File.WriteAllTextAsync(settingsPath, malformed).DefaultTimeout(); 167Assert.Equal(malformed, await File.ReadAllTextAsync(settingsPath).DefaultTimeout()); 178await File.WriteAllTextAsync(settingsPath, unexpected).DefaultTimeout(); 184Assert.Equal(unexpected, await File.ReadAllTextAsync(settingsPath).DefaultTimeout()); 198await File.WriteAllTextAsync(settingsPath, nonObjectRoot).DefaultTimeout(); 204Assert.Equal(nonObjectRoot, await File.ReadAllTextAsync(settingsPath).DefaultTimeout()); 229var root = JsonNode.Parse(await File.ReadAllTextAsync(settingsPath))!.AsObject();
Agents\TelemetryHookInstallerTests.cs (9)
25Assert.True(File.Exists(scripts.ShellScriptPath)); 26Assert.True(File.Exists(scripts.PowerShellScriptPath)); 38var bytes = await File.ReadAllBytesAsync(scripts.ShellScriptPath).DefaultTimeout(); 43var content = await File.ReadAllTextAsync(scripts.ShellScriptPath).DefaultTimeout(); 55var firstShellContent = await File.ReadAllTextAsync(first.ShellScriptPath).DefaultTimeout(); 58var secondShellContent = await File.ReadAllTextAsync(second.ShellScriptPath).DefaultTimeout(); 74await File.WriteAllTextAsync(shellPath, "stale-content").DefaultTimeout(); 78var content = await File.ReadAllTextAsync(scripts.ShellScriptPath).DefaultTimeout(); 97var mode = File.GetUnixFileMode(scripts.ShellScriptPath);
Agents\TelemetryHookScriptTests.cs (5)
415File.WriteAllText(path, "#!/bin/bash\nprintf '%s\\n' \"$@\" > \"$ASPIRE_HOOK_TEST_CAPTURE_FILE\"\n"); 418File.SetUnixFileMode(path, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute 429File.WriteAllText(path, "$args | Set-Content -LiteralPath $env:ASPIRE_HOOK_TEST_CAPTURE_FILE\n"); 453=> File.Exists(capturePath) 454? File.ReadAllLines(capturePath).Where(line => line.Length > 0).ToArray()
Agents\VsCodeAgentEnvironmentScannerTests.cs (11)
127Assert.True(File.Exists(mcpJsonPath)); 144Assert.True(File.Exists(mcpJsonPath)); 146var content = await File.ReadAllTextAsync(mcpJsonPath); 189await File.WriteAllTextAsync(mcpJsonPath, existingConfig.ToJsonString()); 199var content = await File.ReadAllTextAsync(mcpJsonPath); 230await File.WriteAllTextAsync(mcpJsonPath, existingConfig.ToJsonString()); 245var content = await File.ReadAllTextAsync(mcpJsonPath); 282await File.WriteAllTextAsync(mcpJsonPath, "{ invalid json content"); 310await File.WriteAllTextAsync(mcpJsonPath, ""); 336await File.WriteAllTextAsync(mcpJsonPath, originalContent); 352var currentContent = await File.ReadAllTextAsync(mcpJsonPath);
AssemblyMetadataChannelTests.cs (2)
42Assert.True(File.Exists(csprojPath), $"Expected csproj at {csprojPath}"); 61while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "global.json")))
Backchannel\AppHostCliBackchannelTests.cs (2)
35await File.WriteAllBytesAsync(tempFile, new byte[2048]); // 2 KB exceeds the 1 KB limit 70await File.WriteAllBytesAsync(tempFile, new byte[1024]); // 1 KB, below the 4 KB limit
Backchannel\AppHostConnectionResolverTests.cs (5)
92Assert.False(File.Exists(socketPath)); 292File.WriteAllText(realProjectFile.FullName, "<Project />"); 324Assert.False(File.Exists(socketPath)); 515File.WriteAllText(projectFile.FullName, "<Project />"); 529File.WriteAllText(socketPath, "");
Backchannel\OrphanedAppHostCollectorTests.cs (5)
244Assert.False(File.Exists(socketPath)); 270Assert.True(File.Exists(socketPath)); 302Assert.True(File.Exists(throwingSocket)); 303Assert.False(File.Exists(okSocket)); 370File.WriteAllText(path, string.Empty);
BundleNuGetServiceTests.cs (4)
23File.WriteAllText(managedPath, "old"); 24File.SetLastWriteTimeUtc(managedPath, new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc)); 28File.WriteAllText(managedPath, "new-content"); 29File.SetLastWriteTimeUtc(managedPath, new DateTime(2026, 1, 2, 0, 0, 0, DateTimeKind.Utc));
Bundles\BundleServiceCrossRouteExtractionTests.cs (2)
75File.WriteAllText(processPath, "fake-binary"); 85File.WriteAllText(sidecarPath, content);
BundleServiceComputeDefaultExtractDirTests.cs (12)
37File.WriteAllText(binaryPath, string.Empty); 38File.WriteAllText(Path.Combine(binDir, SidecarFileName), $"{{\"source\":\"{source}\"}}"); 60File.WriteAllText(binaryPath, string.Empty); 61File.WriteAllText(Path.Combine(binDir, SidecarFileName), "{\"source\":\"pr\"}"); 80File.WriteAllText(binaryPath, string.Empty); 81File.WriteAllText(Path.Combine(installDir, SidecarFileName), "{\"source\":\"winget\"}"); 106File.WriteAllText(cellarBinary, string.Empty); 107File.WriteAllText(Path.Combine(cellarDir, SidecarFileName), "{\"source\":\"brew\"}"); 112File.CreateSymbolicLink(symlinkPath, cellarBinary); 145File.WriteAllText(binaryPath, string.Empty); 146File.WriteAllText(Path.Combine(ridDir, SidecarFileName), "{\"source\":\"dotnet-tool\"}"); 165File.WriteAllText(binaryPath, string.Empty);
BundleServiceIntegrationTests.cs (19)
65Assert.True(File.Exists(managedExe), $"managed exe should exist at {managedExe}"); 119File.SetLastWriteTimeUtc(v2BinaryPath, File.GetLastWriteTimeUtc(v1BinaryPath).AddHours(1)); 154var content = File.ReadAllText(managedExe); 223File.WriteAllText(lockedFilePath, "locked"); 254File.SetLastWriteTimeUtc(v2BinaryPath, File.GetLastWriteTimeUtc(v1BinaryPath).AddHours(1)); 259File.WriteAllText(Path.Combine(binDir, ".aspire-install.json"), "{\"source\":\"script\"}"); 319File.WriteAllText(Path.Combine(leasesDir, "orphan.lease"), "{}"); 363File.WriteAllText(Path.Combine(ridDir, ".aspire-install.json"), "{\"source\":\"dotnet-tool\"}"); 379Assert.True(File.Exists(managedExe), $"managed exe should exist at {managedExe}"); 444Assert.True(File.Exists(managedExe), $"managed exe should exist at {managedExe}"); 493Assert.True(File.Exists(managedExe)); 495var content = File.ReadAllText(managedExe); 515File.SetLastWriteTimeUtc(v2BinaryPath, File.GetLastWriteTimeUtc(v1BinaryPath).AddHours(1)); 615File.WriteAllText(path, content); 634if (!Directory.Exists(managedDir) || !File.Exists(managedExe) || !Directory.Exists(dcpDir) || !File.Exists(dcpExe))
BundleServiceTests.cs (9)
78File.WriteAllText(processPath, "old"); 79File.SetLastWriteTimeUtc(processPath, new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc)); 83File.WriteAllText(processPath, "new-content"); 84File.SetLastWriteTimeUtc(processPath, new DateTime(2026, 1, 2, 0, 0, 0, DateTimeKind.Utc)); 133File.Delete(managedExe); 137File.WriteAllBytes(managedExe, []); 159File.Delete(BundleDiscovery.GetDcpExecutablePath(Path.Combine(dir, BundleDiscovery.DcpDirectoryName))); 233File.WriteAllText( 239File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDir), "dcp");
Caching\AppHostInfoDiskCacheTests.cs (52)
37File.WriteAllText(path, "<Project Sdk=\"Microsoft.NET.Sdk\" />"); 116using var document = JsonDocument.Parse(await File.ReadAllTextAsync(cachePath)); 152File.WriteAllText(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />\n<!-- edit -->"); 153File.SetLastWriteTimeUtc(projectFile.FullName, DateTime.UtcNow.AddSeconds(2)); 172File.WriteAllText(assetsPath, "{}"); 189File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "Directory.Packages.props"), "<Project />"); 199File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), """ 267File.WriteAllText(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />\n<!-- edit -->"); 268File.SetLastWriteTimeUtc(projectFile.FullName, DateTime.UtcNow.AddSeconds(2)); 290File.WriteAllText(projectFile.FullName, """ 297File.WriteAllText(commonProps, "<Project />"); 302File.WriteAllText(commonProps, """ 309File.SetLastWriteTimeUtc(commonProps, DateTime.UtcNow.AddSeconds(2)); 325File.WriteAllText(projectFile.FullName, """ 354File.WriteAllText(projectFile.FullName, """ 358File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "repo", "Directory.Build.props"), """ 366File.WriteAllText(sharedProps, "<Project />"); 371File.WriteAllText(sharedProps, """ 378File.SetLastWriteTimeUtc(sharedProps, DateTime.UtcNow.AddSeconds(2)); 391File.WriteAllText(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />"); 392File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "repo", "Directory.Build.props"), """ 400File.WriteAllText(sharedProps, "<Project />"); 405File.WriteAllText(sharedProps, """ 412File.SetLastWriteTimeUtc(sharedProps, DateTime.UtcNow.AddSeconds(2)); 424File.WriteAllText(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />"); 425File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "repo", "Directory.Build.props"), """ 449File.WriteAllText(projectFile.FullName, """ 453File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "repo", "Directory.Build.props"), """ 478File.WriteAllText(projectFile.FullName, """ 484File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "Aspire.Common"), ""); 486File.WriteAllText(commonProps, "<Project />"); 491File.WriteAllText(commonProps, """ 498File.SetLastWriteTimeUtc(commonProps, DateTime.UtcNow.AddSeconds(2)); 513File.WriteAllText(projectFile.FullName, """ 532File.WriteAllText(projectFile.FullName, """ 558File.WriteAllText(projectFile.FullName, """ 562File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "Directory.Build.props"), """ 567File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "repo", "Directory.Build.props"), """ 594File.WriteAllText(projectFile.FullName, """ 600File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "Repo.marker"), ""); 602File.WriteAllText(customProps, "<Project />"); 607File.WriteAllText(customProps, """ 614File.SetLastWriteTimeUtc(customProps, DateTime.UtcNow.AddSeconds(2)); 630File.WriteAllText(projectFile.FullName, """ 654File.WriteAllText(projectFile.FullName, """ 729File.WriteAllText(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />"); 732File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "Directory.Build.props"), "<Project />"); 744File.WriteAllText(parentImport, "<Project />"); 747File.WriteAllText( 753File.WriteAllText(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />"); 757File.WriteAllText(parentImport, "<Project><!-- above git boundary edit --></Project>"); 758File.SetLastWriteTimeUtc(parentImport, DateTime.UtcNow.AddSeconds(2));
Caching\DiskCacheTests.cs (2)
126File.Move(current, oldName, overwrite: true); 131Assert.False(File.Exists(oldName));
Certificates\DeveloperCertificateCacheWriteTests.cs (4)
37File.WriteAllBytes(onDiskPfxPath, certificate.Export(X509ContentType.Pfx)); 45Assert.True(File.Exists(cachedPfxPath)); 46Assert.True(File.Exists(cachedKeyPath)); 49Assert.StartsWith("-----BEGIN PRIVATE KEY-----", File.ReadAllText(cachedKeyPath), StringComparison.Ordinal);
Certificates\NativeCertificateToolRunnerTests.cs (6)
103File.SetLastWriteTimeUtc(firstResult, lastWriteTime); 104lastWriteTime = File.GetLastWriteTimeUtc(firstResult); 109Assert.Equal(pemContents, File.ReadAllText(firstResult)); 110Assert.Equal(lastWriteTime, File.GetLastWriteTimeUtc(secondResult)); 122File.GetUnixFileMode(outputDirectory)); 125File.GetUnixFileMode(firstResult));
Certificates\UnixCertificateManagerTests.cs (9)
126File.WriteAllText(certificatePath, "not a certificate"); 161File.WriteAllText(Path.Combine(corruptOpenSslDirectory.FullName, certificateFileName), "not a certificate"); 162File.WriteAllText(Path.Combine(validOpenSslDirectory.FullName, certificateFileName), certificate.ExportCertificatePem()); 197File.WriteAllText(certificatePath, "not a certificate"); 202Assert.False(File.Exists(certificatePath)); 256await File.WriteAllTextAsync(certUtilFile.FullName, script); 257File.SetUnixFileMode( 281await File.WriteAllTextAsync(certUtilFile.FullName, script); 282File.SetUnixFileMode(
CliBootstrapTests.cs (2)
265File.WriteAllText(binaryPath, string.Empty); 267File.WriteAllText(Path.Combine(binaryDir, InstallSidecarReader.SidecarFileName), $$"""{"source":"{{source}}"{{channelField}}}""");
CliExecutionContextTests.cs (2)
109File.WriteAllText(Path.Combine(hivesDir.FullName, "README.md"), "stray"); 110File.WriteAllText(Path.Combine(hivesDir.FullName, ".DS_Store"), string.Empty);
Commands\AddCommandTests.cs (35)
389File.WriteAllText(appHostFile.FullName, string.Empty); 390File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), """ 462File.WriteAllText(appHostFile.FullName, string.Empty); 463File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), """ 543File.WriteAllText(appHostFile.FullName, string.Empty); 544File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), """ 642File.WriteAllText(appHostFile.FullName, string.Empty); 645File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), $$""" 726File.WriteAllText(appHostFile.FullName, string.Empty); 727File.WriteAllText(Path.Combine(projectDirectory.FullName, AspireConfigFile.FileName), """ 770File.WriteAllText(appHostFile.FullName, string.Empty); 843File.WriteAllText(appHostFile.FullName, string.Empty); 844File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), """ 2491File.WriteAllText(appHostFile.FullName, isTypeScript ? string.Empty : "<Project />"); 2495File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), $$""" 2600File.WriteAllText(appHostFile.FullName, string.Empty); 2601File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), """ 2814File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.{cliVersion}.nupkg"), string.Empty); 2815File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.Redis.{cliVersion}.nupkg"), string.Empty); 2852File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.{cliVersion}.nupkg"), string.Empty); 2853File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.Redis.{cliVersion}.nupkg"), string.Empty); 2855File.WriteAllText(Path.Combine(prPackagesDir.FullName, $"Aspire.Hosting.{staleVersion}.nupkg"), string.Empty); 2856File.WriteAllText(Path.Combine(prPackagesDir.FullName, $"Aspire.Hosting.Redis.{staleVersion}.nupkg"), string.Empty); 2882File.WriteAllText(Path.Combine(identityPackagesDir.FullName, $"Aspire.Hosting.{cliVersion}.nupkg"), string.Empty); 2883File.WriteAllText(Path.Combine(identityPackagesDir.FullName, $"Aspire.Hosting.Redis.{cliVersion}.nupkg"), string.Empty); 3011File.WriteAllText(appHostFile.FullName, string.Empty); 3061File.WriteAllText(appHostFile.FullName, string.Empty); 3111File.WriteAllText(appHostFile.FullName, string.Empty); 3165File.WriteAllText(appHostFile.FullName, string.Empty); 3213File.WriteAllText(appHostFile.FullName, string.Empty); 3261File.WriteAllText(appHostFile.FullName, string.Empty); 3309File.WriteAllText(appHostFile.FullName, string.Empty); 3361File.WriteAllText(appHostFile.FullName, string.Empty); 3412File.WriteAllText(appHostFile.FullName, string.Empty); 3470File.WriteAllText(appHostFile.FullName, string.Empty);
Commands\AgentInitCommandTests.cs (6)
103await File.WriteAllTextAsync(blockedSkillParentPath, "blocked").DefaultTimeout(); 836Assert.True(File.Exists(skillPath), $"Expected skill file at {skillPath}"); 850await File.WriteAllTextAsync(skillPath, $$""" 887await File.WriteAllTextAsync(manifestPath, manifestJson); 895using var stream = File.OpenRead(path); 918Assert.True(File.Exists(hookFile), $"Expected telemetry hook at {hookFile}");
Commands\AppHostLauncherTests.cs (9)
89File.WriteAllText(realProjectPath, "<Project />"); 397Assert.False(File.Exists(socketPath)); 962await File.WriteAllLinesAsync(childLogFile, [ 990await File.WriteAllLinesAsync(childLogFile, [ 1013await File.WriteAllLinesAsync(childLogFile, [ 1075await File.WriteAllLinesAsync(childLogFile, [ 1167File.WriteAllText(appHostFile.FullName, "<Project />"); 1258File.WriteAllText(socketPath, ""); 1346File.WriteAllLines(childLogFile, ChildLogLines);
Commands\CacheCommandTests.cs (12)
49File.WriteAllText(Path.Combine(restoreDir.FullName, "test.dll"), "fake"); 63Assert.False(File.Exists(Path.Combine(restoreDir.FullName, "test.dll"))); 73await File.WriteAllTextAsync(cacheEntry, "{}").DefaultTimeout(); 84Assert.False(File.Exists(cacheEntry)); 105await File.WriteAllTextAsync(Path.Combine(firstBuildCache.FullName, "Aspire.Hosting.dll"), "fake").DefaultTimeout(); 106await File.WriteAllTextAsync(Path.Combine(secondBuildCache.FullName, "Aspire.Hosting.dll"), "fake").DefaultTimeout(); 171File.WriteAllText(Path.Combine(tempDir.FullName, "root.txt"), "root"); 172File.WriteAllText(Path.Combine(subDir.FullName, "nested.txt"), "nested"); 198File.WriteAllText(keepFile, "keep"); 199File.WriteAllText(deleteFile, "delete"); 206Assert.True(File.Exists(keepFile)); 207Assert.False(File.Exists(deleteFile));
Commands\ConfigCommandTests.cs (25)
123Assert.True(File.Exists(settingsPath)); 125var json = await File.ReadAllTextAsync(settingsPath); 150var settingsJson = await File.ReadAllTextAsync(settingsPath); 183Assert.True(File.Exists(settingsPath)); 185var json = await File.ReadAllTextAsync(settingsPath); 208Assert.True(File.Exists(settingsPath)); 210var json = await File.ReadAllTextAsync(settingsPath); 242var json = await File.ReadAllTextAsync(settingsPath); 362var json = await File.ReadAllTextAsync(settingsPath); 691var json = await File.ReadAllTextAsync(settingsPath); 723var json = await File.ReadAllTextAsync(settingsPath); 754var json = await File.ReadAllTextAsync(settingsPath); 785var json = await File.ReadAllTextAsync(settingsPath); 801await File.WriteAllTextAsync(settingsPath, """ 815var json = await File.ReadAllTextAsync(settingsPath); 834await File.WriteAllTextAsync(settingsPath, """ 848var json = await File.ReadAllTextAsync(settingsPath); 874var json = await File.ReadAllTextAsync(configPath); 891await File.WriteAllTextAsync(legacySettingsPath, """{ "channel": "daily" }"""); 904var json = await File.ReadAllTextAsync(configPath); 937if (File.Exists(settingsPath)) 939var json = await File.ReadAllTextAsync(settingsPath); 961var json = await File.ReadAllTextAsync(settingsPath); 1001Assert.False(File.Exists(configPath)); 1019var json = await File.ReadAllTextAsync(settingsPath);
Commands\DashboardRunCommandTests.cs (1)
634File.WriteAllText(managedPath, "fake");
Commands\DeployCommandTests.cs (1)
88await File.WriteAllTextAsync(appHostFile.FullName, "<Project />");
Commands\DoctorCommandTests.cs (19)
85Assert.SkipUnless(File.Exists("/etc/os-release"), "Linux /etc/os-release is required for this test."); 88await File.ReadAllTextAsync("/etc/os-release", TestContext.Current.CancellationToken)); 167await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 194await File.WriteAllTextAsync(appHostFile.FullName, "export {};"); 195await File.WriteAllTextAsync( 243await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 270await File.WriteAllTextAsync(projectFile.FullName, "<Project />"); 298await File.WriteAllTextAsync(projectFile.FullName, "<Project />"); 301await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 323await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"), "<Project />"); 324await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.fsproj"), "<Project />"); 351await File.WriteAllTextAsync(appHostFile.FullName, "export {};"); 405await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 406await File.WriteAllTextAsync( 496await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 497await File.WriteAllTextAsync( 527await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 528await File.WriteAllTextAsync( 561await File.WriteAllTextAsync(appHostFile.FullName, "<Project />");
Commands\DotNetSdkCheckTests.cs (1)
105await File.WriteAllTextAsync(filePath, "");
Commands\ExportCommandTests.cs (15)
66Assert.True(File.Exists(outputPath), "Export zip file should be created"); 137Assert.True(File.Exists(outputPath), $"Export zip file should be created at the specified path: {outputPath}"); 155File.WriteAllText(appHostProjectPath, "<Project />"); 172Assert.False(File.Exists(outputPath), "No zip should be created when the AppHost is not running"); 285Assert.True(File.Exists(outputPath), "Export zip file should be created"); 347Assert.True(File.Exists(outputPath), "Export zip file should be created"); 465Assert.True(File.Exists(outputPath), "Export zip file should be created"); 523Assert.True(File.Exists(outputPath), "Export zip file should be created"); 583Assert.True(File.Exists(outputPath), "Export zip file should be created"); 633Assert.True(File.Exists(outputPath)); 675Assert.True(File.Exists(outputPath)); 719Assert.True(File.Exists(outputPath)); 755Assert.False(File.Exists(outputPath), "No zip should be created when the resource doesn't exist"); 794Assert.True(File.Exists(outputPath), "Export zip file should be created"); 841Assert.True(File.Exists(outputPath), "Export zip file should be created even without dashboard");
Commands\ExtensionInternalCommandTests.cs (1)
103await File.WriteAllTextAsync(projectFile.FullName, """
Commands\InitCommandTests.cs (82)
67File.WriteAllText(solutionFile.FullName, "Fake solution file"); 70File.WriteAllText(projectFile.FullName, "<Project />"); 109Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json"))); 118File.WriteAllText(solutionFile.FullName, "Fake solution file"); 150Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json"))); 166Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 168var config = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json")))!.AsObject(); 194Assert.True(File.Exists(runJsonPath), "apphost.run.json should be created so `dotnet run apphost.cs` works."); 196var runJson = JsonNode.Parse(File.ReadAllText(runJsonPath))!.AsObject(); 220var aspireConfig = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json")))!.AsObject(); 263File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json"), existingAspireConfig); 274var runJson = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.run.json")))!.AsObject(); 314File.WriteAllText(aspireConfigPath, customAspireConfig); 327var aspireConfig = JsonNode.Parse(File.ReadAllText(aspireConfigPath))!.AsObject(); 338Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.run.json"))); 362Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 397Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"))); 399var config = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json")))!.AsObject(); 412File.WriteAllText(existingAppHostPath, existingAppHostContent); 413File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), """{ "type": "commonjs" }"""); 427Assert.Equal(existingAppHostContent, File.ReadAllText(existingAppHostPath)); 428Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"))); 429Assert.Equal("""{ "type": "commonjs" }""", File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"))); 436File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{}"); 445File.WriteAllText(Path.Combine(scaffoldDirectory.FullName, context.Language.AppHostFileName!), string.Empty); 475Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"))); 476Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire-apphost", "apphost.mts"))); 587Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 609Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 629Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 632Assert.True(File.Exists(aspireSkillPath), $"Expected aspire skill file at {aspireSkillPath}"); 654var appHostContent = await File.ReadAllTextAsync(appHostPath); 677await File.WriteAllTextAsync(configPath, existingConfig.ToJsonString()); 688var merged = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!.AsObject(); 705await File.WriteAllTextAsync(configPath, "{ this is not json"); 725await File.WriteAllTextAsync(appHostPath, preExistingContent); 735Assert.Equal(preExistingContent, await File.ReadAllTextAsync(appHostPath)); 744File.WriteAllText(solutionFile.FullName, "Fake solution file"); 787File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config")), 797File.WriteAllText(solutionFile.FullName, "Fake solution file"); 874File.WriteAllText(solutionFile.FullName, "Fake solution file"); 940File.WriteAllText(solutionFile.FullName, "Fake solution file"); 989File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1058Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 1061Assert.True(File.Exists(nugetConfigPath), $"nuget.config should be created in workspace for channel '{contextChannel}'."); 1093Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"))); 1096Assert.False(File.Exists(nugetConfigPath), "stable-identity init must not drop a nuget.config (stable packages resolve from ambient nuget.org)."); 1131Assert.True(File.Exists(configPath)); 1133var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 1156await File.WriteAllTextAsync(configPath, existing.ToJsonString()); 1172var config = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!.AsObject(); 1204var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 1248var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 1364await File.WriteAllTextAsync(configPath, existing.ToJsonString()); 1470File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1549File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1637File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1658nugetConfigContentAtNewProjectTime = File.Exists(nugetConfigPath) 1659? File.ReadAllText(nugetConfigPath) 1676Assert.True(File.Exists(nugetConfigPath), $"nuget.config should be created in the solution directory for channel '{contextChannel}'."); 1698File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1727Assert.False(File.Exists(nugetConfigPath), "stable-identity init must not drop a nuget.config (stable packages resolve from ambient nuget.org)."); 1745File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1750Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config"))); 1772Assert.True(File.Exists(nugetConfigPath), "rerun must create the workspace nuget.config even though the AppHost dir already exists."); 1790File.WriteAllText(appHostPath, "#:sdk Aspire.AppHost.Sdk@13.4.0-staging.x\nbuilder.Build().Run();"); 1791Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config"))); 1809Assert.True(File.Exists(nugetConfigPath), "rerun must create the workspace nuget.config even though apphost.cs already exists."); 1828File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1857Assert.True(File.Exists(Path.Combine(solutionDir.FullName, "nuget.config")), 1859Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config")), 1878File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1890File.WriteAllText(nugetConfigPath, nugetConfigContent); 1920var merged = File.ReadAllText(nugetConfigPath); 1939File.WriteAllText(solutionFile.FullName, "Fake solution file"); 1971var content = File.ReadAllText(nugetConfigPath); 1994File.WriteAllText(solutionFile.FullName, "Fake solution file"); 2038File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config")), 2055File.WriteAllText(solutionFile.FullName, """<Solution />"""); 2085Assert.True(File.Exists(nugetConfigPath)); 2188File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, appHostFileName), string.Empty); 2198File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, AspireConfigFile.FileName), config.ToJsonString());
Commands\IntegrationAssemblyNameResolverTests.cs (1)
61File.WriteAllText(projectPath, content);
Commands\LsCommandTests.cs (2)
175await File.WriteAllTextAsync(configuredAppHost.FullName, "Not a real apphost"); 176await File.WriteAllTextAsync(Path.Combine(workingDirectory.FullName, "aspire.config.json"), JsonSerializer.Serialize(new
Commands\NewCommandChannelResolutionTests.cs (1)
681File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.ProjectTemplates.{version}.nupkg"), string.Empty);
Commands\NewCommandTemplateConfigPersistenceTests.cs (7)
260File.WriteAllText(Path.Combine(outputPath, $"{name}.generated"), templateName); 302Assert.True(File.Exists(appHostFile)); 303Assert.Contains(s_prVersion, await File.ReadAllTextAsync(appHostFile)); 310var csharpNuGetConfig = await File.ReadAllTextAsync(Path.Combine(outputDirectory, "nuget.config")); 334var dotNetNuGetConfig = await File.ReadAllTextAsync(Path.Combine(outputDirectory, "nuget.config")); 524File.WriteAllText(processPath, string.Empty); 527File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.ProjectTemplates.{s_prVersion}.nupkg"), string.Empty);
Commands\NewCommandTests.cs (63)
150Assert.True(File.Exists(nugetConfigPath)); 152var nugetConfig = await File.ReadAllTextAsync(nugetConfigPath); 966File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.mts"), "// test apphost"); 983Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "apphost.mts"))); 984Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "aspire.config.json"))); 1132File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "AppHost.java"), "package aspire;"); 1157File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json"), """ 1195File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "AppHost.java"), "package aspire;"); 1223File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.mts"), "// test apphost"); 1235Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "apphost.mts"))); 1312File.WriteAllText(Path.Combine(nestedDirectory.FullName, "Aspire.ProjectTemplates.9.2.0.nupkg"), string.Empty); 1357File.WriteAllText(Path.Combine(sourceOverride, "Aspire.ProjectTemplates.9.2.0.nupkg"), string.Empty); 1380File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, scaffoldFileName), "// test apphost"); 1405File.WriteAllText(Path.Combine(sourceOverride, "Aspire.ProjectTemplates.9.2.0.nupkg"), string.Empty); 1506File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.mts"), "// test apphost"); 1545File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "AppHost.java"), "package aspire;"); 1557Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "AppHost.java"))); 1581File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.py"), "# test apphost"); 1593Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "apphost.py"))); 1609Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "apphost.cs"))); 1639var appHostCreated = File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", "apphost.cs")); 1668Assert.True(File.Exists(aspireConfigPath)); 1669Assert.True(File.Exists(appHostRunJsonPath), "apphost.run.json must be emitted alongside aspire.config.json so dotnet run picks up matching URLs."); 1671var aspireConfig = await File.ReadAllTextAsync(aspireConfigPath); 1672var appHostRunJson = await File.ReadAllTextAsync(appHostRunJsonPath); 1702Assert.True(File.Exists(aspireConfigPath)); 1703Assert.True(File.Exists(appHostRunJsonPath), "apphost.run.json must be emitted alongside aspire.config.json so dotnet run picks up matching URLs."); 1705var aspireConfig = await File.ReadAllTextAsync(aspireConfigPath); 1706var appHostRunJson = await File.ReadAllTextAsync(appHostRunJsonPath); 1776Assert.True(File.Exists(aspireConfigPath)); 1777var aspireConfig = await File.ReadAllTextAsync(aspireConfigPath); 1783Assert.True(File.Exists(appHostRunJsonPath)); 1784var appHostRunJson = await File.ReadAllTextAsync(appHostRunJsonPath); 1952await File.WriteAllTextAsync(Path.Combine(context.TargetDirectory.FullName, "aspire.config.json"), """ 1983var configContent = await File.ReadAllTextAsync(configPath); 2047File.WriteAllText(Path.Combine(modulesDir.FullName, "aspire.mts"), "// generated sdk"); 2062Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "output", LanguageInfo.GeneratedFolderName, "aspire.mts"))); 2136File.WriteAllText(Path.Combine(sourceOverride, "Aspire.ProjectTemplates.9.2.0.nupkg"), string.Empty); 2171File.WriteAllText(Path.Combine(modulesDir.FullName, "aspire.ts"), "// generated sdk"); 2246File.WriteAllText(Path.Combine(sourceOverride, "Aspire.ProjectTemplates.9.2.0.nupkg"), string.Empty); 2368Assert.True(File.Exists(aspireSkillPath), $"Expected aspire skill file at {aspireSkillPath}"); 2509Assert.True(File.Exists(skillPath)); 2549Assert.False(File.Exists(skillPath)); 2914File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.ts"), "// test apphost"); 2930Assert.True(File.Exists(Path.Combine(expectedPath, "apphost.ts"))); 2940File.WriteAllText(Path.Combine(selectedParent.FullName, "existing.txt"), "existing content"); 2977File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.ts"), "// test apphost"); 2994Assert.True(File.Exists(Path.Combine(expectedPath, "apphost.ts"))); 3005File.WriteAllText(Path.Combine(collidingProject.FullName, "existing.txt"), "existing content"); 3130File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.ts"), "// test apphost"); 3147Assert.True(File.Exists(Path.Combine(expectedPath, "apphost.ts"))); 3199File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.ts"), "// test apphost"); 3215Assert.True(File.Exists(Path.Combine(selectedOutputPath.FullName, "apphost.ts"))); 3216Assert.False(File.Exists(Path.Combine(selectedOutputPath.FullName, projectName, "apphost.ts"))); 3253File.WriteAllText(Path.Combine(context.TargetDirectory.FullName, "apphost.ts"), "// test apphost"); 3269Assert.True(File.Exists(Path.Combine(expectedPath, "apphost.ts"))); 3295Assert.False(File.Exists(skillPath)); 3321Assert.True(File.Exists(skillPath)); 3323Assert.False(File.Exists(aspireifySkillPath)); 3349Assert.True(File.Exists(skillPath)); 3351Assert.False(File.Exists(aspireifySkillPath)); 3361File.WriteAllText(Path.Combine(existingDir.FullName, "file.txt"), "content"); 3410File.WriteAllText(Path.Combine(existingDir.FullName, "file.txt"), "content");
Commands\PublishCommandPromptingIntegrationTests.cs (7)
263await File.WriteAllTextAsync(selectedFile, "artifact"); 804await File.WriteAllTextAsync(oversizedFile, new string('x', 100)); 807await File.WriteAllTextAsync(validFile, "ok"); 850await File.WriteAllTextAsync(wrongExtFile, "not a pem"); 853await File.WriteAllTextAsync(correctFile, "pem content"); 896await File.WriteAllTextAsync(validFile, "zip content"); 942await File.WriteAllTextAsync(validFile, "gzip content");
Commands\ResourceCommandTests.cs (1)
199File.WriteAllText(appHostProjectFile.FullName, "<Project />");
Commands\RestoreCommandTests.cs (2)
19await File.WriteAllTextAsync(appHostFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />"); 53await File.WriteAllTextAsync(appHostFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\" />");
Commands\RunCommandTests.cs (43)
145Assert.True(File.Exists(socketPath), "Validation should happen before existing AppHost instances are stopped."); 158File.WriteAllText(Path.Combine(propertiesDirectory.FullName, "launchSettings.json"), """ 207File.WriteAllText(Path.Combine(propertiesDirectory.FullName, "launchSettings.json"), $$""" 374await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 438await File.WriteAllTextAsync(appHostFile.FullName, "<Project />", TestContext.Current.CancellationToken); 526await File.WriteAllTextAsync(appHostFile.FullName, "<Project />", TestContext.Current.CancellationToken); 631await File.WriteAllTextAsync(appHostFile.FullName, "<Project />", TestContext.Current.CancellationToken); 787await File.WriteAllTextAsync(Path.Combine(appHost1Dir.FullName, "AppHost1.csproj"), "fake"); 790await File.WriteAllTextAsync(Path.Combine(appHost2Dir.FullName, "AppHost2.csproj"), "fake"); 855File.WriteAllText(projectFile.FullName, """ 920await File.WriteAllTextAsync( 1088await File.WriteAllTextAsync(appHostFile.FullName, "<Project />", TestContext.Current.CancellationToken); 1161File.WriteAllText(Path.Combine(propertiesDirectory.FullName, "launchSettings.json"), """ 1313await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1389await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1453await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1515await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1573await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1635await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1696await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1759await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1820await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1882await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 2567File.WriteAllText(appHostProjectFile.FullName, "<Project></Project>"); 3207await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3255await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3299await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3347await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3390await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3434await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3478await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 3621File.WriteAllText(originalSecretsPath, """{"TestSecret": "TestValue"}"""); 3708if (File.Exists(originalSecretsPath)) 3710File.Delete(originalSecretsPath); 3811var lines = await File.ReadAllLinesAsync(logFilePath); 3848var lines = await File.ReadAllLinesAsync(logFilePath); 3891await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 3940File.WriteAllText(appHostFile.FullName, "<Project />"); 4007File.WriteAllText(appHostFile.FullName, "<Project />"); 4035File.WriteAllText(appHostFile.FullName, "<Project />"); 4283File.WriteAllText(appHostFile.FullName, "<Project />"); 4324File.WriteAllText(appHostFile.FullName, "<Project />"); 4340File.WriteAllText(socketPath, "");
Commands\SdkDumpCommandTests.cs (3)
262Assert.True(File.Exists(projectPath), $"Could not find Aspire.Hosting project at '{projectPath}'."); 282var output = await File.ReadAllTextAsync(outputPath); 384if (File.Exists(Path.Combine(currentDirectory.FullName, "Aspire.slnx")))
Commands\SdkInstallerTests.cs (3)
29await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"), projectContent); 116await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"), projectContent); 154await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"), projectContent);
Commands\SecretCommandTests.cs (2)
25await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 51await File.WriteAllTextAsync(appHostFile.FullName, "export {};");
Commands\StartCommandTests.cs (10)
158Assert.True(File.Exists(socketPath), "Validation should happen before existing AppHost instances are stopped."); 217File.WriteAllText(Path.Combine(propertiesDirectory.FullName, "launchSettings.json"), """ 268await File.WriteAllTextAsync(Path.Combine(appHost1Dir.FullName, "AppHost1.csproj"), "fake"); 271await File.WriteAllTextAsync(Path.Combine(appHost2Dir.FullName, "AppHost2.csproj"), "fake"); 299await File.WriteAllTextAsync(Path.Combine(appHost1Dir.FullName, "AppHost1.csproj"), "fake"); 302await File.WriteAllTextAsync(Path.Combine(appHost2Dir.FullName, "AppHost2.csproj"), "fake"); 331await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 384File.WriteAllText(appHostFile.FullName, "<Project />"); 668File.WriteAllText(appHostFile.FullName, "<Project />"); 684File.WriteAllText(socketPath, "");
Commands\StopCommandTests.cs (27)
270Assert.False(File.Exists(primaryConnection.SocketPath)); 271Assert.True(File.Exists(nestedConnection.SocketPath)); 281await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 348Assert.True(File.Exists(connection.SocketPath)); 388Assert.False(File.Exists(connection.SocketPath)); 475await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 509await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 541await File.WriteAllTextAsync(runningAppHostFile.FullName, "<Project />"); 544await File.WriteAllTextAsync(discoveredAppHostFile.FullName, "<Project />"); 593await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 625await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 660await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 700await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 735await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 775await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 815await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 854await File.WriteAllTextAsync(appHostFile.FullName, ""); 900await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 937await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 982await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1020await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1058await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1126await File.WriteAllTextAsync(appHostFile.FullName, "<Project />"); 1192Assert.True(File.Exists(socketPath)); 1213Assert.False(File.Exists(socketPath)); 1228File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), ""); 1309File.WriteAllText(socketPath, "");
Commands\TypeScriptAppHostToolingCheckTests.cs (3)
155await File.WriteAllTextAsync( 174File.WriteAllText(appHostPath, "await Promise.resolve();"); 175File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), packageJsonContent);
Commands\UpdateCommandTests.cs (57)
89await File.WriteAllTextAsync(appHostProjectFile.FullName, """ 192File.WriteAllText(oldBackup1, "test"); 193File.WriteAllText(oldBackup2, "test"); 194File.WriteAllText(otherFile, "test"); 200Assert.False(File.Exists(oldBackup1), "Old backup file should be deleted"); 201Assert.False(File.Exists(oldBackup2), "Old backup file should be deleted"); 202Assert.True(File.Exists(otherFile), "Other files should not be deleted"); 213File.WriteAllText(oldBackup, "test"); 223Assert.True(File.Exists(oldBackup), "Locked file should still exist on Windows"); 227Assert.False(File.Exists(oldBackup), "Locked file should be deleted on Mac/Linux"); 377File.WriteAllText(appHostPath, "// test apphost"); 440File.WriteAllText(appHostPath, "// test apphost"); 495File.WriteAllText(appHostPath, "// test apphost"); 1265File.WriteAllText(appHostPath, "// test apphost"); 1467File.WriteAllText(archivePath, "fake archive"); 1493await File.WriteAllTextAsync(processPath, "#!/bin/sh\nexit 0\n"); 1497await File.WriteAllTextAsync( 1518using var document = JsonDocument.Parse(await File.ReadAllBytesAsync(sidecarPath)); 1536await File.WriteAllTextAsync(processPath, originalExecutable); 1541await File.WriteAllTextAsync(sidecarPath, originalSidecar); 1562Assert.Equal(originalExecutable, await File.ReadAllTextAsync(processPath)); 1563Assert.Equal(originalSidecar, await File.ReadAllTextAsync(sidecarPath)); 1592File.WriteAllText(archivePath, "fake archive"); 1633File.WriteAllText(archivePath, "fake archive"); 2032File.WriteAllText(localConfigPath, """{ "channel": "staging" }"""); 2053File.WriteAllText(globalSettingsPath, """{ "channel": "staging" }"""); 2071File.WriteAllText(localConfigPath, """{ "channel": "staging" }"""); 2090File.WriteAllText(Path.Combine(globalDir, "settings.global.json"), """{ "channel": "daily" }"""); 2093File.WriteAllText(localConfigPath, """{ "channel": "staging" }"""); 2114File.WriteAllText(Path.Combine(globalDir, "settings.global.json"), """{ "channel": "staging" }"""); 2134File.WriteAllText(localConfigPath, """{ "channel": "no-such-channel" }"""); 2250File.WriteAllText(projectConfigPath, """{ "channel": "staging" }"""); 2267File.WriteAllText( 2273File.WriteAllText(Path.Combine(globalDir, "settings.global.json"), """{ "channel": "staging" }"""); 2295File.WriteAllText( 2300File.WriteAllText( 2321File.WriteAllText( 2327File.WriteAllText(Path.Combine(globalDir, "settings.global.json"), """{ "channel": "staging" }"""); 2330File.WriteAllText( 2378File.WriteAllText( 2631File.WriteAllText(appHostFile.FullName, string.Empty); 2632File.WriteAllText( 2775File.WriteAllText( 2960File.WriteAllText(archivePath, "fake archive"); 3005File.WriteAllText(archivePath, "fake archive"); 3050File.WriteAllText(archivePath, "fake archive"); 3083File.WriteAllText(archivePath, "fake archive"); 3270File.WriteAllText(archivePath, "fake archive"); 3295await File.WriteAllTextAsync( 3313await using var tarStream = File.OpenRead(tarPath); 3314await using var archiveStream = File.Create(archivePath); 3330File.SetUnixFileMode( 3354File.WriteAllText(processPath, string.Empty); 3355File.WriteAllText(storeExecutablePath, string.Empty); 3366File.WriteAllText(processPath, string.Empty); 3367File.WriteAllText(Path.Combine(binaryDir, InstallSidecarReader.SidecarFileName), """{"source":"nix"}"""); 3436File.WriteAllText(archivePath, "fake archive");
Configuration\AppHostPathConfigurationPolicyTests.cs (4)
41File.WriteAllText(path, json); 55File.WriteAllText(path, json); 65File.WriteAllText(path, """{ "appHost": { "language": "typescript/nodejs" }, "channel": "daily" }"""); 77File.WriteAllText(path, """{ "appHost": { "path": "AppHost.csproj" }""");
Configuration\AspireConfigFileTests.cs (28)
27File.WriteAllText(configPath, """ 47File.WriteAllText(configPath, """ 71File.WriteAllText(configPath, """ 95File.WriteAllText(configPath, """ 118File.WriteAllText(configPath, """ 137File.WriteAllText(configPath, "{ invalid json content }"); 151File.WriteAllText(configPath, """{ "appHost": { "path": """); 164File.WriteAllText(configPath, "{}"); 187Assert.True(File.Exists(filePath)); 189var content = File.ReadAllText(filePath); 204Assert.True(File.Exists(Path.Combine(subDir, AspireConfigFile.FileName))); 220File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), "{}"); 362File.WriteAllText(configPath, """ 383File.WriteAllText(configPath, """ 458File.WriteAllText(settingsPath, """ 480File.WriteAllText(settingsPath, """ 503File.WriteAllText(settingsPath, """ 521File.WriteAllText(settingsPath, """ 532Assert.True(File.Exists(configPath)); 548File.WriteAllText(settingsPath, $$""" 569File.WriteAllText(settingsPath, """ 589File.WriteAllText(settingsPath, """ 609File.WriteAllText(settingsPath, """ 629File.WriteAllText(settingsPath, """ 650File.WriteAllText(settingsPath, """ 670File.WriteAllText(settingsPath, """ 688File.WriteAllText(settingsPath, """ 708File.WriteAllText(settingsPath, $$"""
Configuration\ConfigurationHelperTests.cs (12)
18File.WriteAllText(settingsPath, content); 120File.WriteAllText(settingsPath, """ 131var json = JsonNode.Parse(File.ReadAllText(settingsPath)); 151File.WriteAllText(Path.Combine(configRoot.FullName, AspireConfigFile.FileName), "{}"); 192File.WriteAllText(legacySettingsPath, """ 200Assert.False(File.Exists(aspireConfigPath), "Precondition: aspire.config.json should not yet exist."); 209File.Exists(aspireConfigPath), 236File.WriteAllText(aspireConfigPath, existingContent); 240File.WriteAllText(legacySettingsPath, """ 250Assert.Equal(existingContent, File.ReadAllText(aspireConfigPath)); 264File.WriteAllText(legacySettingsPath, "{ this is not valid json"); 277Assert.False(File.Exists(migratedPath), "Unparseable legacy file must not produce an aspire.config.json on disk.");
Configuration\ConfigurationServiceTests.cs (14)
25File.WriteAllText(settingsFilePath, existingContent); 57var result = File.ReadAllText(settingsFilePath); 80var result = File.ReadAllText(settingsFilePath); 102var result = File.ReadAllText(settingsFilePath); 119Assert.True(File.Exists(legacySettingsPath)); 120var result = File.ReadAllText(legacySettingsPath); 133var result = File.ReadAllText(settingsFilePath); 155var result = File.ReadAllText(settingsFilePath); 223await File.WriteAllTextAsync( 252await File.WriteAllTextAsync( 294var result = File.ReadAllText(settingsFilePath); 310var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); 333var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); 353var json = JsonNode.Parse(File.ReadAllText(settingsFilePath));
Configuration\DotNetBasedAppHostServerChannelResolutionTests.cs (1)
72Assert.False(File.Exists(Path.Combine(appPath, AspireConfigFile.FileName)));
Configuration\PrebuiltAppHostServerChannelResolutionTests.cs (1)
64Assert.False(File.Exists(Path.Combine(appHostDirectory.FullName, AspireConfigFile.FileName)));
DotNet\DotNetCliRunnerTests.cs (70)
46await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 95await File.WriteAllTextAsync(appHostFile.FullName, "Not a real AppHost."); 134await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 170await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 212await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 251await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 279await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 313File.WriteAllText(cliPath, string.Empty); 314File.WriteAllText(Path.Combine(cliDirectory.FullName, "aspire.dll"), string.Empty); 326File.WriteAllText(cliPath, string.Empty); 327File.WriteAllText(Path.Combine(cliDirectory.FullName, "aspire.dll"), string.Empty); 331File.CreateSymbolicLink(linkPath, cliPath); 342File.WriteAllText(dotnetPath, string.Empty); 353File.WriteAllText(cliPath, string.Empty); 354File.WriteAllText(Path.Combine(cliDirectory.FullName, "aspire.dll"), string.Empty); 355File.WriteAllText(Path.Combine(cliDirectory.FullName, ".aspire-install.json"), """{"source":"script"}"""); 366File.WriteAllText(cliPath, string.Empty); 367File.WriteAllText(Path.Combine(cliDirectory.FullName, "aspire.dll"), string.Empty); 370File.WriteAllText(Path.Combine(cliDirectory.FullName, "dcp", OperatingSystem.IsWindows() ? "dcp.exe" : "dcp"), string.Empty); 371File.WriteAllText(Path.Combine(cliDirectory.FullName, "managed", OperatingSystem.IsWindows() ? "aspire-managed.exe" : "aspire-managed"), string.Empty); 381await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 409await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 446await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 475await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 504await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 577await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 614await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 655await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 700await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 755await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 852await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 892await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 934await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 981await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1044await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1090await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1132await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1174await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1227await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 1294await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 1360await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 1433await File.WriteAllTextAsync(solutionFile.FullName, "Not a real solution file."); 1438await File.WriteAllTextAsync(project1File.FullName, "Not a real project file."); 1442await File.WriteAllTextAsync(project2File.FullName, "Not a real project file."); 1480await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1483await File.WriteAllTextAsync(referencedProject.FullName, "Not a real project file."); 1513await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1560await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1606await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1643await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1680await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1721await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1766await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1818await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1867await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1915await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1952await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1987await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2030await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2072await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2112await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2152await File.WriteAllTextAsync(projectFile.FullName, """ 2162await File.WriteAllTextAsync(Path.Combine(projectDirectory.FullName, "Program.cs"), "Console.WriteLine(\"Hello\");"); 2197await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2418await File.WriteAllTextAsync(packagePath, string.Empty); 2488await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2526await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2564await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2604await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2643await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file.");
DotNet\ProcessExecutionDetachedTests.cs (18)
55await File.WriteAllTextAsync(dcpPath, """ 87File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 115], await File.ReadAllLinesAsync(capturePath)); 137await File.WriteAllTextAsync(dcpPath, """ 155File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 218await File.WriteAllTextAsync(dcpPath, """ 235File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 257await File.WriteAllTextAsync(dcpPath, """ 277File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 291var childPid = int.Parse(await File.ReadAllTextAsync(capturePath), CultureInfo.InvariantCulture); 311await File.WriteAllTextAsync(dcpPath, """ 328File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 352Assert.Equal(Path.GetFullPath(versionDirectory.FullName), (await File.ReadAllTextAsync(capturePath)).Trim()); 366await File.WriteAllTextAsync(dcpPath, """ 382File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 416await File.WriteAllTextAsync(dcpPath, """ 432File.SetUnixFileMode(dcpPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 474while (!File.Exists(path))
DotNet\ProcessExecutionTests.cs (11)
41await File.WriteAllTextAsync(outputFile.FullName, CreateJsonPayload(lineCount: 400)); 101await File.WriteAllTextAsync(outputFile.FullName, CreateJsonPayload(lineCount: 400)); 294await File.WriteAllTextAsync(scriptFile.FullName, content); 303await File.WriteAllTextAsync(scriptFile.FullName, content); 305File.SetUnixFileMode( 327await File.WriteAllTextAsync(scriptFile.FullName, content); 338await File.WriteAllTextAsync(scriptFile.FullName, content); 340File.SetUnixFileMode( 358await File.WriteAllTextAsync(scriptFile.FullName, content); 367await File.WriteAllTextAsync(scriptFile.FullName, content); 369File.SetUnixFileMode(
DotNetSdkInstallerTests.cs (3)
335await File.WriteAllTextAsync(scriptFile, script); 359await File.WriteAllTextAsync(shellFile, shellScript); 360File.SetUnixFileMode(
Git\GitRepositoryTests.cs (7)
42await File.WriteAllTextAsync(trackedFile, "Not a real project file."); 47await File.WriteAllTextAsync(untrackedFile, "Not a real project file."); 51await File.WriteAllTextAsync(gitignorePath, "bin/\n"); 56await File.WriteAllTextAsync(ignoredFile, "Not a real project file."); 83await File.WriteAllTextAsync(trackedFile, "Not a real project file."); 89File.Delete(trackedFile); 110await File.WriteAllTextAsync(trackedFile, "Not a real project file.");
Git\GitWorktreeTests.cs (8)
162File.WriteAllText( 185File.WriteAllText( 203File.WriteAllText( 224File.WriteAllText( 229var expectedRoot = File.Exists(caseVariantGitFile) 262File.WriteAllText( 302File.WriteAllText( 321File.WriteAllText(
Layout\LayoutDiscoveryReparsePointTests.cs (12)
44File.WriteAllText(realBinary, "stub"); 49File.CreateSymbolicLink(linkPath, realBinary); 75File.WriteAllText(realBinary, "stub"); 78File.CreateSymbolicLink(linkPath, realBinary); 102File.WriteAllText( 105File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(versionedDcp), "stub"); 142File.WriteAllText(binaryPath, "stub"); 186File.WriteAllText(binaryPath, "stub"); 227File.WriteAllText( 231File.WriteAllText(binaryPath, "stub"); 250File.WriteAllText( 253File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDir), "stub");
Mcp\E2E\McpDocsE2ETests.cs (2)
289while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "Aspire.slnx"))) 301if (!File.Exists(cliProjectPath))
Migrations\TypeScriptAppHostMigrationTests.cs (21)
55await File.WriteAllTextAsync(appHostPath, "import { createBuilder } from './.modules/aspire.js';"); 70await File.WriteAllTextAsync( 83await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.ts"), "// legacy"); 84await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"), "// modern"); 95await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.cs"), "// csharp"); 152await File.WriteAllTextAsync(Path.Combine(root.FullName, "apphost.ts"), LegacyAppHostContent); 153await File.WriteAllTextAsync( 162await File.WriteAllTextAsync( 170await File.WriteAllTextAsync( 181await File.WriteAllTextAsync(Path.Combine(root.FullName, "eslint.config.mjs"), LegacyEslintConfigContent); 184await File.WriteAllTextAsync(Path.Combine(modulesDir.FullName, "aspire.ts"), "// generated"); 189var config = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root.FullName, "aspire.config.json")))!; 192var tsconfig = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root.FullName, "tsconfig.apphost.json")))!; 196var packageJson = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root.FullName, "package.json")))!; 201var eslintConfig = await File.ReadAllTextAsync(Path.Combine(root.FullName, "eslint.config.mjs")); 214Assert.False(File.Exists(Path.Combine(root.FullName, "apphost.ts"))); 217var modernContent = await File.ReadAllTextAsync(Path.Combine(root.FullName, "apphost.mts")); 234Assert.False(File.Exists(Path.Combine(appHostDirectory.FullName, "apphost.ts"))); 236Assert.Equal(ExpectedModernAppHostContent, await File.ReadAllTextAsync(Path.Combine(appHostDirectory.FullName, "apphost.mts"))); 278var migratedContent = await File.ReadAllTextAsync(Path.Combine(root.FullName, "apphost.mts")); 282Assert.Equal(migratedContent, await File.ReadAllTextAsync(Path.Combine(root.FullName, "apphost.mts")));
Npm\AspireJsLauncherTests.cs (15)
44File.WriteAllText(layout.RidPackageJsonPath, "{ not valid json"); 67File.WriteAllText(monkeyPatchScript, """ 96File.WriteAllText(monkeyPatchScript, """ 139Assert.True(File.Exists(cachedBinaryPath), $"Expected cached binary at {cachedBinaryPath}"); 151File.WriteAllText(probeScript, $$""" 173File.WriteAllText(probeScript, $$""" 186var scriptContent = File.ReadAllText(scriptPath); 245File.WriteAllText( 252File.Copy(realLauncherPath, launcherScript); 256File.WriteAllText( 266File.WriteAllText( 275File.WriteAllText(probeScript, """ 292File.Copy(GetNodeExecutablePath(), binaryPath); 300File.WriteAllText(binaryPath, """ 408while (current is not null && !File.Exists(Path.Combine(current, "Aspire.slnx")))
Npm\NpmRunnerTests.cs (4)
180await File.ReadAllLinesAsync(argumentsPath, TestContext.Current.CancellationToken)); 251File.WriteAllText( 266File.WriteAllText( 272File.SetUnixFileMode(
NuGet\BundleNuGetPackageCacheTests.cs (3)
31await File.WriteAllTextAsync(managedPath!, string.Empty); 86await File.WriteAllTextAsync(managedPath!, string.Empty); 135await File.WriteAllTextAsync(managedPath!, string.Empty);
NuGet\BundleNuGetServiceTests.cs (16)
27File.WriteAllText(managedPath, string.Empty); 68File.WriteAllText(managedPath, string.Empty); 102File.WriteAllText(managedPath, string.Empty); 105File.WriteAllText(nugetConfigPath, "<configuration />"); 139File.WriteAllText(managedPath, string.Empty); 151File.WriteAllText(manifestPath, "{}"); 183File.WriteAllText(managedPath, string.Empty); 195File.WriteAllText(manifestPath, "{ invalid json"); 205File.WriteAllText(manifestPath, """{"managedAssemblies":[],"nativeLibraries":[]}"""); 236File.WriteAllText(managedPath, "v1"); 250File.WriteAllText(managedPath, "v2-changed"); 271File.WriteAllText(managedPath, string.Empty); 315File.WriteAllText(managedPath, string.Empty); 343await File.WriteAllTextAsync( 386File.WriteAllText(managedPath, string.Empty); 394File.WriteAllText(lockedFilePath, "legacy");
Packaging\NuGetConfigMergerSnapshotTests.cs (1)
35await File.WriteAllTextAsync(path, content);
Packaging\NuGetConfigMergerTests.cs (11)
25await File.WriteAllTextAsync(path, content); 47Assert.True(File.Exists(targetConfigPath)); 50var expected = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 51var actual = await File.ReadAllTextAsync(targetConfigPath); 71Assert.True(File.Exists(targetConfigPath)); 760Assert.True(File.Exists(targetConfigPath)); 790Assert.False(File.Exists(targetConfigPath)); 840Assert.True(File.Exists(targetConfigPath)); 861var originalContent = await File.ReadAllTextAsync(Path.Combine(root.FullName, "nuget.config")).DefaultTimeout(); 883var currentContent = await File.ReadAllTextAsync(targetConfigPath); 905Assert.True(File.Exists(targetConfigPath));
Packaging\PackageChannelTests.cs (35)
146File.WriteAllText( 178File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.5.0.nupkg"), string.Empty); 182File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.ProjectTemplates.{pinnedVersion}.nupkg"), string.Empty); 225File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.5.0.nupkg"), string.Empty); 228File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.ProjectTemplates.{pinnedVersion}.nupkg"), string.Empty); 266File.WriteAllText(Path.Combine(channelPackagesDirectory.FullName, "Aspire.ProjectTemplates.13.4.0-preview.1.nupkg"), string.Empty); 270File.WriteAllText(Path.Combine(nestedDirectory.FullName, "Aspire.ProjectTemplates.13.5.0-preview.2.nupkg"), string.Empty); 305File.WriteAllText(Path.Combine(nestedDirectory.FullName, "Aspire.ProjectTemplates.13.5.0-preview.2.nupkg"), string.Empty); 332File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Redis.{pinnedVersion}.nupkg"), string.Empty); 333File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.PostgreSQL.{pinnedVersion}.nupkg"), string.Empty); 334File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"CommunityToolkit.Aspire.Hosting.NodeJS.{pinnedVersion}.nupkg"), string.Empty); 337File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.SqlServer.13.3.0.nupkg"), string.Empty); 340File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.ProjectTemplates.{pinnedVersion}.nupkg"), string.Empty); 347File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.AppHost.{pinnedVersion}.nupkg"), string.Empty); 348File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Sdk.{pinnedVersion}.nupkg"), string.Empty); 349File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Orchestration.linux-arm64.{pinnedVersion}.nupkg"), string.Empty); 350File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Testing.{pinnedVersion}.nupkg"), string.Empty); 351File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Msi.{pinnedVersion}.nupkg"), string.Empty); 352File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Integration.Analyzers.{pinnedVersion}.nupkg"), string.Empty); 355File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.Dapr.{pinnedVersion}.nupkg"), string.Empty); 356File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.GitHub.Models.{pinnedVersion}.nupkg"), string.Empty); 357File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.Hosting.NodeJs.{pinnedVersion}.nupkg"), string.Empty); 640File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Redis.13.4.0.nupkg"), string.Empty); 641File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Redis.13.5.0-preview.1.nupkg"), string.Empty); 642File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.PostgreSQL.13.4.0-preview.1.nupkg"), string.Empty); 659File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Redis.13.4.0.nupkg"), string.Empty); 660File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Redis.13.5.0-preview.1.nupkg"), string.Empty); 661File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.PostgreSQL.13.4.0.nupkg"), string.Empty); 678File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Redis.13.5.0.nupkg"), string.Empty); 679File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Redis.13.6.0-preview.1.nupkg"), string.Empty); 680File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Azure.Kubernetes.13.6.0-pr.19404.gf51e8e1d.nupkg"), string.Empty); 709File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Dapr.13.4.0.nupkg"), string.Empty); 710File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Sql.13.4.0.nupkg"), string.Empty); 729File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Dapr.13.4.0.nupkg"), string.Empty); 730File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.Hosting.Sql.13.4.0.nupkg"), string.Empty);
Packaging\PackagingServiceTests.cs (37)
1122Assert.True(File.Exists(nugetConfigPath)); 1124var configContent = await File.ReadAllTextAsync(nugetConfigPath); 1377Assert.True(File.Exists(nugetConfigPath)); 1379var configContent = await File.ReadAllTextAsync(nugetConfigPath); 1492File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.ProjectTemplates.{localVersion}.nupkg"), string.Empty); 1493File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.{localVersion}.nupkg"), string.Empty); 1516File.WriteAllText(processPath, string.Empty); 1519File.WriteAllText(Path.Combine(packagesDirectory.FullName, $"Aspire.ProjectTemplates.{prVersion}.nupkg"), string.Empty); 1558File.WriteAllText(Path.Combine(defaultPackagesDirectory.FullName, $"Aspire.ProjectTemplates.{defaultHiveVersion}.nupkg"), string.Empty); 1563File.WriteAllText(processPath, string.Empty); 1566File.WriteAllText(Path.Combine(dogfoodPackagesDirectory.FullName, $"Aspire.ProjectTemplates.{dogfoodHiveVersion}.nupkg"), string.Empty); 1599File.WriteAllText(processPath, string.Empty); 1602File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.not-a-semver.nupkg"), string.Empty); 1635File.WriteAllText(processPath, string.Empty); 1665File.WriteAllText(processPath, string.Empty); 1721File.WriteAllText(processPath, string.Empty); 1757File.WriteAllText(processPath, string.Empty); 1780File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.ProjectTemplates.{localVersion}.nupkg"), string.Empty); 1972File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.ProjectTemplates.{pinnedVersion}.nupkg"), string.Empty); 2005File.WriteAllText(Path.Combine(runPackagesDir.FullName, $"Aspire.ProjectTemplates.{pinnedVersion}.nupkg"), string.Empty); 2040File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.{localVersion}.nupkg"), string.Empty); 2042File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.Redis.{localVersion}.nupkg"), string.Empty); 2043File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.Hosting.JavaScript.{localVersion}.nupkg"), string.Empty); 2045File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.ProjectTemplates.{localVersion}.nupkg"), string.Empty); 2046File.WriteAllText(Path.Combine(localPackagesDir.FullName, $"Aspire.AppHost.Sdk.{localVersion}.nupkg"), string.Empty); 2077File.WriteAllText(Path.Combine(localPackagesDir.FullName, "Aspire.Hosting.13.4.0-pr.16820.g1a99aa46.nupkg"), string.Empty); 2169File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, $"Aspire.ProjectTemplates.{overrideVersion}.nupkg"), string.Empty); 2170File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, $"Aspire.Hosting.{overrideVersion}.nupkg"), string.Empty); 2197File.WriteAllText(Path.Combine(staleHiveDir.FullName, "Aspire.Hosting.13.4.0.nupkg"), string.Empty); 2201File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, $"Aspire.Hosting.{overrideVersion}.nupkg"), string.Empty); 2227File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, "Aspire.Hosting.13.4.1.nupkg"), string.Empty); 2228File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, "Aspire.Hosting.13.4.2.nupkg"), string.Empty); 2230File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, "Aspire.ProjectTemplates.13.4.2.nupkg"), string.Empty); 2255File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, "Aspire.Hosting.13.4.1.nupkg"), string.Empty); 2257File.WriteAllText(Path.Combine(nestedDir.FullName, "Aspire.Hosting.13.4.2.nupkg"), string.Empty); 2259File.WriteAllText(Path.Combine(nestedDir.FullName, "Aspire.ProjectTemplates.13.4.2.nupkg"), string.Empty); 2260File.WriteAllText(Path.Combine(packagesOverrideDir.FullName, "Aspire.ProjectTemplates.13.4.2.nupkg"), string.Empty);
Packaging\TemporaryNuGetConfigTests.cs (7)
26var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 65var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 96var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 119var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 141var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 160var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 194xmlDoc.LoadXml(await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName));
Processes\ProcessTreeGracefulShutdownServiceTests.cs (8)
25File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty); 62File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty); 87File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(mutableDcpDirectory.FullName), string.Empty); 92File.WriteAllText(leasedDcpPath, string.Empty); 150File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty); 206File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty); 245File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty); 284File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty);
ProfileCaptureOptionsTests.cs (2)
120File.WriteAllText(expectedManagedPath, string.Empty); 141File.WriteAllText(expectedManagedPath, string.Empty);
ProfileCaptureServiceTests.cs (7)
94File.WriteAllText(managedPath, string.Empty); 337Assert.True(File.Exists(outputPath)); 373Assert.True(File.Exists(options.OutputPath)); 394Assert.False(File.Exists(options.OutputPath)); 410Assert.False(File.Exists(options.OutputPath)); 464File.WriteAllText(managedPath, string.Empty); 676File.WriteAllText(path, string.Empty);
ProgramTests.cs (3)
94File.WriteAllText(settingsPath, """{ "appHost": { "path": "AppHost.csproj" } }"""); 111File.WriteAllText(settingsPath, """{ "channel": "daily" }"""); 128File.WriteAllText(settingsPath, content);
Projects\AppHostCandidateFinderTests.cs (2)
541await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, ".gitignore"), "legacy/\n"); 609await File.WriteAllTextAsync(fullPath, "Not a real project file.");
Projects\AppHostInfoResolverTests.cs (1)
207File.WriteAllText(path, "<Project Sdk=\"Microsoft.NET.Sdk;Aspire.AppHost.Sdk/9.5.0\" />");
Projects\AppHostServerProjectTests.cs (12)
64var content = await File.ReadAllTextAsync(appSettingsPath); 85var content = await File.ReadAllTextAsync(programCsPath); 107Assert.True(File.Exists(programCs)); 109var content = await File.ReadAllTextAsync(programCs); 130Assert.True(File.Exists(appSettingsPath)); 132var content = await File.ReadAllTextAsync(appSettingsPath); 213await File.WriteAllTextAsync(integrationProjectPath, "<Project />"); 321await File.WriteAllTextAsync(aspireConfigPath, """ 401Assert.True(File.Exists(projectFilePath), $"Project file should be created at {projectFilePath}"); 403var projectContent = await File.ReadAllTextAsync(projectFilePath); 425await File.WriteAllTextAsync(aspireConfigPath, """ 479await File.WriteAllTextAsync(aspireConfigPath, """
Projects\AppHostServerSessionTests.cs (1)
450File.WriteAllText(integrationCachePathBlockedByFile, string.Empty);
Projects\AppHostWorkloadIdTests.cs (6)
15File.WriteAllText(target.FullName, "<Project />"); 32File.WriteAllText(target.FullName, "<Project />"); 50File.WriteAllText(target.FullName, "<Project />"); 62File.WriteAllText(target.FullName, "<Project />"); 82File.WriteAllText(target.FullName, "<Project />"); 97File.CreateSymbolicLink(linkPath, targetPath);
Projects\DefaultLanguageDiscoveryTests.cs (1)
198File.WriteAllText(appHostPath, "void main(String[] args) { }");
Projects\DotNetAppHostProjectTests.cs (40)
266File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "apphost.run.json"), """ 395Assert.False(File.Exists(socketPath)); 412Assert.True(File.Exists(socketPath)); 483File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(customDcpDirectory.FullName), ""); 487File.WriteAllText(customDashboardPath, ""); 536File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(inheritedDcpDirectory), ""); 538File.WriteAllText(inheritedDashboardPath, ""); 698File.Delete(BundleDiscovery.GetDcpExecutablePath(layout.GetDcpPath()!)); 699File.Delete(layout.GetManagedPath()!); 871File.WriteAllText(repoLocalManaged, "fake"); 986File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1081File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1165File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1251File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1293File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1337File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), $$""" 1384File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1429File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1549File.WriteAllText(targetPath, string.Empty); 1633File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1700File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), $$""" 1803File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "AppHost.run.json"), """ 1869File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "My Project", "launchSettings.json"), """ 1930File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 1995File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 2052File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "Properties", "launchSettings.json"), """ 2176File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "apphost.run.json"), """ 2378File.WriteAllText(Path.Combine(appHostFile.DirectoryName!, "apphost.run.json"), """ 2534File.WriteAllText(appHostPath, """ 2556File.WriteAllText(socketPath, ""); 2564File.WriteAllText(targetPath, string.Empty); 2565File.WriteAllText(Path.ChangeExtension(targetPath, ".runtimeconfig.json"), "{}"); 2573File.WriteAllText(commandPath, string.Empty); 4155while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "Aspire.slnx"))) 4179File.WriteAllText(path, content); 4209File.WriteAllText(appHostPath, """ 4226File.WriteAllText(projectPath, """ 4242File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), ""); 4243File.WriteAllText( 4299=> File.WriteAllText(Path.Combine(directory, "aspire.config.json"), content);
Projects\DotNetBasedAppHostServerScaffoldCacheTests.cs (11)
36Assert.True(File.Exists(assetsPath), 60Assert.False(File.Exists(assetsPath), 63var csproj = await File.ReadAllTextAsync( 83File.Delete(programPath); 87Assert.True(File.Exists(programPath), "Program.cs was not restored after being deleted."); 106File.WriteAllText(stalePath, "partial restore"); 110Assert.False(File.Exists(stalePath), 132Assert.Contains(firstProject, await File.ReadAllTextAsync(csprojPath)); 137Assert.False(File.Exists(assetsPath), 139Assert.Contains(secondProject, await File.ReadAllTextAsync(csprojPath)); 152File.WriteAllText(assetsPath, "{}");
Projects\FallbackProjectParserTests.cs (14)
31await File.WriteAllTextAsync(projectFile, projectContent); 56await File.WriteAllTextAsync(projectFile, projectContent); 81await File.WriteAllTextAsync(projectFile, projectContent); 106await File.WriteAllTextAsync(projectFile, projectContent); 132await File.WriteAllTextAsync(projectFile, projectContent); 158await File.WriteAllTextAsync(projectFile, projectContent); 195await File.WriteAllTextAsync(projectFile, invalidProjectContent); 217await File.WriteAllTextAsync(projectFile, projectContent); 247await File.WriteAllTextAsync(projectFile, projectContent); 270await File.WriteAllTextAsync(projectFile, projectContent); 294await File.WriteAllTextAsync(projectFile, projectContent); 317await File.WriteAllTextAsync(projectFile, projectContent); 339await File.WriteAllTextAsync(projectFile, projectContent); 357await File.WriteAllTextAsync(projectFile, projectContent);
Projects\GuestAppHostProjectTests.cs (60)
55await File.WriteAllTextAsync(kept, "class Kept { }"); 56await File.WriteAllTextAsync(obsolete, "class RemovedResource { }"); 72Assert.True(File.Exists(kept)); 73Assert.False(File.Exists(obsolete)); 82await File.WriteAllTextAsync(handWritten, "class HandWritten { }"); 89Assert.True(File.Exists(handWritten)); 96await File.WriteAllTextAsync(filePath, "class Generated { }"); 98File.SetLastWriteTimeUtc(filePath, originalWriteTime); 105Assert.Equal(originalWriteTime, File.GetLastWriteTimeUtc(filePath)); 112await File.WriteAllTextAsync(filePath, "class Generated { }"); 113File.SetLastWriteTimeUtc(filePath, new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc)); 118Assert.Equal("class Generated { int x; }", await File.ReadAllTextAsync(filePath)); 119Assert.True(File.GetLastWriteTimeUtc(filePath) > new DateTime(2020, 1, 2, 0, 0, 0, DateTimeKind.Utc)); 130Assert.Equal("class New { }", await File.ReadAllTextAsync(filePath)); 137await File.WriteAllTextAsync(filePath, "def add_redis(): ..."); 139File.SetLastWriteTimeUtc(filePath, originalWriteTime); 147Assert.True(File.GetLastWriteTimeUtc(filePath) > originalWriteTime); 179File.WriteAllText(settingsPath, """ 199File.WriteAllText(settingsPath, """ 385File.WriteAllText(settingsPath, """ 403var json = File.ReadAllText(settingsPath); 432var content = await File.ReadAllTextAsync(settingsPath); 445File.WriteAllText(launchSettingsPath, """ 534File.WriteAllText(aspireConfigPath, """ 726await File.WriteAllTextAsync(configPath, """ 734await File.WriteAllTextAsync(appHostPath, "// test apphost"); 779await File.WriteAllTextAsync(configPath, """ 787await File.WriteAllTextAsync(appHostPath, "// test apphost"); 820await File.WriteAllTextAsync(appHostPath, "// test apphost"); 837Assert.False(File.Exists(socketPath)); 844await File.WriteAllTextAsync(configPath, """ 853await File.WriteAllTextAsync(appHostPath, "// test apphost"); 900await File.WriteAllTextAsync(configPath, """ 908await File.WriteAllTextAsync(appHostPath, "// test apphost"); 955await File.WriteAllTextAsync(configPath, """ 964await File.WriteAllTextAsync(appHostPath, "// test apphost"); 1039await File.WriteAllTextAsync(configPath, seededJson); 1042await File.WriteAllTextAsync(appHostPath, "// test apphost"); 1139await File.WriteAllTextAsync(appHostPath, "// test apphost"); 1181await File.WriteAllTextAsync(appHostPath, "// test apphost"); 1260await File.WriteAllTextAsync(configPath, $$""" 1268await File.WriteAllTextAsync(appHostPath, "// test apphost"); 1349await File.WriteAllTextAsync(configPath, $$""" 1357await File.WriteAllTextAsync(appHostPath, "// test apphost"); 1446File.WriteAllText(socketPath, ""); 1585await File.WriteAllTextAsync(existingBundlePath, "existing certificate", TestContext.Current.CancellationToken); 1586await File.WriteAllTextAsync(devCertificatePath, "development certificate", TestContext.Current.CancellationToken); 1587var expectedDevCertificateContents = await File.ReadAllBytesAsync(devCertificatePath, TestContext.Current.CancellationToken); 1588var expectedExistingBundleContents = await File.ReadAllBytesAsync(existingBundlePath, TestContext.Current.CancellationToken); 1607await File.ReadAllBytesAsync(envVars["NODE_EXTRA_CA_CERTS"], TestContext.Current.CancellationToken)); 1641await File.WriteAllTextAsync(existingBundlePath, existingBundleContents, TestContext.Current.CancellationToken); 1642await File.WriteAllTextAsync(inheritedBundlePath, inheritedBundleContents, TestContext.Current.CancellationToken); 1643await File.WriteAllTextAsync(devCertificatePath, devCertificateContents, TestContext.Current.CancellationToken); 1674Assert.Equal(expectedBundleContents, await File.ReadAllBytesAsync(expectedBundlePath, TestContext.Current.CancellationToken)); 1677File.SetLastWriteTimeUtc(expectedBundlePath, cachedWriteTime); 1678cachedWriteTime = File.GetLastWriteTimeUtc(expectedBundlePath); 1689Assert.Equal(cachedWriteTime, File.GetLastWriteTimeUtc(expectedBundlePath)); 1696File.GetUnixFileMode(Path.GetDirectoryName(expectedBundlePath)!)); 1699File.GetUnixFileMode(expectedBundlePath)); 1709await File.WriteAllTextAsync(devCertificatePath, "dev certificate", TestContext.Current.CancellationToken);
Projects\GuestRuntimeTests.cs (37)
755Assert.True(File.Exists(logFilePath), "Log file should exist"); 756var logContents = await File.ReadAllTextAsync(logFilePath); 765if (File.Exists(logFilePath)) 767File.Delete(logFilePath); 976Assert.False(File.Exists(migrationFilePath)); 981Assert.True(File.Exists(migrationFilePath)); 982var writtenContent = await File.ReadAllTextAsync(migrationFilePath); 998await File.WriteAllTextAsync(migrationFilePath, existingContent); 1025var writtenContent = await File.ReadAllTextAsync(migrationFilePath); 1059Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "classes", ".aspire-compile-stamp"))); 1090File.SetLastWriteTimeUtc(input, DateTime.UtcNow.AddMinutes(1)); 1111File.WriteAllText(classFile, ""); 1113File.SetLastWriteTimeUtc(classFile, DateTime.UtcNow.AddMinutes(1)); 1138File.Delete(Path.Combine(workspace.WorkspaceRoot.FullName, relativeInput.Replace('/', Path.DirectorySeparatorChar))); 1154File.WriteAllText(pom, "<project/>"); 1160File.SetLastWriteTimeUtc(pom, DateTime.UtcNow.AddMinutes(1)); 1177File.WriteAllText(Path.Combine(dependencies, "guava-32.0.0.jar"), ""); 1188File.Delete(Path.Combine(dependencies, "guava-32.0.0.jar")); 1189File.WriteAllText(Path.Combine(dependencies, "guava-33.0.0.jar"), ""); 1207File.WriteAllText(jar, ""); 1213File.SetLastWriteTimeUtc(jar, DateTime.UtcNow.AddMinutes(1)); 1235File.WriteAllText(unrelated, ""); 1237File.SetLastWriteTimeUtc(unrelated, DateTime.UtcNow.AddMinutes(1)); 1277File.WriteAllText(nested, "class Resources { }"); 1279File.SetLastWriteTimeUtc(nested, DateTime.UtcNow.AddMinutes(1)); 1307File.WriteAllText(path, ""); 1318File.SetLastWriteTimeUtc(path, DateTime.UtcNow.AddMinutes(1)); 1348File.WriteAllText(Path.Combine(unreadable, "Hidden.java"), "class Hidden { }"); 1373File.SetUnixFileMode(path, mode); 1389Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "classes", ".aspire-compile-stamp"))); 1415File.WriteAllText(appHostFile.FullName, "class AppHost { }"); 1416File.WriteAllText(Path.Combine(root.FullName, "Helper.java"), "class Helper { }"); 1420File.WriteAllText(Path.Combine(generated, "Generated.java"), "class Generated { }"); 1424File.WriteAllText(Path.Combine(sources, "Service.java"), "class Service { }"); 1439File.SetLastWriteTimeUtc(file, timestampUtc); 1455File.WriteAllText(stamp, ""); 1456File.SetLastWriteTimeUtc(stamp, timestampUtc);
Projects\JavaAppHostToolchainResolverTests.cs (34)
14File.WriteAllText(path, ""); 81File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 92File.WriteAllText(Path.Combine(workspace.Path, buildFileName), ""); 101File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 102File.WriteAllText(Path.Combine(workspace.Path, "build.gradle"), ""); 111File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 135File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 183File.WriteAllText(Path.Combine(workspace.Path, buildFileName), ""); 234File.WriteAllText(Path.Combine(workspace.Path, "build.gradle"), ""); 272File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 307File.WriteAllText(wrapperPath, ""); 344File.WriteAllText(rootWrapperPath, ""); 347File.WriteAllText(Path.Combine(moduleDirectory.FullName, useMaven ? "pom.xml" : "build.gradle"), ""); 372File.WriteAllText(Path.Combine(workspace.Path, OperatingSystem.IsWindows() ? windowsWrapperName : wrapperName), ""); 376File.WriteAllText(Path.Combine(innerCheckout.FullName, useMaven ? "pom.xml" : "build.gradle"), ""); 388File.WriteAllText(Path.Combine(directory, "pom.xml"), ""); 392File.WriteAllText(Path.Combine(directory, "settings.gradle"), ""); 400File.WriteAllText(Path.Combine(workspace.Path, "build.gradle"), ""); 407Assert.Contains("aspireCopyDependencies", await File.ReadAllTextAsync(scriptPath)); 409await File.WriteAllTextAsync(scriptPath, "// stale"); 412Assert.Contains("aspireCopyDependencies", await File.ReadAllTextAsync(scriptPath)); 419File.WriteAllText(Path.Combine(workspace.Path, "build.gradle"), ""); 424var script = await File.ReadAllTextAsync(Path.Combine(workspace.Path, ".aspire", "aspire-gradle-init.gradle")); 435File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 439await File.WriteAllTextAsync(Path.Combine(dependencyDirectory, "library-1.0.jar"), ""); 452File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 463File.WriteAllText(Path.Combine(workspace.Path, "build.gradle"), ""); 468await File.WriteAllTextAsync(Path.Combine(dependencyDirectory, "library-1.0.jar"), ""); 485File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 502File.WriteAllText(Path.Combine(workspace.Path, buildFileName), ""); 517File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 527File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 569File.WriteAllText(Path.Combine(workspace.Path, "build.gradle"), ""); 579Assert.Contains("aspireCopyDependencies", await File.ReadAllTextAsync(scriptPath));
Projects\LanguageInfoTests.cs (4)
65File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.ts"), ""); 76File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "MyApp.csproj"), ""); 89File.WriteAllText(Path.Combine(nested, "apphost.cs"), ""); 103File.WriteAllText(Path.Combine(deep, "apphost.cs"), "");
Projects\LegacyTypeScriptAppHostHelperTests.cs (3)
14File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.ts"), "// legacy"); 23File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.ts"), "// legacy"); 24File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"), "// modern");
Projects\PrebuiltAppHostServerTests.cs (65)
33var firstWrite = File.GetLastWriteTimeUtc(path); 36File.SetLastWriteTimeUtc(path, firstWrite.AddMinutes(-5)); 37var backdated = File.GetLastWriteTimeUtc(path); 40Assert.Equal(backdated, File.GetLastWriteTimeUtc(path)); 41Assert.Equal("<Project />", await File.ReadAllTextAsync(path)); 52Assert.Equal("<Project Sdk=\"Microsoft.NET.Sdk\" />", await File.ReadAllTextAsync(path)); 62await File.WriteAllTextAsync(path, "<Project />"); 69File.SetUnixFileMode(path, UnixFileMode.UserWrite); 76File.SetUnixFileMode(path, UnixFileMode.UserRead | UnixFileMode.UserWrite); 79Assert.Equal("<Project Sdk=\"Microsoft.NET.Sdk\" />", await File.ReadAllTextAsync(path)); 122await File.WriteAllTextAsync(referencedProject, """<Project><ItemGroup><PackageReference Include="Aspire.Hosting" Version="13.5.0" /></ItemGroup></Project>"""); 129await File.WriteAllTextAsync(referencedProject, """<Project><ItemGroup><PackageReference Include="Aspire.Hosting" Version="13.6.0-dev" /></ItemGroup></Project>"""); 143await File.WriteAllTextAsync(referencedProject, """<Project><ItemGroup><PackageReference Include="Aspire.Hosting" /></ItemGroup></Project>"""); 145await File.WriteAllTextAsync(packagesProps, """<Project><ItemGroup><PackageVersion Include="Aspire.Hosting" Version="13.5.0" /></ItemGroup></Project>"""); 150await File.WriteAllTextAsync(packagesProps, """<Project><ItemGroup><PackageVersion Include="Aspire.Hosting" Version="13.6.0-dev" /></ItemGroup></Project>"""); 161await File.WriteAllTextAsync(leaf, """<Project><ItemGroup><PackageReference Include="Aspire.Hosting" Version="13.5.0" /></ItemGroup></Project>"""); 163await File.WriteAllTextAsync(referencedProject, """<Project><ItemGroup><ProjectReference Include="Leaf.csproj" /></ItemGroup></Project>"""); 170await File.WriteAllTextAsync(leaf, """<Project><ItemGroup><PackageReference Include="Aspire.Hosting" Version="13.6.0-dev" /></ItemGroup></Project>"""); 181await File.WriteAllTextAsync(leaf, """<Project><ItemGroup><PackageReference Include="Some.Package" Version="13.4.*" /></ItemGroup></Project>"""); 183await File.WriteAllTextAsync(referencedProject, """<Project><ItemGroup><ProjectReference Include="Leaf.csproj" /></ItemGroup></Project>"""); 199await File.WriteAllTextAsync(first, """<Project><ItemGroup><ProjectReference Include="Second.csproj" /></ItemGroup></Project>"""); 200await File.WriteAllTextAsync(second, """<Project><ItemGroup><ProjectReference Include="First.csproj" /></ItemGroup></Project>"""); 213await File.WriteAllTextAsync(referencedProject, "<Project />"); 229await File.WriteAllTextAsync(referencedProject, """<Project><ItemGroup><PackageReference Include="Some.Package" Version="13.4.*" /></ItemGroup></Project>"""); 242await File.WriteAllTextAsync(referencedProject, """<Project ToolsVersion="4.0"><ItemGroup><PackageReference Include="Some.Package" Version="13.5.0" /></ItemGroup></Project>"""); 356File.WriteAllText(Path.Combine(objDir, "project.assets.json"), "{}"); 359File.WriteAllText(Path.Combine(objDir, "aspire-restore.stamp"), fingerprint); 1373await File.WriteAllTextAsync(aspireConfigPath, """ 1403Assert.True(File.Exists(appSettingsPath)); 1405var appSettingsContent = await File.ReadAllTextAsync(appSettingsPath); 1564await File.WriteAllTextAsync(aspireConfigPath, $$""" 1623await File.WriteAllTextAsync(aspireConfigPath, """ 1683await File.WriteAllTextAsync(aspireConfigPath, """ 1742await File.WriteAllTextAsync(aspireConfigPath, """ 1802await File.WriteAllTextAsync(aspireConfigPath, $$""" 1857await File.WriteAllTextAsync(aspireConfigPath, """ 1922await File.WriteAllTextAsync(aspireConfigPath, """ 2005await File.WriteAllTextAsync(aspireConfigPath, """ 2094await File.WriteAllTextAsync(aspireConfigPath, """ 2176await File.WriteAllTextAsync(aspireConfigPath, """ 2252restoreConfigFileExistedDuringBuild = restoreConfigFile is not null && File.Exists(restoreConfigFile); 2317temporaryNuGetConfigContent = File.ReadAllText(GetArgumentValue(args, "--nuget-config")); 2399Assert.True(File.Exists(Path.Combine(layoutPath, "libs", "MyIntegration.dll"))); 2473await using var probeManifestStream = File.OpenRead(probeManifestPath); 2527await using var probeManifestStream = File.OpenRead(probeManifestPath); 2611await File.WriteAllTextAsync(copiedFilePath, "corrupt"); 2617Assert.Equal("integration-v1", await File.ReadAllTextAsync(copiedFilePath)); 2658Assert.True(File.Exists(lockedFilePath)); 2659Assert.True(File.Exists(Path.Combine(secondLayoutPath, "libs", "MyIntegration.dll"))); 2678File.WriteAllText(firstSourcePath, "redis"); 2679File.WriteAllText(secondSourcePath, "redis"); 2724File.WriteAllText(firstPackagePath, "redis"); 2725File.WriteAllText(secondPackagePath, "redis"); 2726File.WriteAllText(projectPath, "integration"); 2785File.SetLastWriteTimeUtc(packageSourcePath, File.GetLastWriteTimeUtc(packageSourcePath).AddMinutes(5)); 2858File.WriteAllText( 2887if (!File.Exists(sourcePath) || File.ReadAllText(sourcePath) != content) 2889File.WriteAllText(sourcePath, content); 2900File.WriteAllLines(Path.Combine(restoreDirectory.FullName, PrebuiltAppHostServer.ClosureMetadataFileName), metadataLines); 2901File.WriteAllLines(Path.Combine(restoreDirectory.FullName, PrebuiltAppHostServer.ClosureSourcesFileName), sourcePaths); 2902File.WriteAllLines(Path.Combine(restoreDirectory.FullName, PrebuiltAppHostServer.ClosureTargetsFileName), targetPaths); 2903File.WriteAllLines(Path.Combine(restoreDirectory.FullName, PrebuiltAppHostServer.ProjectRefAssemblyNamesFileName), projectReferenceAssemblyNames); 2946File.WriteAllText(Path.Combine(objDirectory.FullName, "project.assets.json"), projectAssetsContent);
Projects\ProcessGuestLauncherTests.cs (3)
341await File.WriteAllTextAsync(scriptFile.FullName, content); 352await File.WriteAllTextAsync(shellFile.FullName, shellContent); 353File.SetUnixFileMode(
Projects\ProjectLocatorTests.cs (218)
49await File.WriteAllTextAsync( 65await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 69await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 73await File.WriteAllTextAsync(configPath, originalConfig); 86Assert.Equal(originalConfig, await File.ReadAllTextAsync(configPath)); 96await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 100await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 104await File.WriteAllTextAsync(configPath, originalConfig); 115Assert.Equal(originalConfig, await File.ReadAllTextAsync(configPath)); 125await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 129await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 133await File.WriteAllTextAsync(configPath, originalConfig); 146Assert.Equal(originalConfig, await File.ReadAllTextAsync(configPath)); 158await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 162await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 165await File.WriteAllTextAsync(configPath, """{"appHost":{"path":"FirstAppHost/FirstAppHost.csproj"}}"""); 191await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 195await File.WriteAllTextAsync(firstAlternative.FullName, "Not a real apphost"); 197await File.WriteAllTextAsync(secondAlternative.FullName, "Not a real apphost"); 200await File.WriteAllTextAsync(configPath, """{"appHost":{"path":"FirstAppHost/FirstAppHost.csproj"}}"""); 224await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 228await File.WriteAllTextAsync(alternativeAppHost.FullName, "Not a real apphost"); 232await File.WriteAllTextAsync(configPath, originalConfig); 243Assert.Equal(originalConfig, await File.ReadAllTextAsync(configPath)); 253await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 277await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 302await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 307await File.WriteAllTextAsync(configPath, """{"sdk":{"version":"9.9.9"}}"""); 341using (var document = JsonDocument.Parse(await File.ReadAllTextAsync(configPath))) 372await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 376await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 379await File.WriteAllTextAsync(configPath, """{"appHost":{"path":"FirstAppHost/FirstAppHost.csproj"}}"""); 403await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 407await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 411await File.WriteAllTextAsync(configPath, originalConfig); 429Assert.Equal(originalConfig, await File.ReadAllTextAsync(configPath)); 439await File.WriteAllTextAsync(firstAppHostProjectFile.FullName, "Not a real apphost"); 443await File.WriteAllTextAsync(secondAppHostProjectFile.FullName, "Not a real apphost"); 446await File.WriteAllTextAsync(configPath, """{"appHost":{"path":"FirstAppHost/FirstAppHost.csproj"}}"""); 478using var document = JsonDocument.Parse(File.ReadAllText(configPath)); 509await File.WriteAllTextAsync(projectFile.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 529Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName))); 541await File.WriteAllTextAsync(brokenAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 545await File.WriteAllTextAsync(decoyAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 550await File.WriteAllTextAsync(aspireSettingsFile.FullName, JsonSerializer.Serialize(new 579Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName))); 591await File.WriteAllTextAsync(outsideAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 595await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 629await File.WriteAllTextAsync(appHostFile.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 692await File.WriteAllTextAsync(projectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk.Web\"></Project>"); 721await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 725await File.WriteAllTextAsync(otherAppHostProjectFile.FullName, "Not a real apphost"); 754await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 785await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 812await File.WriteAllTextAsync(realAppHostProjectFile.FullName, "Not a real apphost project"); 853await File.WriteAllTextAsync(staleProjectFile.FullName, "Not a real apphost project"); 856await File.WriteAllTextAsync(realAppHostProjectFile.FullName, "Not a real apphost project"); 906await File.WriteAllTextAsync(aspireSettingsFile.FullName, JsonSerializer.Serialize(new 929await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 964await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 968await File.WriteAllTextAsync(decoyAppHostProjectFile.FullName, "Not a real apphost"); 971await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1002await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 1006await File.WriteAllTextAsync(decoyAppHostProjectFile.FullName, "Not a real apphost"); 1009await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1039await File.WriteAllTextAsync(guestAppHostFile.FullName, "// guest apphost"); 1042await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1076await File.WriteAllTextAsync(configuredAppHostProjectFile.FullName, "Not a real apphost"); 1079await File.WriteAllTextAsync(realAppHostProjectFile.FullName, "Not a real apphost"); 1082await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1129await File.WriteAllTextAsync(configuredAppHostProjectFile.FullName, "Not a real apphost"); 1132await File.WriteAllTextAsync(realAppHostProjectFile.FullName, "Not a real apphost"); 1135await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1181await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 1185await File.WriteAllTextAsync(otherAppHostProjectFile.FullName, "Not a real apphost"); 1188await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1218await File.WriteAllTextAsync(settingsAppHostFile.FullName, "Not a real apphost"); 1224await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1257await File.WriteAllTextAsync(settingsAppHostFile.FullName, "Not a supported apphost type"); 1260await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 1292await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 1322await File.WriteAllTextAsync(projectFile1.FullName, "Not a real project file."); 1325await File.WriteAllTextAsync(projectFile2.FullName, "Not a real project file."); 1340await File.WriteAllTextAsync(appHostProject.FullName, "Not a real apphost project."); 1343await File.WriteAllTextAsync(webProject.FullName, "Not a real web project."); 1386await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1404await File.WriteAllTextAsync(onDiskProjectFile.FullName, "Not a real project file."); 1413Assert.True(File.Exists(mismatchedCasePath)); 1433await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1449await File.WriteAllTextAsync(appHostFile.FullName, "// TypeScript AppHost"); 1451await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName), JsonSerializer.Serialize(new 1487await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real project file."); 1509var settingsJson = await File.ReadAllTextAsync(settingsFile.FullName); 1524await File.WriteAllTextAsync(appHostFile.FullName, "// TypeScript apphost"); 1527await File.WriteAllTextAsync( 1571Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName))); 1573var adjacentConfigJson = await File.ReadAllTextAsync(adjacentConfigPath); 1591await File.WriteAllTextAsync(appHost1File.FullName, "// TypeScript apphost"); 1593await File.WriteAllTextAsync(appHost1ConfigPath, """ 1603await File.WriteAllTextAsync(appHost2File.FullName, "// TypeScript apphost"); 1605await File.WriteAllTextAsync(appHost2ConfigPath, """ 1641Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName))); 1643var appHost1ConfigJson = await File.ReadAllTextAsync(appHost1ConfigPath); 1648var appHost2ConfigJson = await File.ReadAllTextAsync(appHost2ConfigPath); 1661await File.WriteAllTextAsync(appHostFile.FullName, "// TypeScript apphost"); 1695Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName))); 1710await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 1721await File.WriteAllTextAsync(aspireSettingsFile.FullName, JsonSerializer.Serialize(new { appHostPath = relativeAppHostPath })); 1740Assert.True(File.Exists(aspireConfigFilePath), "aspire.config.json should have been created by migration from .aspire/settings.json"); 1742var configJson = await File.ReadAllTextAsync(aspireConfigFilePath); 1754await File.WriteAllTextAsync( 1779await File.WriteAllTextAsync( 1805await File.WriteAllTextAsync( 1815await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 1820await File.WriteAllTextAsync( 1860await File.WriteAllTextAsync(appHostFile.FullName, @"using Aspire.Hosting 1880await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 1885await File.WriteAllTextAsync( 1921await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1948await File.WriteAllTextAsync( 1972await File.WriteAllTextAsync(appHostFile.FullName, @"using Aspire.Hosting; 1993await File.WriteAllTextAsync(appHostFile.FullName, "using Aspire.Hosting;"); 1996await File.WriteAllTextAsync(projectFile.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2019await File.WriteAllTextAsync( 2030await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 2045await File.WriteAllTextAsync(txtFile.FullName, "Some text file"); 2065await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 2070await File.WriteAllTextAsync( 2257await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2312await File.WriteAllTextAsync(projectFile.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2329Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName))); 2342await File.WriteAllTextAsync(first.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2345await File.WriteAllTextAsync(second.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2382await File.WriteAllTextAsync(brokenAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2387await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 2424await File.WriteAllTextAsync(healthyAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2429await File.WriteAllTextAsync(brokenAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2432await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 2465await File.WriteAllTextAsync(configuredAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2470await File.WriteAllTextAsync(firstAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2473await File.WriteAllTextAsync(secondAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2476await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 2510await File.WriteAllTextAsync(unsupportedAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2515await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 2564await File.WriteAllTextAsync(brokenAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2568await File.WriteAllTextAsync(firstHealthy.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2572await File.WriteAllTextAsync(secondHealthy.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 2575await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 2614await File.WriteAllTextAsync(projectFile1.FullName, "Not a real project file."); 2616await File.WriteAllTextAsync(projectFile2.FullName, "Not a real project file."); 2651await File.WriteAllTextAsync( 2679await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2718await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 2723await File.WriteAllTextAsync(appHostCsFile.FullName, """ 2761await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 2765await File.WriteAllTextAsync(appHostCsFile.FullName, """ 2803await File.WriteAllTextAsync(appHostCsFile.FullName, """ 2826await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2847await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2869await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 2922await File.WriteAllTextAsync(normalProject.FullName, "Not a real project file."); 2929await File.WriteAllTextAsync(cachedProject.FullName, "Not a real project file."); 2959await File.WriteAllTextAsync(project1.FullName, "Not a real project file."); 2963await File.WriteAllTextAsync(project2.FullName, "Not a real project file."); 2990await File.WriteAllTextAsync(normalProject.FullName, "Not a real project file."); 2997await File.WriteAllTextAsync(cachedProject.FullName, "Not a real project file."); 3031await File.WriteAllTextAsync(siblingProject.FullName, "Not a real project file."); 3037await File.WriteAllTextAsync(cachedProject.FullName, "Not a real project file."); 3067await File.WriteAllTextAsync(appHostFile.FullName, "Not a real apphost"); 3090await File.WriteAllTextAsync(appHost1File.FullName, "Not a real apphost"); 3096await File.WriteAllTextAsync(appHost2File.FullName, "Not a real apphost"); 3120await File.WriteAllTextAsync(appHostFile.FullName, "Not a real apphost"); 3143await File.WriteAllTextAsync(Path.Combine(appHost1Dir.FullName, "AppHost1.csproj"), "Not a real apphost"); 3146await File.WriteAllTextAsync(Path.Combine(appHost2Dir.FullName, "AppHost2.csproj"), "Not a real apphost"); 3165await File.WriteAllTextAsync(appHost1File.FullName, "Not a real apphost"); 3168await File.WriteAllTextAsync(appHost2File.FullName, "Not a real apphost"); 3171await File.WriteAllTextAsync(slowValidationFile.FullName, "Not a real apphost"); 3224await File.WriteAllTextAsync(appHost1File.FullName, "Not a real apphost"); 3228await File.WriteAllTextAsync(appHost2File.FullName, "Not a real apphost"); 3237await File.WriteAllTextAsync(aspireSettingsFile.FullName, JsonSerializer.Serialize(new { appHostPath = relativeAppHostPath })); 3257await File.WriteAllTextAsync(appHost1File.FullName, "Not a real apphost"); 3261await File.WriteAllTextAsync(appHost2File.FullName, "Not a real apphost"); 3270await File.WriteAllTextAsync(aspireSettingsFile.FullName, JsonSerializer.Serialize(new { appHostPath = relativeAppHostPath })); 3292await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 3297await File.WriteAllTextAsync(staleAppHost.FullName, "Not a real project file."); 3320await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 3324await File.WriteAllTextAsync(staleAppHost.FullName, "Not a real project file."); 3349await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 3353await File.WriteAllTextAsync(skipListedAppHost.FullName, "Not a real project file."); 3378await File.WriteAllTextAsync(buildableAppHost.FullName, "Not a real project file."); 3382await File.WriteAllTextAsync(unbuildableAppHost.FullName, "Not a real project file."); 3417await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 3422await File.WriteAllTextAsync(staleAppHost.FullName, "Not a real project file."); 3456await File.WriteAllTextAsync(configuredAppHost.FullName, "<Project Sdk=\"Aspire.AppHost.Sdk\"></Project>"); 3460await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new 3492await File.WriteAllTextAsync(trackedAppHost.FullName, "Not a real project file."); 3496await File.WriteAllTextAsync(ignoredAppHost.FullName, "Not a real project file."); 3527await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 3532await File.WriteAllTextAsync(nodeModulesAppHost.FullName, "Not a real project file."); 3564await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 3620await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 3687await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 3720await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); 3806await File.WriteAllTextAsync(configPath, """ 3834await File.WriteAllTextAsync(aspireSettingsFile.FullName, """ 3861await File.WriteAllTextAsync(configPath, """ 3886await File.WriteAllTextAsync(aspireSettingsFile.FullName, """ 3911await File.WriteAllTextAsync(configPath, """ 3941await File.WriteAllTextAsync(settingsPath, """ 3968await File.WriteAllTextAsync(settingsPath, """ 3995await File.WriteAllTextAsync(settingsPath, """ 4033await File.WriteAllTextAsync(realAppHost.FullName, "Not a real project file."); 4057Assert.True(File.Exists(pathThroughLink), "Symlinked path should resolve to the real apphost file."); 4095await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real project file."); 4098if (!File.Exists(differentlyCasedPath)) 4106await File.WriteAllTextAsync(configPath, $$""" 4130await File.WriteAllTextAsync(configuredAppHost.FullName, "Not a real project file."); 4133await File.WriteAllTextAsync(configPath, JsonSerializer.Serialize(new
Projects\ProjectUpdaterTests.cs (93)
39await File.WriteAllTextAsync( 149await File.WriteAllTextAsync( 161await File.WriteAllTextAsync( 288var updatedConfig = await File.ReadAllTextAsync(aspireConfigFile.FullName); 313await File.WriteAllTextAsync( 420await File.WriteAllTextAsync( 429await File.WriteAllTextAsync( 571var updatedConfig = await File.ReadAllTextAsync(aspireConfigFile.FullName); 584await File.WriteAllTextAsync( 713await File.WriteAllTextAsync( 843await File.WriteAllTextAsync( 852await File.WriteAllTextAsync( 866await File.WriteAllTextAsync( 958var updatedContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 976await File.WriteAllTextAsync( 988await File.WriteAllTextAsync( 1063var updatedContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1078await File.WriteAllTextAsync( 1090await File.WriteAllTextAsync( 1166var content = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1201await File.WriteAllTextAsync( 1216await File.WriteAllTextAsync( 1291var updatedContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1308await File.WriteAllTextAsync( 1371var updatedContent = await File.ReadAllTextAsync(appHostProjectFile.FullName); 1396await File.WriteAllTextAsync(appHostProjectFile.FullName, ProjectContent); 1445var unchangedContent = await File.ReadAllTextAsync(appHostProjectFile.FullName); 1465await File.WriteAllTextAsync( 1480await File.WriteAllTextAsync( 1540var updatedProject = await File.ReadAllTextAsync(appHostProjectFile.FullName); 1541var updatedProps = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1562Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config"))); 1563Assert.False(File.Exists(Path.Combine(appHostProjectFile.DirectoryName!, "nuget.config"))); 1578await File.WriteAllTextAsync(nugetConfigPath, 1611Assert.True(File.Exists(nugetConfigPath)); 1612var updatedConfig = await File.ReadAllTextAsync(nugetConfigPath); 1631Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config"))); 1639await File.WriteAllTextAsync( 1779await File.WriteAllTextAsync( 1791await File.WriteAllTextAsync( 1877var content = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1892await File.WriteAllTextAsync( 1905await File.WriteAllTextAsync( 2000var content = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 2016await File.WriteAllTextAsync( 2028await File.WriteAllTextAsync( 2130await File.WriteAllTextAsync( 2142await File.WriteAllTextAsync( 2239await File.WriteAllTextAsync( 2335await File.WriteAllTextAsync( 2347await File.WriteAllTextAsync( 2435await File.WriteAllTextAsync( 2513await File.WriteAllTextAsync( 2596await File.WriteAllTextAsync( 2665var updatedContent = await File.ReadAllTextAsync(appHostFile.FullName); 2688await File.WriteAllTextAsync( 2760var updatedContent = await File.ReadAllTextAsync(appHostFile.FullName); 2782await File.WriteAllTextAsync( 2845var updatedContent = await File.ReadAllTextAsync(appHostFile.FullName); 2859await File.WriteAllTextAsync( 2928var updatedContent = await File.ReadAllTextAsync(appHostFile.FullName); 2940await File.WriteAllTextAsync( 3027await File.WriteAllTextAsync( 3091var updatedContent = await File.ReadAllTextAsync(appHostProjectFile.FullName); 3105await File.WriteAllTextAsync( 3170var updatedContent = await File.ReadAllTextAsync(appHostProjectFile.FullName); 3182await File.WriteAllTextAsync( 3309await File.WriteAllTextAsync( 3326await File.WriteAllTextAsync( 3419var directoryPackagesContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 3442await File.WriteAllTextAsync(projectFile, originalContent); 3450var updatedContent = await File.ReadAllTextAsync(projectFile); 3474await File.WriteAllTextAsync(projectFile, originalContent); 3482var updatedContent = await File.ReadAllTextAsync(projectFile); 3511await File.WriteAllTextAsync(projectFile, originalContent); 3519var updatedContent = await File.ReadAllTextAsync(projectFile); 3547await File.WriteAllTextAsync(projectFile, originalContent); 3555var updatedContent = await File.ReadAllTextAsync(projectFile); 3579await File.WriteAllTextAsync(projectFile, originalContent); 3587var updatedContent = await File.ReadAllTextAsync(projectFile); 3612await File.WriteAllTextAsync(projectFile, originalContent); 3620var updatedContent = await File.ReadAllTextAsync(projectFile); 3654await File.WriteAllTextAsync(projectFile, originalContent); 3658await File.WriteAllTextAsync(directoryPackagesPropsFile, """ 3676var updatedPropsContent = await File.ReadAllTextAsync(directoryPackagesPropsFile); 3682var updatedCsprojContent = await File.ReadAllTextAsync(projectFile); 3712await File.WriteAllTextAsync( 3826await File.WriteAllTextAsync( 3903await File.WriteAllTextAsync( 3956await File.WriteAllTextAsync( 3980var updatedContent = await File.ReadAllTextAsync(existingConfigFile.FullName); 3993await File.WriteAllTextAsync( 4057var content = await File.ReadAllTextAsync(createdConfig.FullName);
Projects\RunningInstanceManagerTests.cs (2)
46Assert.True(File.Exists(socketPath)); 55Assert.False(File.Exists(socketPath));
Projects\TypeScriptAppHostToolchainResolverTests.cs (29)
18File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"packageManager\": \"bun@1.2.0\" }"); 29File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 30File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "pnpm-lock.yaml"), "lockfileVersion: '9.0'"); 42File.WriteAllText(packageJsonPath, "{ \"packageManager\": \"yarn@1.22.22\" }"); 53File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"packageManager\": \"yarn@4.14.1\" }"); 64File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 66File.WriteAllText(yarnLockPath, "# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n# yarn lockfile v1\n"); 79File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 80File.WriteAllText(Path.Combine(parentDirectory.FullName, "package.json"), "{ \"name\": \"workspace\" }"); 82File.WriteAllText(yarnLockPath, "# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n# yarn lockfile v1\n"); 95File.WriteAllText(Path.Combine(parentDirectory.FullName, "package.json"), "{ \"name\": \"workspace\" }"); 96File.WriteAllText(Path.Combine(parentDirectory.FullName, "yarn.lock"), string.Empty); 97File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 98File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package-lock.json"), "{}"); 110File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 111File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package-lock.json"), "{}"); 112File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "yarn.lock"), string.Empty); 124File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 136File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 147File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 148File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "yarn.lock"), string.Empty); 167File.WriteAllText(Path.Combine(appHostDirectory.Parent!.FullName, "package.json"), "{ \"packageManager\": \"pnpm@10.12.1\" }"); 168File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 181File.WriteAllText(Path.Combine(appHostDirectory.Parent!.FullName, "package.json"), "{ \"packageManager\": \"pnpm@10.12.1\" }"); 182File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package.json"), "{ \"packageManager\": \"bun@1.2.0\" }"); 196File.WriteAllText(Path.Combine(appHostDirectory.Parent!.FullName, "package.json"), "{ \"packageManager\": \"yarn@4.14.1\" }"); 197File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package.json"), "{ \"name\": \"apphost\" }"); 198File.WriteAllText(Path.Combine(appHostDirectory.FullName, "pnpm-lock.yaml"), "lockfileVersion: '9.0'"); 210File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"packageManager\": \"bun@1.2.0\" }");
Scaffolding\ScaffoldingServiceTests.cs (8)
36File.WriteAllText(Path.Combine(rootDirectory.FullName, "package.json"), "{}"); 74File.WriteAllText(Path.Combine(rootDirectory.FullName, "package.json"), "{}"); 141File.WriteAllText(Path.Combine(rootDirectory.FullName, "package.json"), "{ \"packageManager\": \"npm@10.0.0\" }"); 142File.WriteAllText(Path.Combine(appHostDirectory.FullName, "package.json"), "{ \"packageManager\": \"pnpm@10.0.0\" }"); 235File.WriteAllText(Path.Combine(rootDirectory.FullName, ".gitignore"), "node_modules/\n"); 236File.WriteAllText(Path.Combine(rootDirectory.FullName, "package.json"), "{}"); 237File.WriteAllText(Path.Combine(rootDirectory.FullName, "apphost.mts"), string.Empty); 275File.WriteAllText(Path.Combine(rootDirectory.FullName, ".vscode", "settings.json"), "{}");
Secrets\SecretsStoreTests.cs (7)
37Assert.True(File.Exists(path)); 118File.WriteAllText(path, """ 139File.WriteAllText(path, """ 169File.WriteAllText(path, """ 189var json = File.ReadAllText(path); 207Assert.True(File.Exists(path)); 232var json = File.ReadAllText(path);
Telemetry\InternalMicrosoftDetectorTests.cs (7)
25await File.WriteAllTextAsync(cacheFilePath, """ 64await File.WriteAllTextAsync(cacheFilePath, """ 84var updatedCache = await File.ReadAllTextAsync(cacheFilePath); 257await File.WriteAllTextAsync(Path.Combine(workspace.Path, "dsregcmd"), string.Empty); 258await File.WriteAllTextAsync(Path.Combine(workspace.Path, "dsregcmd.EXE"), string.Empty); 294await File.WriteAllTextAsync(Path.Combine(workspace.Path, "dsregcmd"), string.Empty); 295await File.WriteAllTextAsync(Path.Combine(workspace.Path, "dsregcmd.EXE"), string.Empty);
Templating\DotNetTemplateFactoryTests.cs (16)
40await File.WriteAllTextAsync(path, content); 65Assert.True(File.Exists(nugetConfigPath), "nuget.config should be created in working directory for in-place creation"); 97Assert.True(File.Exists(nugetConfigPath), "nuget.config should exist in working directory"); 99var content = await File.ReadAllTextAsync(nugetConfigPath); 135var parentContent = await File.ReadAllTextAsync(parentConfigPath); 141Assert.True(File.Exists(outputConfigPath), "nuget.config should be created in output directory"); 143var outputContent = await File.ReadAllTextAsync(outputConfigPath); 177Assert.True(File.Exists(outputConfigPath), "nuget.config should exist in output directory"); 179var content = await File.ReadAllTextAsync(outputConfigPath); 204Assert.False(File.Exists(workingConfigPath), "No nuget.config should be created in working directory"); 208Assert.True(File.Exists(outputConfigPath), "nuget.config should be created in output directory"); 210var content = await File.ReadAllTextAsync(outputConfigPath); 231Assert.False(File.Exists(workingConfigPath), "No nuget.config should be created for implicit channel"); 232Assert.False(File.Exists(outputConfigPath), "No nuget.config should be created for implicit channel"); 252Assert.False(File.Exists(workingConfigPath), "No nuget.config should be created when no mappings exist"); 253Assert.False(File.Exists(outputConfigPath), "No nuget.config should be created when no mappings exist");
Templating\JavaAppHostTemplateTests.cs (14)
17var lines = File.ReadAllLines(GetJavaStarterAppHostPath()); 29var lines = File.ReadAllLines(GetJavaStarterAppHostPath()); 46Assert.True(File.Exists(path), $"Expected the java-starter VS Code settings at {path}"); 48using var document = System.Text.Json.JsonDocument.Parse(File.ReadAllText(path)); 68await Verify(File.ReadAllText(GetJavaStarterAppHostPath()), extension: "java"); 84Assert.True(File.Exists(pomPath), $"Expected the java-starter API's Maven project at {pomPath}"); 85Assert.Contains("spring-boot-starter-parent", File.ReadAllText(pomPath), StringComparison.Ordinal); 107using var document = System.Text.Json.JsonDocument.Parse(File.ReadAllText(path)); 133Assert.True(File.Exists(path), $"Expected the java-starter Maven wrapper at {path}"); 137Assert.True(File.Exists(propertiesPath), $"Expected the java-starter wrapper properties at {propertiesPath}"); 138Assert.Contains("distributionType=only-script", File.ReadAllText(propertiesPath), StringComparison.Ordinal); 151var appHost = File.ReadAllText(GetJavaStarterAppHostPath()); 154var viteConfig = File.ReadAllText(Path.Combine(GetJavaStarterDirectory(), "frontend", "vite.config.ts")); 161Assert.True(File.Exists(path), $"Expected the java-starter AppHost at {path}");
Templating\JavaStarterScaffoldTests.cs (4)
38Assert.True(File.Exists(wrapperPath), $"Expected the scaffolded Maven wrapper at {wrapperPath}"); 45private static UnixFileMode GetUnixFileMode(string path) => File.GetUnixFileMode(path); 78Assert.True(File.Exists(Path.Combine(outputDirectory, "frontend", "vite.config.ts"))); 79Assert.True(File.Exists(Path.Combine(outputDirectory, "AppHost.java")));
Templating\OutputPathHelperTests.cs (5)
36File.WriteAllText(Path.Combine(dir.FullName, "file.txt"), "content"); 52File.WriteAllText(Path.Combine(dir.FullName, "file.txt"), "content"); 67File.WriteAllText(Path.Combine(dir.FullName, "file.txt"), "content"); 122File.WriteAllText(Path.Combine(dir.FullName, "file.txt"), "content"); 159File.WriteAllText(Path.Combine(dir.FullName, "file.txt"), "content");
Templating\TemplateGitIgnoreTests.cs (2)
16Assert.True(File.Exists(filePath), $"Expected template .gitignore at {filePath}"); 18var lines = File.ReadAllLines(filePath);
Templating\TemplateNuGetConfigServiceTests.cs (24)
30await File.WriteAllTextAsync( 114await File.WriteAllTextAsync( 124await File.WriteAllTextAsync( 179Assert.False(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, "nuget.config"))); 448File.WriteAllText( 647File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.5.0.nupkg"), string.Empty); 648File.WriteAllText(Path.Combine(prPackagesDirectory.FullName, "Aspire.ProjectTemplates.13.6.0-dev.nupkg"), string.Empty); 721File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.5.0.nupkg"), string.Empty); 722File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.6.0.nupkg"), string.Empty); 762File.WriteAllText( 800File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.6.0-dev.nupkg"), string.Empty); 801File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.99.0.0.nupkg"), string.Empty); 836File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.99.0.0.nupkg"), string.Empty); 877File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.6.0-dev.nupkg"), string.Empty); 878File.WriteAllText(Path.Combine(packagesDirectory.FullName, "Aspire.ProjectTemplates.13.7.0-dev.nupkg"), string.Empty); 978File.WriteAllText(Path.Combine(packagesDir.FullName, "Aspire.ProjectTemplates.13.5.0.nupkg"), string.Empty); 1035await File.WriteAllTextAsync(templatePackagePath, string.Empty); 1124Assert.True(File.Exists(configPath)); 1161Assert.False(File.Exists(Path.Combine(outputDir.FullName, "nuget.config"))); 1171await File.WriteAllTextAsync( 1207Assert.True(File.Exists(configPath)); 1232await File.WriteAllTextAsync( 1267Assert.True(File.Exists(configPath)); 1277Assert.False(File.Exists(configPath));
Templating\TemplatePackageLockTests.cs (4)
26using var packageJson = JsonDocument.Parse(File.ReadAllText(filePath)); 52using var packageLock = JsonDocument.Parse(File.ReadAllText(filePath)); 118using var packageLock = JsonDocument.Parse(File.ReadAllText(filePath)); 127using var packageLock = JsonDocument.Parse(File.ReadAllText(filePath));
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
TestServices\FakePlaywrightServices.cs (3)
151await File.WriteAllTextAsync(path, content, cancellationToken); 174await File.WriteAllTextAsync(Path.Combine(_bundleDirectory.FullName, "skill-manifest.json"), manifestJson, cancellationToken); 197using var stream = File.OpenRead(path);
TestServices\ProcessTestHelpers.cs (1)
14if (File.Exists(pidFile))
TestServices\TestGitWorktree.cs (2)
21File.WriteAllText(Path.Combine(adminDirectory, "gitdir"), backPointer + Environment.NewLine); 37File.WriteAllText(gitFilePath, $"gitdir: {pointer}{Environment.NewLine}");
Utils\AppHostHelperTests.cs (26)
257File.WriteAllText(socket1, ""); 258File.WriteAllText(socket2, ""); 261File.WriteAllText(otherSocket, ""); 283File.WriteAllText(oldFormatSocket, ""); 286File.WriteAllText(legacyPidSocket, ""); 310File.WriteAllText(badSeparator, ""); 314File.WriteAllText(badPid, ""); 333File.WriteAllText(otherSocket, ""); 353File.WriteAllText(oldFormatSocket, ""); 357File.WriteAllText(orphanedSocket, ""); 361File.WriteAllText(liveSocket, ""); 367Assert.True(File.Exists(oldFormatSocket), "Old format socket should still exist (can't detect orphan)"); 368Assert.False(File.Exists(orphanedSocket), "Orphaned socket should be deleted"); 369Assert.True(File.Exists(liveSocket), "Live socket should still exist"); 393File.WriteAllText(orphanedSocket, ""); 394File.WriteAllText(liveSocket, ""); 395File.WriteAllText(pidlessSocket, ""); 407Assert.False(File.Exists(orphanedSocket)); 408Assert.True(File.Exists(liveSocket)); 409Assert.True(File.Exists(pidlessSocket)); 424File.WriteAllText(projectFileViaSymlink, "<Project />"); 432File.WriteAllText(liveSocket, ""); 461File.WriteAllText(realProjectPath, "<Project />"); 570File.WriteAllText(socket, ""); 601File.WriteAllText(socket, ""); 631File.WriteAllText(legacySocket, "");
Utils\AspireRepositoryDetectorTests.cs (3)
41File.WriteAllText(Path.Combine(repoRoot, "Aspire.slnx"), string.Empty); 67File.WriteAllText(Path.Combine(repoRoot, "Aspire.slnx"), string.Empty); 88File.WriteAllText(Path.Combine(repoRoot, "Aspire.slnx"), string.Empty);
Utils\CliPathHelperTests.cs (19)
255File.WriteAllText(target, string.Empty); 258File.CreateSymbolicLink(link, target); 330File.WriteAllText(realPath, string.Empty); 333Assert.True(File.Exists(firmlinkedPath), "firmlinked /private/var path should resolve to the same physical file"); 346File.WriteAllText(realPath, string.Empty); 385File.WriteAllText(binaryPath, string.Empty); 386File.WriteAllText(Path.Combine(binaryDir, InstallSidecarReader.SidecarFileName), $$"""{"source":"{{source}}"}"""); 399File.WriteAllText(staleFile, string.Empty); 401File.WriteAllText(freshFile, string.Empty); 404File.SetLastWriteTimeUtc(staleFile, fakeTime.GetUtcNow().UtcDateTime - TimeSpan.FromHours(48)); 405File.SetLastWriteTimeUtc(freshFile, fakeTime.GetUtcNow().UtcDateTime - TimeSpan.FromMinutes(5)); 411Assert.False(File.Exists(staleFile)); 412Assert.True(File.Exists(freshFile)); 428File.WriteAllText(matching, string.Empty); 430File.WriteAllText(unrelated, string.Empty); 433File.SetLastWriteTimeUtc(matching, fakeTime.GetUtcNow().UtcDateTime - TimeSpan.FromHours(48)); 434File.SetLastWriteTimeUtc(unrelated, fakeTime.GetUtcNow().UtcDateTime - TimeSpan.FromHours(48)); 440Assert.False(File.Exists(matching)); 441Assert.True(File.Exists(unrelated));
Utils\CliTestHelperTests.cs (2)
26Assert.True(File.Exists(logFilePath), $"Log file should exist at {logFilePath}"); 33Assert.False(File.Exists(logFilePath), "Log file should be deleted after workspace disposal");
Utils\CliUpdateNotificationServiceTests.cs (2)
424File.WriteAllText(processPath, string.Empty); 425File.WriteAllText(storeExecutablePath, string.Empty);
Utils\DcpConnectionHealthCheckTests.cs (6)
190await File.WriteAllTextAsync(kubeconfigPath, "clusters:", TestContext.Current.CancellationToken); 205return File.WriteAllTextAsync(kubeconfigPath, completeKubeconfig, cancellationToken); 236File.WriteAllText(keyPath, "cached key"); 241Assert.Equal(certificate.ExportCertificatePem(), File.ReadAllText(certificatePath)); 242Assert.Equal("cached key", File.ReadAllText(keyPath)); 249File.WriteAllText(BundleDiscovery.GetDcpExecutablePath(dcpDirectory.FullName), string.Empty);
Utils\DevCertsCheckTests.cs (14)
69File.WriteAllText(certUtilPath, ""); 72File.SetUnixFileMode(certUtilPath, UnixFileMode.UserRead | UnixFileMode.UserExecute); 101File.WriteAllText(openSslPath, contents); 104File.SetUnixFileMode(openSslPath, UnixFileMode.UserRead | UnixFileMode.UserExecute); 116File.WriteAllText(Path.Combine(trustDirectory.FullName, GetOpenSslCertificateFileName(certificate)), certificatePem); 117File.WriteAllText(Path.Combine(trustDirectory.FullName, hashEntryName), certificatePem); 557File.WriteAllText(Path.Combine(trustDirectory.FullName, GetOpenSslCertificateFileName(certificate)), certificate.ExportCertificatePem()); 607File.WriteAllText(Path.Combine(trustDirectory.FullName, GetOpenSslCertificateFileName(certificate)), certificate.ExportCertificatePem()); 666File.WriteAllText(Path.Combine(trustDirectory.FullName, GetOpenSslCertificateFileName(certificate)), certificate.ExportCertificatePem()); 723File.WriteAllText(Path.Combine(trustDirectory.FullName, GetOpenSslCertificateFileName(certificate)), certificate.ExportCertificatePem()); 854File.WriteAllText(Path.Combine(trustDirectory.FullName, corruptCertificateFileName), "not a certificate"); 900File.WriteAllText(Path.Combine(trustDirectory.FullName, corruptCertificateFileName), "not a certificate"); 946File.WriteAllText(Path.Combine(trustDirectory.FullName, "unrelated.pem"), "not a certificate"); 989File.WriteAllText(Path.Combine(trustDirectory.FullName, GetOpenSslCertificateFileName(certificate)), staleCertificate.ExportCertificatePem());
Utils\DotNetToolDetectionTests.cs (3)
44File.WriteAllText(processPath, string.Empty); 45File.WriteAllText(storeExecutablePath, string.Empty); 84File.WriteAllText(processPath, string.Empty);
Utils\FileSystemHelperTests.cs (38)
19File.WriteAllText(Path.Combine(sourceDir.FullName, "file1.txt"), "content1"); 20File.WriteAllText(Path.Combine(sourceDir.FullName, "file2.txt"), "content2"); 21File.WriteAllText(Path.Combine(sourceDir.FullName, "file3.cs"), "using System;"); 28Assert.True(File.Exists(Path.Combine(destDir, "file1.txt"))); 29Assert.True(File.Exists(Path.Combine(destDir, "file2.txt"))); 30Assert.True(File.Exists(Path.Combine(destDir, "file3.cs"))); 32Assert.Equal("content1", File.ReadAllText(Path.Combine(destDir, "file1.txt"))); 33Assert.Equal("content2", File.ReadAllText(Path.Combine(destDir, "file2.txt"))); 34Assert.Equal("using System;", File.ReadAllText(Path.Combine(destDir, "file3.cs"))); 49File.WriteAllText(Path.Combine(sourceDir.FullName, "root.txt"), "root content"); 50File.WriteAllText(Path.Combine(subDir1.FullName, "level1.txt"), "level 1 content"); 51File.WriteAllText(Path.Combine(subDir2.FullName, "level2.txt"), "level 2 content"); 58Assert.True(File.Exists(Path.Combine(destDir, "root.txt"))); 60Assert.True(File.Exists(Path.Combine(destDir, "subdir1", "level1.txt"))); 62Assert.True(File.Exists(Path.Combine(destDir, "subdir1", "subdir2", "level2.txt"))); 64Assert.Equal("root content", File.ReadAllText(Path.Combine(destDir, "root.txt"))); 65Assert.Equal("level 1 content", File.ReadAllText(Path.Combine(destDir, "subdir1", "level1.txt"))); 66Assert.Equal("level 2 content", File.ReadAllText(Path.Combine(destDir, "subdir1", "subdir2", "level2.txt"))); 159File.WriteAllBytes(binaryFilePath, randomBytes); 166Assert.True(File.Exists(copiedFilePath)); 168var copiedBytes = File.ReadAllBytes(copiedFilePath); 185File.WriteAllText(Path.Combine(current.FullName, $"file{i}.txt"), $"content at level {i}"); 198Assert.True(File.Exists(filePath)); 199Assert.Equal($"content at level {i}", File.ReadAllText(filePath)); 212File.WriteAllText(Path.Combine(sourceDir.FullName, "file1.txt"), "new content 1"); 213File.WriteAllText(Path.Combine(sourceDir.FullName, "file2.txt"), "new content 2"); 216File.WriteAllText(Path.Combine(subDir.FullName, "project.assets.json"), "new assets"); 217File.WriteAllText(Path.Combine(subDir.FullName, "project.csproj.nuget.dgspec.json"), "new dgspec"); 221File.WriteAllText(Path.Combine(destDir, "file1.txt"), "old content 1"); 222File.WriteAllText(Path.Combine(destDir, "file2.txt"), "old content 2"); 225File.WriteAllText(Path.Combine(destSubDir.FullName, "project.assets.json"), "old assets"); 226File.WriteAllText(Path.Combine(destSubDir.FullName, "project.csproj.nuget.dgspec.json"), "old dgspec"); 232Assert.Equal("new content 1", File.ReadAllText(Path.Combine(destDir, "file1.txt"))); 233Assert.Equal("new content 2", File.ReadAllText(Path.Combine(destDir, "file2.txt"))); 234Assert.Equal("new assets", File.ReadAllText(Path.Combine(destDir, "obj", "project.assets.json"))); 235Assert.Equal("new dgspec", File.ReadAllText(Path.Combine(destDir, "obj", "project.csproj.nuget.dgspec.json"))); 247File.WriteAllText(Path.Combine(sourceDir.FullName, "file1.txt"), "new content"); 251File.WriteAllText(Path.Combine(destDir, "file1.txt"), "old content");
Utils\FirstTimeUseNoticeSentinelTests.cs (5)
32File.WriteAllText(sentinelFilePath, string.Empty); 54Assert.True(File.Exists(sentinelFilePath)); 65File.WriteAllText(sentinelFilePath, "existing content"); 73Assert.True(File.Exists(sentinelFilePath)); 91Assert.True(File.Exists(sentinelFilePath));
Utils\IsolatedUserSecretsHelperTests.cs (6)
63File.WriteAllText(sourcePath, """{"TestKey": "TestValue"}"""); 75Assert.True(File.Exists(isolatedPath)); 77var content = File.ReadAllText(isolatedPath); 116File.WriteAllText(secretsPath, """{"TestKey": "TestValue"}"""); 119Assert.True(File.Exists(secretsPath)); 126Assert.False(File.Exists(secretsPath));
Utils\LegacySettingsFileCheckTests.cs (8)
17await File.WriteAllTextAsync(Path.Combine(legacyDir, "settings.json"), "{}"); 42await File.WriteAllTextAsync( 62await File.WriteAllTextAsync(Path.Combine(legacyDir, "settings.json"), "{}"); 63await File.WriteAllTextAsync( 82await File.WriteAllTextAsync( 107await File.WriteAllTextAsync(Path.Combine(legacyDir, "settings.json"), "{}"); 133await File.WriteAllTextAsync(Path.Combine(legacyDir, "settings.json"), "{}"); 138await File.WriteAllTextAsync(
Utils\MissingJavaScriptToolWarningTests.cs (1)
51File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "package.json"), "{ \"packageManager\": \"bun@1.2.0\" }");
Utils\PathNormalizerTests.cs (4)
20File.WriteAllText(file.FullName, "<Project />"); 40File.WriteAllText(target.FullName, "<Project />"); 65File.WriteAllText(file.FullName, "<Project />"); 106File.CreateSymbolicLink(linkPath, targetPath);
Utils\ReparsePointTests.cs (26)
18File.WriteAllText(Path.Combine(target, "marker"), "hello"); 27Assert.Equal("hello", File.ReadAllText(Path.Combine(link, "marker"))); 47File.WriteAllText(Path.Combine(target1, "id"), "one"); 48File.WriteAllText(Path.Combine(target2, "id"), "two"); 52Assert.Equal("one", File.ReadAllText(Path.Combine(link, "id"))); 58Assert.Equal("two", File.ReadAllText(Path.Combine(link, "id"))); 79File.WriteAllText(Path.Combine(real, "legacy"), "legacy"); 90Assert.True(File.Exists(Path.Combine(real, "legacy"))); 119File.WriteAllText(markerPath, "still here"); 127Assert.True(File.Exists(markerPath)); 136File.WriteAllText(Path.Combine(dir, "nested", "f"), "x"); 212File.WriteAllText(Path.Combine(target, "marker"), "hello"); 223Assert.Equal("hello", File.ReadAllText(Path.Combine(link, "marker"))); 244File.WriteAllText(Path.Combine(nestedDir, "data.txt"), "payload"); 256Assert.Equal("payload", File.ReadAllText(Path.Combine(nestedThroughLink, "data.txt"))); 283File.WriteAllText(markerPath, "still here"); 293Assert.True(File.Exists(markerPath)); 352File.WriteAllText(Path.Combine(targetV1, "id"), "one"); 353File.WriteAllText(Path.Combine(targetV2, "id"), "two"); 362Assert.Equal("one", File.ReadAllText(Path.Combine(link, "id"))); 372Assert.Equal("two", File.ReadAllText(Path.Combine(link, "id"))); 382Assert.True(File.Exists(Path.Combine(targetV1, "id"))); 432File.WriteAllText(Path.Combine(targetV1, "id"), "one"); 433File.WriteAllText(Path.Combine(targetV2, "id"), "two"); 453Assert.Equal("two", File.ReadAllText(Path.Combine(link, "id"))); 456Assert.True(File.Exists(Path.Combine(targetV1, "id")));
Aspire.Dashboard (12)
ServiceClient\DashboardRunStore.cs (9)
148if (!File.Exists(DatabasePath)) 200!File.Exists(Path.Combine(directory, DatabaseFileName))) 268var metadata = JsonSerializer.Deserialize<DashboardRunMetadata>(File.ReadAllText(metadataPath)); 355var metadata = JsonSerializer.Deserialize<DashboardRunMetadata>(File.ReadAllText(metadataPath)); 422File.WriteAllText(temporaryPath, JsonSerializer.Serialize(metadata, s_jsonOptions)); 423File.Move(temporaryPath, metadataPath, overwrite: true); 429File.Delete(temporaryPath); 473return JsonSerializer.Deserialize<DashboardRunMetadata>(File.ReadAllText(metadataPath))?.IsPinned == true; 552File.Delete(path);
ServiceClient\DashboardSqliteDatabase.cs (1)
81if (!File.Exists(databasePath))
src\Shared\DirectoryHelper.cs (1)
29File.SetUnixFileMode(path, OwnerOnlyMode);
src\Shared\Export\ExportArchive.cs (1)
56using var fileStream = File.Create(filePath);
Aspire.Dashboard.Components.Tests (1)
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.Dashboard.Tests (36)
BlazorAssetsTests.cs (3)
16Assert.True(File.Exists(blazorWebJsPath), $"Expected generated Blazor asset at {blazorWebJsPath}"); 18var blazorWebJs = File.ReadAllText(blazorWebJsPath); 29while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aspire.slnx")))
Integration\OtlpGrpcServiceTests.cs (2)
176await File.WriteAllTextAsync(configPath, configJson.ToString()).DefaultTimeout(); 225await File.WriteAllTextAsync(configPath, configJson.ToString()).DefaultTimeout();
Integration\StartupTests.cs (5)
262File.Delete(browserTokenConfigFile); 294await File.WriteAllTextAsync(browserTokenConfigFile, changedFrontendBrowserToken).DefaultTimeout(); 309File.Delete(browserTokenConfigFile); 648await File.WriteAllTextAsync(configFilePath, configJson.ToString()).DefaultTimeout(); 1146await File.WriteAllTextAsync(browserTokenConfigFile, browserToken);
Model\DashboardDataSourceTests.cs (22)
67File.SetUnixFileMode( 77File.GetUnixFileMode(applicationDirectory)); 114Assert.False(File.Exists(metadataPath)); 123Assert.False(File.Exists(metadataPath)); 127using var metadata = JsonDocument.Parse(File.ReadAllText(metadataPath)); 150using var metadata = JsonDocument.Parse(File.ReadAllText(Path.Combine(currentRunStore.RunDirectory, "run.json"))); 178Assert.False(File.Exists(Path.Combine(runStore.RunDirectory, "run.json"))); 234Assert.True(File.Exists(databasePath)); 238Assert.False(File.Exists(databasePath)); 297File.WriteAllText(Path.Combine(abandonedDirectory, "dashboard.db"), string.Empty); 334File.WriteAllText(Path.Combine(otherDirectory, "dashboard.db"), string.Empty); 433Assert.False(File.Exists(databasePath)); 458File.WriteAllBytes(databasePath, databaseContents); 459File.WriteAllBytes($"{databasePath}-wal", walContents); 460File.WriteAllBytes($"{databasePath}-shm", sharedMemoryContents); 464Assert.Equal(databaseContents, File.ReadAllBytes(databasePath)); 465Assert.True(File.Exists($"{databasePath}-wal")); 466Assert.True(File.Exists($"{databasePath}-shm")); 659Assert.False(File.Exists(prunedRun.DatabasePath)); 663Assert.All(selectableRuns, run => Assert.True(File.Exists(run.DatabasePath))); 692using var metadata = JsonDocument.Parse(File.ReadAllText(Path.Combine(pinnedRunDirectories[^1], "run.json"))); 867using var metadata = JsonDocument.Parse(File.ReadAllText(Path.Combine(Path.GetDirectoryName(historicalRun.DatabasePath)!, "run.json")));
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.Deployment.EndToEnd.Tests (145)
AcaCompactNamingDeploymentTests.cs (4)
106var content = File.ReadAllText(appHostFilePath); 133File.WriteAllText(appHostFilePath, content); 254var content = File.ReadAllText(appHostFilePath); 283File.WriteAllText(appHostFilePath, content);
AcaCompactNamingUpgradeDeploymentTests.cs (2)
222var content = File.ReadAllText(appHostFilePath); 243File.WriteAllText(appHostFilePath, content);
AcaCustomRegistryDeploymentTests.cs (2)
110var content = File.ReadAllText(appHostFilePath); 122File.WriteAllText(appHostFilePath, content);
AcaDeploymentErrorOutputTests.cs (4)
95var content = File.ReadAllText(appHostFilePath); 105File.WriteAllText(appHostFilePath, content); 135Assert.True(File.Exists(deployOutputFile), $"Deploy output file not found at {deployOutputFile}"); 137var deployOutput = File.ReadAllText(deployOutputFile);
AcaExistingRegistryDeploymentTests.cs (2)
138var content = File.ReadAllText(appHostFilePath); 152File.WriteAllText(appHostFilePath, content);
AcaManagedRedisDeploymentTests.cs (4)
118var appHostContent = File.ReadAllText(appHostFilePath); 135File.WriteAllText(appHostFilePath, appHostContent); 142var programContent = File.ReadAllText(programFilePath); 153File.WriteAllText(programFilePath, programContent);
AcaStarterDeploymentTests.cs (2)
107var content = File.ReadAllText(appHostFilePath); 119File.WriteAllText(appHostFilePath, content);
AcrPurgeTaskDeploymentTests.cs (4)
112var content = File.ReadAllText(appHostFilePath); 127File.WriteAllText(appHostFilePath, content); 164var content2 = File.ReadAllText(mainPyPath); 166File.WriteAllText(mainPyPath, content2);
AksAzureKubernetesEnvironmentCertManagerDeploymentTests.cs (2)
115var content = File.ReadAllText(appHostFilePath); 174File.WriteAllText(appHostFilePath, content);
AksAzureKubernetesEnvironmentCertManagerTypeScriptDeploymentTests.cs (2)
137var content = File.ReadAllText(appHostFilePath); 193File.WriteAllText(appHostFilePath, content);
AksAzureKubernetesEnvironmentGatewayDeploymentTests.cs (2)
114var content = File.ReadAllText(appHostFilePath); 172File.WriteAllText(appHostFilePath, content);
AksBlazorRedisDeploymentTests.cs (2)
104var content = File.ReadAllText(appHostFilePath); 119File.WriteAllText(appHostFilePath, content);
AksMultipleNodePoolsDeploymentTests.cs (2)
104var content = File.ReadAllText(appHostFilePath); 128File.WriteAllText(appHostFilePath, content);
AksPersistentVolumeDeploymentTests.cs (5)
211var content = File.ReadAllText(appHostPath); 245File.WriteAllText(appHostPath, content); 250var content = File.ReadAllText(appHostPath); 265File.WriteAllText(appHostPath, content); 270File.WriteAllText(
AksStarterDeploymentTests.cs (2)
185var content = File.ReadAllText(appHostFilePath); 204File.WriteAllText(appHostFilePath, content);
AksStarterWithRedisHelmDeploymentTests.cs (2)
185var content = File.ReadAllText(appHostFilePath); 204File.WriteAllText(appHostFilePath, content);
AksVnetInfraDeploymentTests.cs (2)
96var content = File.ReadAllText(appHostFilePath); 121File.WriteAllText(appHostFilePath, content);
AksVnetWithAzureResourcesDeploymentTests.cs (4)
129var content = File.ReadAllText(appHostFilePath); 170File.WriteAllText(appHostFilePath, content); 183var apiContent = File.ReadAllText(apiProgramPath); 213File.WriteAllText(apiProgramPath, apiContent);
AksWithAzureResourcesDeploymentTests.cs (4)
127var content = File.ReadAllText(appHostFilePath); 156File.WriteAllText(appHostFilePath, content); 169var apiContent = File.ReadAllText(apiProgramPath); 203File.WriteAllText(apiProgramPath, apiContent);
AksWithHelmChartDeploymentTests.cs (2)
108var content = File.ReadAllText(appHostFilePath); 133File.WriteAllText(appHostFilePath, content);
AppServicePythonDeploymentTests.cs (2)
116var content = File.ReadAllText(appHostFilePath); 128File.WriteAllText(appHostFilePath, content);
AppServiceReactDeploymentTests.cs (4)
129var content = File.ReadAllText(appHostFilePath); 142File.WriteAllText(appHostFilePath, content); 173content = File.ReadAllText(appHostFilePath); 183File.WriteAllText(appHostFilePath, upgradedContent);
AppServiceStoragePrivateEndpointDeploymentTests.cs (4)
104var appHostContent = File.ReadAllText(appHostFilePath); 142File.WriteAllText(appHostFilePath, appHostContent); 145var serverProgramContent = File.ReadAllText(serverProgramPath); 197File.WriteAllText(serverProgramPath, serverProgramContent);
AzureAppConfigDeploymentTests.cs (2)
105var content = File.ReadAllText(appHostFilePath); 119File.WriteAllText(appHostFilePath, content);
AzureContainerRegistryDeploymentTests.cs (2)
91var content = File.ReadAllText(appHostFilePath); 102File.WriteAllText(appHostFilePath, content);
AzureEventHubsDeploymentTests.cs (2)
105var content = File.ReadAllText(appHostFilePath); 119File.WriteAllText(appHostFilePath, content);
AzureKeyVaultDeploymentTests.cs (2)
105var content = File.ReadAllText(appHostFilePath); 119File.WriteAllText(appHostFilePath, content);
AzureLogAnalyticsDeploymentTests.cs (2)
91var content = File.ReadAllText(appHostFilePath); 102File.WriteAllText(appHostFilePath, content);
AzureResourceScopeDeploymentTests.cs (2)
90var content = File.ReadAllText(appHostFilePath); 115File.WriteAllText(appHostFilePath, content);
AzureRoleAssignmentRunModeTests.cs (3)
94var appHostContent = File.ReadAllText(appHostFilePath); 108File.WriteAllText(appHostFilePath, appHostContent); 113File.WriteAllText(validateScriptPath, """
AzureServiceBusDeploymentTests.cs (2)
106var content = File.ReadAllText(appHostFilePath); 120File.WriteAllText(appHostFilePath, content);
AzureStorageDeploymentTests.cs (4)
117var content = File.ReadAllText(appHostFilePath); 132File.WriteAllText(appHostFilePath, content); 264var content = File.ReadAllText(appHostFilePath); 295File.WriteAllText(appHostFilePath, content);
AzureStorageRunModeTests.cs (3)
83var appHostContent = File.ReadAllText(appHostFilePath); 94File.WriteAllText(appHostFilePath, appHostContent); 97File.WriteAllText(validateScriptPath, """
FoundryHostedAgentDeploymentTests.cs (5)
114File.WriteAllText(Path.Combine(hostedAgentDir, "DotNetHostedAgent.csproj"), """ 138File.WriteAllText(Path.Combine(hostedAgentDir, "Program.cs"), """ 210File.WriteAllText(Path.Combine(hostedAgentDir, ".dockerignore"), """ 232var appHostContent = File.ReadAllText(appHostFilePath); 252File.WriteAllText(appHostFilePath, appHostContent);
FrontDoorDeploymentTests.cs (2)
116var content = File.ReadAllText(appHostFilePath); 132File.WriteAllText(appHostFilePath, content);
Helpers\DeploymentE2ETestHelpers.cs (1)
205return candidates.Find(File.Exists);
Helpers\DeploymentReporter.cs (3)
66File.AppendAllText(summaryPath, sb.ToString()); 135File.AppendAllText(summaryPath, sb.ToString()); 178File.AppendAllText(summaryPath, sb.ToString());
KubernetesGatewayTlsDeploymentTests.cs (2)
267var content = File.ReadAllText(appHostFilePath); 317File.WriteAllText(appHostFilePath, content);
KubernetesHelmChartDeploymentTests.cs (2)
155var content = File.ReadAllText(appHostFilePath); 186File.WriteAllText(appHostFilePath, content);
NspStorageKeyVaultDeploymentTests.cs (4)
135var content = File.ReadAllText(appHostFilePath); 182File.WriteAllText(appHostFilePath, content); 196var content = File.ReadAllText(serverProgramPath); 244File.WriteAllText(serverProgramPath, content);
PythonFastApiDeploymentTests.cs (2)
118var content = File.ReadAllText(appHostFilePath); 130File.WriteAllText(appHostFilePath, content);
RadiusAzureResourcesDeploymentTests.cs (1)
77File.WriteAllText(appHostFilePath,
RadiusStarterDeploymentTests.cs (4)
331var content = File.ReadAllText(appHostFilePath); 362File.WriteAllText(appHostFilePath, content); 366var webProgram = File.ReadAllText(webProgramFilePath); 395File.WriteAllText(webProgramFilePath, webProgram);
tests\Shared\CliInstallStrategy.cs (1)
297if (!File.Exists(archivePath))
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
TypeScriptAzureContainerAppJobDeploymentTests.cs (1)
126File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"), """
TypeScriptExpressDeploymentTests.cs (2)
112var content = File.ReadAllText(appHostFilePath); 125File.WriteAllText(appHostFilePath, content);
TypeScriptJavaScriptHostingDeploymentTests.cs (5)
124File.WriteAllText(Path.Combine(apiDir.FullName, "package.json"), """ 134File.WriteAllText(Path.Combine(apiDir.FullName, "server.js"), """ 145File.WriteAllText(Path.Combine(staticSiteDir.FullName, "package.json"), """ 155File.WriteAllText(Path.Combine(staticSiteDir.FullName, "index.html"), """ 168File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.mts"), """
TypeScriptVnetSqlServerInfraDeploymentTests.cs (2)
181var content = File.ReadAllText(appHostFilePath); 206File.WriteAllText(appHostFilePath, content);
VnetKeyVaultConnectivityDeploymentTests.cs (4)
119var content = File.ReadAllText(appHostFilePath); 147File.WriteAllText(appHostFilePath, content); 160var content = File.ReadAllText(webProgramPath); 169File.WriteAllText(webProgramPath, content);
VnetKeyVaultInfraDeploymentTests.cs (2)
102var content = File.ReadAllText(appHostFilePath); 126File.WriteAllText(appHostFilePath, content);
VnetSqlServerConnectivityDeploymentTests.cs (4)
124var content = File.ReadAllText(appHostFilePath); 153File.WriteAllText(appHostFilePath, content); 166var content = File.ReadAllText(webProgramPath); 215File.WriteAllText(webProgramPath, content);
VnetSqlServerInfraDeploymentTests.cs (2)
102var content = File.ReadAllText(appHostFilePath); 127File.WriteAllText(appHostFilePath, content);
VnetStorageBlobConnectivityDeploymentTests.cs (4)
121var content = File.ReadAllText(appHostFilePath); 152File.WriteAllText(appHostFilePath, content); 165var content = File.ReadAllText(webProgramPath); 175File.WriteAllText(webProgramPath, content);
VnetStorageBlobInfraDeploymentTests.cs (2)
103var content = File.ReadAllText(appHostFilePath); 128File.WriteAllText(appHostFilePath, content);
Aspire.EndToEnd.Tests (18)
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
tests\Shared\TemplatesTesting\AspireProject.cs (9)
65File.WriteAllText(Path.Combine(dir, "Directory.Build.props"), "<Project />"); 66File.WriteAllText(Path.Combine(dir, "Directory.Build.targets"), "<Project />"); 73File.Copy(srcNuGetConfigPath, targetNuGetConfigPath); 107File.WriteAllText(Path.Combine(rootDir, "Directory.Build.props"), "<Project />"); 108File.WriteAllText(Path.Combine(rootDir, "Directory.Build.targets"), "<Project />"); 133var csprojContent = File.ReadAllText(csprojPath); 153File.Copy(Path.Combine(BuildEnvironment.TestAssetsPath, "EndPointWriterHook_cs"), Path.Combine(project.AppHostProjectDirectory, "EndPointWriterHook.cs")); 155string programCs = File.ReadAllText(programCsPath); 158File.WriteAllText(programCsPath, programCs);
tests\Shared\TemplatesTesting\BuildEnvironment.cs (2)
103.FirstOrDefault(File.Exists); 126.FirstOrDefault(File.Exists);
tests\Shared\TemplatesTesting\TemplateCustomHive.cs (4)
18public string CustomHiveDirectory => File.Exists(_stampFilePath) 37if (BuildEnvironment.IsRunningOnCI && File.Exists(_stampFilePath)) 51if (File.Exists(_stampFilePath)) 80File.WriteAllText(_stampFilePath, "");
Aspire.Hosting (104)
ApplicationModel\AspireStore.cs (4)
58using (var fileStream = File.OpenWrite(tempFileName)) 68if (!File.Exists(finalFilePath)) 70File.Copy(tempFileName, finalFilePath, overwrite: true); 75File.Delete(tempFileName);
ApplicationModel\AspireStoreExtensions.cs (2)
26if (!File.Exists(sourceFilename)) 31using var sourceStream = File.OpenRead(sourceFilename);
ApplicationModel\ContainerFileSystemCallbackAnnotation.cs (1)
207if (File.Exists(fullPath))
ApplicationModel\DockerfileBuildAnnotation.cs (7)
112await File.WriteAllTextAsync(DockerfilePath, dockerfileContent, cancellationToken).ConfigureAwait(false); 157File.Copy(DockerfilePath, dockerfilePath, overwrite: true); 173if (File.Exists(contextRootIgnore)) 175if (File.Exists(perDockerfileIgnore) && 180File.Delete(perDockerfileIgnore); 186await File.WriteAllTextAsync(perDockerfileIgnore, content, cancellationToken).ConfigureAwait(false); 200var existingContent = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
ApplicationModel\ProjectResource.cs (2)
199if (File.Exists(tempDockerfilePath)) 203File.Delete(tempDockerfilePath);
ApplicationModel\RequiredCommandValidator.cs (1)
200return File.Exists(candidate) ? candidate : null;
Backchannel\AuxiliaryBackchannelService.cs (4)
80if (File.Exists(SocketPath)) 83File.Delete(SocketPath); 129if (SocketPath != null && File.Exists(SocketPath)) 133File.Delete(SocketPath);
Backchannel\BackchannelService.cs (4)
51if (File.Exists(unixSocketPath)) 54File.Delete(unixSocketPath); 129if (_socketPath is not null && File.Exists(_socketPath)) 133File.Delete(_socketPath);
ContainerResourceBuilderExtensions.cs (1)
1501if (!Directory.Exists(sourceFullPath) && !File.Exists(sourceFullPath))
Dashboard\DashboardEventHandlers.cs (8)
137if (!File.Exists(runtimeConfigPath)) 144var configText = File.ReadAllText(runtimeConfigPath); 209if (!File.Exists(originalRuntimeConfig)) 229File.WriteAllText(customConfigPath, JsonSerializer.Serialize(defaultConfig, new JsonSerializerOptions { WriteIndented = true })); 236var originalConfigText = File.ReadAllText(originalRuntimeConfig); 271File.WriteAllText(tempPath, configJson.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 321if (!File.Exists(dashboardDll)) 1062File.Delete(_customRuntimeConfigPath);
Dcp\DcpDependencyCheck.cs (1)
47if (!File.Exists(dcpPath))
Dcp\DcpHost.cs (1)
298if (!File.Exists(dcpExePath))
Dcp\ExecutableConfigurationResolver.cs (5)
107File.WriteAllBytes(Path.Join(customBundleOutputPath, bundleFactory.Key), bundleBytes); 123File.WriteAllText(Path.Join(baseServerAuthOutputPath, $"{thumbprint}.crt"), publicCertificatePem); 128File.WriteAllBytes(Path.Join(baseServerAuthOutputPath, $"{thumbprint}.key"), keyBytes); 131File.WriteAllText( 142File.WriteAllBytes(Path.Join(baseServerAuthOutputPath, $"{thumbprint}.pfx"), pfxBytes);
Dcp\KubernetesService.cs (1)
607using var activity = ProfilingTelemetry.StartDcpEnsureKubernetesClient(configuration, File.Exists(locations.DcpKubeconfigPath));
Devcontainers\DevcontainerSettingsWriter.cs (4)
119var settingsContent = await File.ReadAllTextAsync(settingsPath, cancellationToken).ConfigureAwait(false); 185await File.WriteAllTextAsync(settingsPath, settingsContent, cancellationToken).ConfigureAwait(false); 247if (!File.Exists(path)) 255using var stream = File.Open(path, FileMode.CreateNew);
DeveloperCertificateService.cs (8)
232return File.Exists(certificateFileName) && File.Exists(keyFileName) 281if (!File.Exists(certFileName)) 307if (!File.Exists(path)) 312var bytes = File.ReadAllBytes(path); 396File.WriteAllText(certFileName, certificate.ExportCertificatePem()); 400File.WriteAllBytes(pfxFileName, pfxBytes); 405File.WriteAllBytes(keyFileName, keyBytes);
DistributedApplicationBuilder.cs (1)
1011if (!File.Exists(deploymentStatePath))
DistributedApplicationOptions.cs (3)
184if (File.Exists(csprojPath)) 191else if (File.Exists(fullPath) && fullPath.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase)) 205if (File.Exists(csprojPath))
Lifecycle\TerminalHostEventingSubscriber.cs (1)
79if (!File.Exists(terminalHostPath))
Lifecycle\TerminalHostOrphanCleanupService.cs (10)
171File.Delete(socketPath); 191File.Delete(metadataPath); 397lastWriteTimeUtc = File.GetLastWriteTimeUtc(metadataPath); 420File.Delete(metadataPath); 452lastWriteTimeUtc = File.GetLastWriteTimeUtc(temporaryPath); 467File.Delete(temporaryPath); 481=> File.Exists(TerminalHostPaths.GetSocketPath(trmnlDirectory, replicaId, TerminalHostPaths.ProducerSockPurpose)) 482|| File.Exists(TerminalHostPaths.GetSocketPath(trmnlDirectory, replicaId, TerminalHostPaths.ConsumerSockPurpose)) 483|| File.Exists(TerminalHostPaths.GetSocketPath(trmnlDirectory, replicaId, TerminalHostPaths.ControlSockPurpose)); 489var value = File.ReadAllText(path).Trim();
Pipelines\DistributedApplicationPipeline.cs (1)
77if (deploymentStateManager.StateFilePath is string stateFilePath && File.Exists(stateFilePath))
Pipelines\Internal\DeploymentStateManagerBase.cs (4)
80if (statePath is not null && File.Exists(statePath)) 82var fileContent = await File.ReadAllTextAsync(statePath, cancellationToken).ConfigureAwait(false); 306if (StateFilePath is string stateFilePath && File.Exists(stateFilePath)) 308File.Delete(stateFilePath);
Pipelines\Internal\FileDeploymentStateManager.cs (1)
109await File.WriteAllTextAsync(
Publishing\ContainerRuntimeBase.cs (1)
587if (context.EnvFilePath is not null && File.Exists(context.EnvFilePath))
src\Shared\BackchannelConstants.cs (1)
470File.Delete(socketPath);
src\Shared\BundleDiscovery.cs (3)
138if (File.Exists(dcpExePath)) 169if (File.Exists(managedExe)) 282return File.Exists(managedPath) ? managedPath : null;
src\Shared\DirectoryHelper.cs (1)
29File.SetUnixFileMode(path, OwnerOnlyMode);
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (3)
76if (!File.Exists(projectMetadata.ProjectPath)) 90if (!File.Exists(launchSettingsFilePath)) 100if (File.Exists(runSettingsFilePath))
src\Shared\LaunchProfiles\LaunchSettingsReader.cs (2)
24if (!File.Exists(launchSettingsFilePath)) 63using var stream = File.OpenRead(launchSettingsFilePath);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
src\Shared\ProcessStartTimeHelper.cs (1)
345contents = File.ReadAllText(statPath);
TerminalResourceBuilderExtensions.cs (3)
336File.SetUnixFileMode(temporaryMetadataPath, UnixFileMode.UserRead | UnixFileMode.UserWrite); 350File.Move(temporaryMetadataPath, metadataPath, overwrite: true); 362File.Delete(temporaryMetadataPath);
UserSecrets\UserSecretsManagerFactory.cs (4)
168await File.WriteAllTextAsync(FilePath, json, Encoding.UTF8, cancellationToken).ConfigureAwait(false); 220File.WriteAllText(tempFilename, json, Encoding.UTF8); 221File.Move(tempFilename, FilePath, overwrite: true); 225File.WriteAllText(FilePath, json, Encoding.UTF8);
Utils\DockerfileHelper.cs (1)
45var dockerfileContent = await File.ReadAllTextAsync(annotation.DockerfilePath, cancellationToken).ConfigureAwait(false);
Utils\FileSystemService.cs (3)
162File.Create(filePath).Dispose(); 262if (File.Exists(_path)) 264File.Delete(_path);
Aspire.Hosting.Azure (12)
AzureBicepResource.cs (4)
175File.WriteAllText(path, TemplateString); 187using var fs = File.OpenWrite(path); 224return File.ReadAllText(TemplateFile); 514File.Delete(Path);
AzureProvisioningResource.cs (3)
94File.WriteAllText(moduleSourcePath, compiledBicep.Value); 97File.Copy(moduleSourcePath, moduleDestinationPath, true); 110_generatedBicep = File.ReadAllText(template.Path);
AzurePublishingContext.cs (3)
160File.Copy(file.Path, modulePath, true); 406File.Copy(file.Path, modulePath, true); 529await File.WriteAllTextAsync(bicepPath, compiledBicep.Value).ConfigureAwait(false);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
Aspire.Hosting.Azure.Functions (5)
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (3)
76if (!File.Exists(projectMetadata.ProjectPath)) 90if (!File.Exists(launchSettingsFilePath)) 100if (File.Exists(runSettingsFilePath))
src\Shared\LaunchProfiles\LaunchSettingsReader.cs (2)
24if (!File.Exists(launchSettingsFilePath)) 63using var stream = File.OpenRead(launchSettingsFilePath);
Aspire.Hosting.Azure.Kubernetes (4)
AzureKubernetesEnvironmentResource.AksPipeline.cs (2)
279await File.WriteAllTextAsync(kubeConfigPath, kubeConfigContent, context.CancellationToken).ConfigureAwait(false); 284File.SetUnixFileMode(kubeConfigPath, UnixFileMode.UserRead | UnixFileMode.UserWrite);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
Aspire.Hosting.Azure.Kubernetes.Tests (6)
AzureKubernetesFoundryReferenceTests.cs (1)
60var values = await File.ReadAllTextAsync(valuesPath);
AzureKubernetesInfrastructureTests.cs (1)
469await File.ReadAllTextAsync(aks.Resource.KubernetesEnvironment.KubeConfigPath!, TestContext.Current.CancellationToken));
AzureKubernetesIngressTests.cs (2)
34Assert.True(File.Exists(ingressPath), $"Expected ingress YAML at {ingressPath}"); 36var content = await File.ReadAllTextAsync(ingressPath);
AzureKubernetesPersistentVolumeTests.cs (2)
37Assert.True(File.Exists(claimPath), $"Expected persistent volume claim YAML at {claimPath}."); 39var content = await File.ReadAllTextAsync(claimPath);
Aspire.Hosting.Azure.Tests (82)
AzureAppServiceTests.cs (7)
437File.WriteAllText(Path.Combine(directory.FullName, "Dockerfile"), ""); 561Assert.True(File.Exists(mainBicepPath), $"Expected publish to produce '{mainBicepPath}'."); 562var mainBicep = await File.ReadAllTextAsync(mainBicepPath); 565Assert.True(File.Exists(envBicepPath), $"Expected publish to produce '{envBicepPath}'."); 566var envBicep = await File.ReadAllTextAsync(envBicepPath); 569Assert.True(File.Exists(apiBicepPath), $"Expected publish to produce '{apiBicepPath}'."); 570var apiBicep = await File.ReadAllTextAsync(apiBicepPath);
AzureBicepResourceTests.cs (5)
261File.WriteAllText(bicepFilePath, "param location string = resourceGroup().location"); 275Assert.True(File.Exists(templateFile.Path), $"The template file should exist at {templateFile.Path}"); 286File.WriteAllText(bicepFilePath, "param location string = resourceGroup().location"); 317Assert.True(File.Exists(templateFile.Path), $"The template file should exist at {templateFile.Path}"); 318Assert.Equal(bicepContent, File.ReadAllText(templateFile.Path));
AzureContainerAppEnvironmentExtensionsTests.cs (4)
566Assert.True(File.Exists(mainBicepPath), $"Expected publish to produce '{mainBicepPath}'."); 567var mainBicep = await File.ReadAllTextAsync(mainBicepPath); 570Assert.True(File.Exists(envBicepPath), $"Expected publish to produce '{envBicepPath}'."); 571var envBicep = await File.ReadAllTextAsync(envBicepPath);
AzureContainerAppsTests.cs (2)
68File.WriteAllText(Path.Combine(directory.FullName, "Dockerfile"), ""); 2684File.WriteAllText(Path.Combine(workspace.Path, "Dockerfile"), "FROM alpine");
AzureDeployerTests.cs (26)
1657if (File.Exists(deploymentStatePath)) 1659File.Delete(deploymentStatePath); 1665Assert.True(File.Exists(deploymentStatePath)); 1666var stateContent = await File.ReadAllTextAsync(deploymentStatePath); 1671if (File.Exists(deploymentStatePath)) 1673File.Delete(deploymentStatePath); 1695await File.WriteAllTextAsync(deploymentStatePath, cachedState.ToJsonString()); 1717Assert.True(File.Exists(deploymentStatePath)); 1719if (File.Exists(deploymentStatePath)) 1721File.Delete(deploymentStatePath); 1746if (File.Exists(deploymentStatePath)) 1748File.Delete(deploymentStatePath); 1754Assert.False(File.Exists(deploymentStatePath)); 1779if (File.Exists(stagingStatePath)) 1781File.Delete(stagingStatePath); 1787Assert.True(File.Exists(stagingStatePath)); 1788var stateContent = await File.ReadAllTextAsync(stagingStatePath); 1792if (File.Exists(stagingStatePath)) 1794File.Delete(stagingStatePath); 1840Assert.False(File.Exists(deploymentStatePath)); 1870Assert.True(File.Exists(deploymentStatePath)); 1871firstDeploymentState = await File.ReadAllTextAsync(deploymentStatePath); 1925Assert.True(File.Exists(deploymentStatePath)); 1926secondDeploymentState = await File.ReadAllTextAsync(deploymentStatePath); 1937if (deploymentStatePath is not null && File.Exists(deploymentStatePath)) 1939File.Delete(deploymentStatePath);
AzureEnvironmentResourceTests.cs (22)
35Assert.True(File.Exists(mainBicepPath)); 36var mainBicep = File.ReadAllText(mainBicepPath); 39Assert.True(File.Exists(envBicepPath)); 40var envBicep = File.ReadAllText(envBicepPath); 72Assert.True(File.Exists(mainBicepPath)); 73var mainBicep = File.ReadAllText(mainBicepPath); 123Assert.True(File.Exists(mainBicepPath)); 124var content = File.ReadAllText(mainBicepPath); 170var mainBicep = File.ReadAllText(Path.Combine(workspace.FullName, "main.bicep")); 171var storageBicep = File.ReadAllText(Path.Combine(workspace.FullName, "storage", "storage.bicep")); 218var mainBicep = File.ReadAllText(Path.Combine(workspace.Path, "main.bicep")); 251Assert.True(File.Exists(mainBicepPath)); 252var mainBicep = File.ReadAllText(mainBicepPath); 256Assert.True(File.Exists(includedStorageBicepPath), "Included storage should have a bicep file generated"); 260Assert.False(File.Exists(excludedStorageBicepPath), "Excluded storage should not have a bicep file generated"); 282Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 283var actualContent = await File.ReadAllTextAsync(dockerfilePath); 321await File.WriteAllTextAsync(bicepFilePath, bicepContent); 342Assert.True(File.Exists(mainBicepPath), "main.bicep should be generated"); 345Assert.True(File.Exists(resourceBicepPath), "custom-resource/custom-resource.bicep should be generated"); 348var copiedContent = await File.ReadAllTextAsync(resourceBicepPath); 352var mainBicepContent = await File.ReadAllTextAsync(mainBicepPath);
AzureEventHubsExtensionsTests.cs (2)
478File.WriteAllText(configJsonPath, source); 499File.Delete(configJsonPath);
AzureFunctionsTests.cs (7)
651File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 676File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 698File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 729File.WriteAllText(projectPath1, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 730File.WriteAllText(projectPath2, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 751File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 783File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>");
AzureManifestUtils.cs (2)
39if (pathNode?.ToString() is not { } path || !File.Exists(Path.Combine(manifestDir, path))) 44var bicepText = await File.ReadAllTextAsync(Path.Combine(manifestDir, path));
AzureResourceOptionsTests.cs (2)
45var sbBicep = await File.ReadAllTextAsync(Path.Combine(tempDir.FullName, "sb.module.bicep")); 47var sqlBicep = await File.ReadAllTextAsync(Path.Combine(tempDir.FullName, "sql-server.module.bicep"));
AzureServiceBusExtensionsTests.cs (3)
560File.WriteAllText(configJsonPath, """ 596File.Delete(configJsonPath); 817File.WriteAllText(configJsonPath,
Aspire.Hosting.Blazor (8)
BlazorGatewayExtensions.cs (4)
507if (!File.Exists(srcEndpoints)) 516await File.WriteAllTextAsync(destEndpoints, modifiedEndpoints, context.CancellationToken).ConfigureAwait(false); 545File.Copy(scriptSource, scriptDest, overwrite: true); 584if (!File.Exists(scriptPath))
Manifests\EndpointsManifestTransformer.cs (4)
23await File.ReadAllTextAsync(manifestPath, ct).ConfigureAwait(false), 88if (!File.Exists(runtimePath)) 95await File.ReadAllTextAsync(runtimePath, ct).ConfigureAwait(false), 123await File.WriteAllTextAsync(
Aspire.Hosting.Blazor.Tests (17)
AddDotnetProjectBlazorGatewayTests.cs (1)
24Assert.True(File.Exists(projectMetadata.ProjectPath));
BlazorHostedExtensionsTests.cs (4)
266File.WriteAllText(serverProjectPath, """<Project Sdk="Microsoft.NET.Sdk.Web" />"""); 572File.WriteAllText(serverProjectPath, """ 587File.WriteAllText(clientProjectPath, """ 604File.WriteAllText(serverProjectPath, """
EndpointsManifestTransformerTests.cs (11)
39await File.WriteAllTextAsync(manifestPath, JsonSerializer.Serialize(manifest, ManifestJsonContext.Default.EndpointsManifest)); 64await File.WriteAllTextAsync(manifestPath, JsonSerializer.Serialize(manifest, ManifestJsonContext.Default.EndpointsManifest)); 95await File.WriteAllTextAsync(manifestPath, JsonSerializer.Serialize(manifest, ManifestJsonContext.Default.EndpointsManifest)); 119await File.WriteAllTextAsync(manifestPath, JsonSerializer.Serialize(manifest, ManifestJsonContext.Default.EndpointsManifest)); 177await File.WriteAllTextAsync(app1Path, JsonSerializer.Serialize(app1Manifest, ManifestJsonContext.Default.DevelopmentManifest)); 178await File.WriteAllTextAsync(app2Path, JsonSerializer.Serialize(app2Manifest, ManifestJsonContext.Default.DevelopmentManifest)); 194Assert.True(File.Exists(outputPath)); 197await File.ReadAllTextAsync(outputPath), 241await File.WriteAllTextAsync(app1Path, JsonSerializer.Serialize(app1Manifest, ManifestJsonContext.Default.DevelopmentManifest)); 242await File.WriteAllTextAsync(app2Path, JsonSerializer.Serialize(app2Manifest, ManifestJsonContext.Default.DevelopmentManifest)); 259await File.ReadAllTextAsync(outputPath),
tests\Shared\TestFileSystemService.cs (1)
37File.Create(filePath).Dispose();
Aspire.Hosting.Browsers (17)
BrowserEndpointDiscovery.cs (5)
59if (!File.Exists(metadataPath)) 77using var stream = File.OpenRead(metadataPath); 183using (var stream = File.Create(tempPath)) 188File.Move(tempPath, metadataPath, overwrite: true); 281File.Delete(path);
BrowserHost.cs (2)
230if (!File.Exists(devToolsActivePortFilePath)) 237File.Delete(devToolsActivePortFilePath);
BrowserHostRegistry.cs (1)
340if (File.Exists(localStatePath))
BrowserLogsArtifacts.cs (1)
80catch (IOException) when (attempt < 99 && File.Exists(filePath))
ChromiumBrowserResolver.cs (6)
24if (Path.IsPathRooted(browser) && File.Exists(browser)) 35if (File.Exists(candidate)) 81if (File.Exists(localStatePath)) 85using var localStateStream = File.OpenRead(localStatePath); 167if (File.Exists(localStatePath)) 181using var localStateStream = File.OpenRead(localStatePath);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
Aspire.Hosting.Browsers.Tests (36)
BrowserHostTests.cs (4)
24await File.WriteAllTextAsync(browserExecutable, string.Empty); 26await File.WriteAllTextAsync(devToolsActivePortPath, "12345\n/devtools/browser/stale"); 57Assert.False(File.Exists(devToolsActivePortPath)); 58Assert.False(File.Exists(BrowserEndpointDiscovery.GetEndpointMetadataFilePath(userDataDirectory.FullName)));
BrowserLogsBuilderExtensionsTests.cs (2)
897Assert.Equal(session.ScreenshotBytes, await File.ReadAllBytesAsync(path)); 1022await File.WriteAllTextAsync(tempBrowserPath, string.Empty);
BrowserLogsRunningSessionTests.cs (1)
24File.WriteAllText(browserExecutable, string.Empty);
BrowserLogsSessionManagerTests.cs (12)
65File.WriteAllText(browserExecutable, string.Empty); 105File.WriteAllText(browserExecutable, string.Empty); 140File.WriteAllText(browserExecutable, string.Empty); 174File.WriteAllText(browserExecutable, string.Empty); 274Assert.False(File.Exists(metadataPath)); 300var metadata = await File.ReadAllTextAsync(metadataPath); 323await File.WriteAllTextAsync( 337Assert.False(File.Exists(metadataPath)); 397File.WriteAllText( 429File.WriteAllText( 482File.WriteAllText(Path.Combine(userDataDirectory, "Local State"), "{"); 510File.WriteAllText(
src\Aspire.Hosting.Browsers\BrowserEndpointDiscovery.cs (5)
59if (!File.Exists(metadataPath)) 77using var stream = File.OpenRead(metadataPath); 183using (var stream = File.Create(tempPath)) 188File.Move(tempPath, metadataPath, overwrite: true); 281File.Delete(path);
src\Aspire.Hosting.Browsers\BrowserHost.cs (2)
230if (!File.Exists(devToolsActivePortFilePath)) 237File.Delete(devToolsActivePortFilePath);
src\Aspire.Hosting.Browsers\BrowserHostRegistry.cs (1)
340if (File.Exists(localStatePath))
src\Aspire.Hosting.Browsers\BrowserLogsArtifacts.cs (1)
80catch (IOException) when (attempt < 99 && File.Exists(filePath))
src\Aspire.Hosting.Browsers\ChromiumBrowserResolver.cs (6)
24if (Path.IsPathRooted(browser) && File.Exists(browser)) 35if (File.Exists(candidate)) 81if (File.Exists(localStatePath)) 85using var localStateStream = File.OpenRead(localStatePath); 167if (File.Exists(localStatePath)) 181using var localStateStream = File.OpenRead(localStatePath);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
Aspire.Hosting.CodeGeneration.Go (2)
GoLanguageSupport.cs (2)
113if (!File.Exists(appHostPath)) 119if (!File.Exists(goModPath))
Aspire.Hosting.CodeGeneration.Java (1)
JavaLanguageSupport.cs (1)
126if (File.Exists(Path.Combine(directoryPath, relativePath)))
Aspire.Hosting.CodeGeneration.Java.Tests (5)
JavaLanguageSupportDetectionTests.cs (5)
28File.WriteAllText(appHostPath, "void main(String[] args) { }"); 46File.WriteAllText(Path.Combine(workspace.Path, "AppHost.java"), "void main(String[] args) { }"); 48File.WriteAllText(Path.Combine(nested.FullName, "AppHost.java"), "void main(String[] args) { }"); 57File.WriteAllText(Path.Combine(workspace.Path, "pom.xml"), "<project />"); 77File.WriteAllText(path, "class Application { }");
Aspire.Hosting.CodeGeneration.Python (3)
PythonLanguageSupport.cs (3)
143if (!File.Exists(appHostPath)) 148var hasPylock = File.Exists(Path.Combine(directoryPath, "pylock.apphost.toml")); 149var hasRequirements = File.Exists(Path.Combine(directoryPath, "apphost_requirements.txt"));
Aspire.Hosting.CodeGeneration.Rust (2)
RustLanguageSupport.cs (2)
117if (!File.Exists(appHostPath)) 123if (!File.Exists(cargoPath))
Aspire.Hosting.CodeGeneration.Rust.Tests (6)
RustLanguageSupportTests.cs (5)
42File.WriteAllText(Path.Combine(workspace.Path, "apphost.rs"), "// marker"); 43File.WriteAllText(Path.Combine(workspace.Path, "Cargo.toml"), "[package]"); 57File.WriteAllText(Path.Combine(workspace.Path, "apphost.ts"), "// typescript"); 58File.WriteAllText(Path.Combine(workspace.Path, "Cargo.toml"), "[package]"); 70File.WriteAllText(Path.Combine(workspace.Path, "apphost.rs"), "// marker");
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.Hosting.CodeGeneration.TypeScript (5)
TypeScriptLanguageSupport.cs (5)
180File.Exists(Path.Combine(parent.FullName, PackageJsonFileName)); 186return File.Exists(packageJsonPath); 226var appHostFileName = File.Exists(Path.Combine(directoryPath, AppHostFileName)) 230if (!File.Exists(appHostPath)) 237if (!File.Exists(packageJsonPath))
Aspire.Hosting.CodeGeneration.TypeScript.Tests (6)
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
TypeScriptLanguageSupportTests.cs (5)
71File.WriteAllText(Path.Combine(workspace.Path, "package.json"), """ 136File.WriteAllText(Path.Combine(workspace.Path, "package.json"), """{ "name": "existing-app" }"""); 158File.WriteAllText(Path.Combine(workspace.Path, "package.json"), """ 204File.WriteAllText(existingTsConfigPath, existingTsConfig); 214Assert.Equal(existingTsConfig, File.ReadAllText(existingTsConfigPath));
Aspire.Hosting.Containers.Tests (6)
DockerSocketBindMountTests.cs (3)
25await File.WriteAllTextAsync(dockerFilePath, dockerfile); 49Assert.True(File.Exists(infoFile)); 51var infoContent = await File.ReadAllTextAsync(infoFile);
WithDockerfileTests.cs (3)
931Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 932var actualContent = await File.ReadAllTextAsync(dockerfilePath); 935var manifestContent = await File.ReadAllTextAsync(manifestPath);
Aspire.Hosting.Docker (11)
DockerComposeEnvironmentResource.cs (2)
406if (!File.Exists(dockerComposeFilePath)) 450if (!File.Exists(dockerComposeFilePath))
DockerComposePublishingContext.cs (2)
149await File.WriteAllTextAsync(outputFile, composeOutput, cancellationToken).ConfigureAwait(false); 198File.Copy(file.SourcePath, sourcePath);
EnvFile.cs (5)
30if (!File.Exists(path)) 37foreach (var line in File.ReadAllLines(path)) 95if (File.Exists(_path)) 112File.WriteAllLines(_path, lines); 157File.WriteAllLines(_path, lines);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
Aspire.Hosting.Docker.Tests (104)
DockerComposePublisherTests.cs (82)
102Assert.True(File.Exists(composePath)); 103Assert.True(File.Exists(envPath)); 105await Verify(File.ReadAllText(composePath), "yaml") 106.AppendContentAsFile(File.ReadAllText(envPath), "env"); 139Assert.True(File.Exists(composePath)); 140Assert.True(File.Exists(envPath)); 142await Verify(File.ReadAllText(composePath), "yaml") 143.AppendContentAsFile(File.ReadAllText(envPath), "env"); 166Assert.True(File.Exists(composePath)); 168await Verify(File.ReadAllText(composePath), "yaml"); 195Assert.True(File.Exists(composePath)); 246Assert.True(File.Exists(composePath)); 248Assert.True(File.Exists(envPath)); 250await Verify(File.ReadAllText(composePath), "yaml") 251.AppendContentAsFile(File.ReadAllText(envPath), "env"); 273Assert.True(File.Exists(envFilePath)); 274var firstContent = File.ReadAllText(envFilePath).Replace("PARAM1=", "PARAM1=changed"); 275File.WriteAllText(envFilePath, firstContent); 278Assert.True(File.Exists(envFilePath)); 279var secondContent = File.ReadAllText(envFilePath); 314Assert.True(File.Exists(envFilePath)); 315var firstContent = File.ReadAllText(envFilePath).Replace("PARAM1=", "PARAM1=changed"); 316File.WriteAllText(envFilePath, firstContent); 319Assert.True(File.Exists(envFilePath)); 320var secondContent = File.ReadAllText(envFilePath); 345Assert.True(File.Exists(composePath)); 347var composeFile = File.ReadAllText(composePath); 371Assert.True(File.Exists(composePath)); 373var composeContent = File.ReadAllText(composePath); 403Assert.True(File.Exists(composePath)); 405var composeContent = File.ReadAllText(composePath); 434Assert.True(File.Exists(composePath)); 436var composeContent = File.ReadAllText(composePath); 462Assert.True(File.Exists(composePath)); 464var composeContent = File.ReadAllText(composePath); 488Assert.True(File.Exists(composePath)); 490var composeContent = File.ReadAllText(composePath); 516Assert.True(File.Exists(composePath)); 518var composeContent = File.ReadAllText(composePath); 548Assert.True(File.Exists(composePath)); 550var composeContent = File.ReadAllText(composePath); 573Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 574var actualContent = await File.ReadAllTextAsync(dockerfilePath); 597Assert.False(File.Exists(composePath)); 623var envFileContent = await File.ReadAllTextAsync(Path.Combine(workspace.Path, ".env.Production")); 653Assert.True(File.Exists(envFilePath), $"Expected env file at {envFilePath}"); 655var envFileContent = await File.ReadAllTextAsync(envFilePath); 686var envFileContent = await File.ReadAllTextAsync(Path.Combine(workspace.Path, ".env.Production")); 709File.WriteAllText(envFilePath, "# Old content\nOLD_KEY=old_value\n"); 715var envFileContent = File.ReadAllText(envFilePath); 743File.WriteAllText(envFilePath, "# Old staging content\nOLD_STAGING_KEY=old_staging_value\n"); 749var envFileContent = File.ReadAllText(envFilePath); 775var composeContent = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "docker-compose.yaml")); 776var envFileContent = await File.ReadAllTextAsync(Path.Combine(workspace.Path, ".env.Production")); 808var envFileContent = await File.ReadAllTextAsync(Path.Combine(workspace.Path, ".env.Production")); 834var envFileContent = await File.ReadAllTextAsync(Path.Combine(workspace.Path, ".env.Production")); 861Assert.True(File.Exists(composePath)); 862Assert.True(File.Exists(envPath)); 864await Verify(File.ReadAllText(composePath), "yaml") 865.AppendContentAsFile(File.ReadAllText(envPath), "env"); 887Assert.True(File.Exists(composePath)); 889var composeContent = File.ReadAllText(composePath); 919Assert.True(File.Exists(composePath)); 920Assert.True(File.Exists(envPath)); 922await Verify(File.ReadAllText(composePath), "yaml") 923.AppendContentAsFile(File.ReadAllText(envPath), "env"); 958Assert.True(File.Exists(composePath)); 959Assert.True(File.Exists(envPath)); 961await Verify(File.ReadAllText(composePath), "yaml") 962.AppendContentAsFile(File.ReadAllText(envPath), "env"); 1006Assert.True(File.Exists(composePath)); 1007Assert.True(File.Exists(envPath)); 1009await Verify(File.ReadAllText(composePath), "yaml") 1010.AppendContentAsFile(File.ReadAllText(envPath), "env"); 1040Assert.True(File.Exists(composePath)); 1041Assert.True(File.Exists(envPath)); 1043await Verify(File.ReadAllText(composePath), "yaml") 1044.AppendContentAsFile(File.ReadAllText(envPath), "env"); 1083Assert.True(File.Exists(composePath)); 1085await Verify(File.ReadAllText(composePath), "yaml"); 1117Assert.True(File.Exists(composePath)); 1119await Verify(File.ReadAllText(composePath), "yaml");
DockerComposeTests.cs (10)
64Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 86Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 88var composeContent = File.ReadAllText(composeFile); 188Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 189var composeContent = File.ReadAllText(composeFile); 222Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 223var composeContent = File.ReadAllText(composeFile); 261Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 262var composeContent = File.ReadAllText(composeFile); 348Assert.True(File.Exists(composePath));
EnvFileTests.cs (12)
15File.WriteAllLines(envFilePath, [ 26var lines = File.ReadAllLines(envFilePath); 41File.WriteAllLines(envFilePath, [ 52var lines = File.ReadAllLines(envFilePath); 67File.WriteAllLines(envFilePath, [ 87var lines = File.ReadAllLines(envFilePath); 107File.WriteAllLines(envFilePath, [ 118var lines = File.ReadAllLines(envFilePath); 132File.WriteAllText(envFilePath, string.Empty); 138var lines = File.ReadAllLines(envFilePath); 153Assert.True(File.Exists(envFilePath)); 154var lines = File.ReadAllLines(envFilePath);
Aspire.Hosting.Dotnet (9)
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (3)
76if (!File.Exists(projectMetadata.ProjectPath)) 90if (!File.Exists(launchSettingsFilePath)) 100if (File.Exists(runSettingsFilePath))
src\Shared\LaunchProfiles\LaunchSettingsReader.cs (2)
24if (!File.Exists(launchSettingsFilePath)) 63using var stream = File.OpenRead(launchSettingsFilePath);
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
Aspire.Hosting.Dotnet.Tests (12)
DotnetProjectResourceTests.cs (12)
165Assert.False(File.Exists(Path.Combine(workspace.Path, "aspire-manifest.json"))); 398await File.WriteAllTextAsync(Path.Combine(workspace.Path, "Dockerfile"), "FROM scratch"); 434File.WriteAllText(projectPath, "<Project />"); 451File.WriteAllText(Path.Combine(projectDir.FullName, "First.csproj"), "<Project />"); 452File.WriteAllText(Path.Combine(projectDir.FullName, "Second.csproj"), "<Project />"); 478await File.WriteAllTextAsync(projectPath, "<Project />"); 481await File.WriteAllTextAsync(Path.Combine(propertiesDir.FullName, "launchSettings.json"), """ 565await File.WriteAllTextAsync(projectPath, "<Project />"); 568await File.WriteAllTextAsync(Path.Combine(propertiesDir.FullName, "launchSettings.json"), """ 635await File.WriteAllTextAsync(projectPath, "<Project />"); 638await File.WriteAllTextAsync(Path.Combine(propertiesDir.FullName, "launchSettings.json"), """ 939File.WriteAllText(path, string.Empty);
Aspire.Hosting.Garnet.Tests (1)
GarnetFunctionalTests.cs (1)
141File.SetUnixFileMode(bindMountPath, BindMountPermissions);
Aspire.Hosting.Go (5)
GoHostingExtensions.cs (3)
167if (File.Exists(Path.Combine(appDirectory, "Dockerfile"))) 186var hasGoMod = File.Exists(Path.Combine(appDirectory, "go.mod")); 187var hasGoSum = File.Exists(Path.Combine(appDirectory, "go.sum"));
GoVersionDetector.cs (2)
15if (!File.Exists(goModPath)) 23foreach (var line in File.ReadLines(goModPath))
Aspire.Hosting.Go.Tests (33)
AddGoAppTests.cs (28)
88File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 95var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 779File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.23\n"); 780File.WriteAllText(Path.Combine(sourceDir.FullName, "main.go"), "package main\nfunc main() {}"); 788Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated in publish mode"); 790var content = await File.ReadAllTextAsync(dockerfilePath); 807var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 819File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.22\n"); 829var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 841File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 851var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 864File.WriteAllText(Path.Combine(sourceDir.FullName, "Dockerfile"), "FROM scratch"); 880File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.22\n"); 888var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 902File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 910var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 922File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 930var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 978File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 995var dockerfile = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 1012File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 1035var dockerfile = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 1080File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 1087var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 1154File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 1161var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile")); 1173File.WriteAllText(Path.Combine(sourceDir.FullName, "go.mod"), "module example.com/api\n\ngo 1.24\n"); 1181var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"));
GoVersionDetectorTests.cs (5)
22File.WriteAllText(Path.Combine(workspace.Path, "go.mod"), "module example.com/m\n\ngo 1.23\n"); 33File.WriteAllText(Path.Combine(workspace.Path, "go.mod"), "module example.com/m\n\ngo 1.23.4\n"); 44File.WriteAllText(Path.Combine(workspace.Path, "go.mod"), 57File.WriteAllText(Path.Combine(workspace.Path, "go.mod"), 69File.WriteAllText(Path.Combine(workspace.Path, "go.mod"), "module example.com/m\n");
Aspire.Hosting.Java (28)
JavaBuildToolResolver.cs (7)
31var hasMaven = File.Exists(Path.Combine(appDirectory, "pom.xml")); 32var hasGradle = s_gradleBuildFileNames.Any(fileName => File.Exists(Path.Combine(appDirectory, fileName))); 89if (File.Exists(candidate) 100if (Directory.Exists(gitPath) || File.Exists(gitPath)) 116JavaBuildTool.Gradle => File.Exists(Path.Combine(directory, "settings.gradle")) 117|| File.Exists(Path.Combine(directory, "settings.gradle.kts")), 120JavaBuildTool.Maven => File.Exists(Path.Combine(directory, "pom.xml")),
JavaDockerfileGenerator.cs (8)
123&& !File.Exists(Path.Combine(appDirectory, ".dockerignore"))) 782if (!File.Exists(path)) 787content = File.ReadAllText(path); 850foreach (var line in File.ReadLines(propertiesPath)) 955foreach (var line in File.ReadLines(propertiesPath)) 1004if (!File.Exists(propertiesPath)) 1049if (!File.Exists(resolvedWrapperPath)) 1076if (!File.Exists(Path.Combine(appDirectory, posixSibling.Replace('/', Path.DirectorySeparatorChar))))
JavaHostingExtensions.cs (6)
117if (File.Exists(Path.Combine(appDirectory, "Dockerfile"))) 1530if (File.Exists(wrapperPath)) 1954return File.Exists(runJar) ? Path.GetFullPath(runJar) : null; 2021if (!File.Exists(pomPath)) 2059if (!File.Exists(settingsPath)) 2069if (GradleRootProjectNameRegex().Match(File.ReadAllText(settingsPath)) is { Success: true } match)
JavaVersionDetector.cs (3)
77if (!File.Exists(pomPath)) 201if (!File.Exists(buildScriptPath)) 209contents = File.ReadAllText(buildScriptPath);
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
Aspire.Hosting.Java.Tests (77)
AddJavaAppPublishTests.cs (55)
52await File.WriteAllTextAsync(Path.Combine(workspace.Path, "build", "libs", "reports service.jar"), ""); 68Assert.True(File.Exists(destination)); 234File.WriteAllText(Path.Combine(sourceDir.FullName, "build.gradle"), ""); 395File.WriteAllText(Path.Combine(source, ".dockerignore"), "secrets/\n"); 410File.WriteAllText(Path.Combine(sourceDir.FullName, "Dockerfile"), "FROM scratch\n"); 416Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 431File.WriteAllText(Path.Combine(sourceDir.FullName, "Dockerfile"), "FROM scratch\n"); 462File.WriteAllText(Path.Combine(sourceDir.FullName, "Dockerfile"), "FROM scratch\n"); 494var manifest = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "aspire-manifest.json"), TestContext.Current.CancellationToken); 511File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), $""" 532File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 562File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 640File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), script); 650File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 653File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "sourceCompatibility = '21'"); 669File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 672File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "sourceCompatibility = '21'"); 686File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 689File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "plugins { id 'java' }"); 701File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 724File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 746File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 767File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), "<project>"); 799File.WriteAllText(Path.Combine(appDirectory.Path, fileName), ""); 816File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), "<project />"); 817File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), ""); 863File.WriteAllText(Path.Combine(sourceDir.FullName, "pom.xml"), "<project/>"); 1012File.Delete(Path.Combine(sourceDir.FullName, "mvnw")); 1078File.WriteAllText(Path.Combine(source, "target", "worker.jar"), ""); 1098File.WriteAllText(Path.Combine(source, "target", "worker.jar"), ""); 1114File.WriteAllText(Path.Combine(source, "target", "worker.jar"), ""); 1147await File.WriteAllTextAsync( 1178await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "aspire-manifest.json"), TestContext.Current.CancellationToken)); 1187File.Copy( 1190File.Copy( 1227await File.WriteAllTextAsync( 1260await File.WriteAllTextAsync( 1294File.Copy( 1297File.Copy( 1472Assert.Equal("runner", File.ReadAllText(Path.Combine(stagingDirectory, "quarkus-run.jar"))); 1481Assert.Equal("dependency", File.ReadAllText(expectedDependency)); 1531File.AppendAllText( 1694File.WriteAllText( 1696File.ReadAllText(Path.Combine(source, "pom.xml")).Replace( 1779File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile")), 1805return await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 2028return await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 2054return File.Exists(ignorePath) 2055? await File.ReadAllTextAsync(ignorePath, TestContext.Current.CancellationToken) 2063File.WriteAllText(Path.Combine(sourceDirectory, "pom.xml"), $""" 2080File.WriteAllText(Path.Combine(sourceDirectory, "pom.xml"), $""" 2097File.WriteAllText(Path.Combine(sourceDirectory, "pom.xml"), $""" 2125File.WriteAllText(Path.Combine(sourceDirectory, "build.gradle"), contents); 2131File.WriteAllText(Path.Combine(sourceDirectory, wrapperName), "#!/bin/sh\nexit 0\n"); 2148File.WriteAllText(
AddJavaAppTests.cs (13)
351File.WriteAllText(Path.Combine(repo.Path, "settings.gradle"), "include 'services:api'"); 353File.WriteAllText(Path.Combine(module, "build.gradle"), ""); 371File.WriteAllText(Path.Combine(repo.Path, "pom.xml"), "<project />"); 373File.WriteAllText(Path.Combine(module, "pom.xml"), "<project />"); 392File.WriteAllText(Path.Combine(module, JavaHostingExtensions.s_defaultGradleWrapper), "#!/bin/sh\n"); 781File.WriteAllText(customWrapper, "#!/bin/sh\n"); 816await File.WriteAllTextAsync(wrapper, "#!/bin/sh\nexit 0\n"); 819File.SetUnixFileMode(wrapper, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.OtherRead); 1575File.WriteAllText( 1684File.WriteAllText(Path.Combine(tempDir.Path, "pom.xml"), """ 1714File.WriteAllText(Path.Combine(tempDir.Path, "settings.gradle"), "rootProject.name = 'orders'\n"); 1747File.WriteAllText( 1769File.WriteAllText(Path.Combine(tempDir.Path, "pom.xml"), """
JavaBuildToolResolverTests.cs (6)
68File.SetUnixFileMode( 95File.SetUnixFileMode( 119File.SetUnixFileMode( 143File.WriteAllText(Path.Combine(_root.FullName, "pom.xml"), "<project/>"); 144File.WriteAllText(Path.Combine(_root.FullName, "mvnw"), "#!/bin/sh\n"); 152File.WriteAllText(Path.Combine(module.FullName, "pom.xml"), "<project/>");
TempJavaAppDirectory.cs (3)
45File.WriteAllText(fullPath, content); 66File.WriteAllText( 74File.SetUnixFileMode(
Aspire.Hosting.JavaScript (30)
JavaScriptHostingExtensions.cs (26)
177if (File.Exists(Path.Combine(resource.WorkingDirectory, "Dockerfile"))) 281if (File.Exists(Path.Combine(appDirectory, "package.json"))) 520if (File.Exists(Path.Combine(resource.WorkingDirectory, "Dockerfile"))) 706if (File.Exists(Path.Combine(appDirectory, "package.json"))) 1170if (File.Exists(Path.Combine(appDirectory, "Dockerfile"))) 1545if (File.Exists(candidatePath)) 1589File.WriteAllText(aspireConfigPath, aspireConfig); 1850var hasBunLock = File.Exists(Path.Combine(workingDirectory, "bun.lock")) || 1851File.Exists(Path.Combine(workingDirectory, "bun.lockb")); 1856if (File.Exists(Path.Combine(workingDirectory, "bun.lock"))) 1860if (File.Exists(Path.Combine(workingDirectory, "bun.lockb"))) 1900File.Exists(Path.Combine(resource.Resource.WorkingDirectory, "package-lock.json")) 1918var hasYarnLock = File.Exists(Path.Combine(workingDirectory, "yarn.lock")); 1919var hasYarnrc = File.Exists(Path.Combine(workingDirectory, ".yarnrc.yml")); 1997var hasPnpmLock = File.Exists(Path.Combine(workingDirectory, "pnpm-lock.yaml")); 1998var hasPnpmWorkspace = File.Exists(Path.Combine(workingDirectory, "pnpm-workspace.yaml")); 2053if (!File.Exists(packageJsonPath)) 2060using var packageJson = JsonDocument.Parse(File.ReadAllText(packageJsonPath)); 2442if (!File.Exists(configPath)) 2449var content = File.ReadAllText(configPath); 2567if (File.Exists(nvmrcPath)) 2569var versionString = File.ReadAllText(nvmrcPath).Trim(); 2580if (File.Exists(nodeVersionPath)) 2582var versionString = File.ReadAllText(nodeVersionPath).Trim(); 2593if (File.Exists(toolVersionsPath)) 2595var lines = File.ReadAllLines(toolVersionsPath);
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
Aspire.Hosting.JavaScript.Tests (132)
AddBunAppTests.cs (17)
41File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 49var dockerfileContents = File.ReadAllText(dockerfilePath); 66File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 75await Verify(File.ReadAllText(Path.Combine(workspace.Path, "js.Dockerfile"))); 86File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 96Assert.True(File.Exists(perDockerfileIgnorePath), $"Expected per-Dockerfile dockerignore at {perDockerfileIgnorePath}"); 97var ignoreContents = File.ReadAllText(perDockerfileIgnorePath); 101Assert.False(File.Exists(Path.Combine(appDir, ".dockerignore")), "Aspire should not write a .dockerignore into the user's source tree."); 117File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 124Assert.True(File.Exists(perDockerfileIgnorePath)); 131File.WriteAllText(userIgnorePath, userIgnoreContents); 135Assert.False(File.Exists(perDockerfileIgnorePath), "Aspire should not shadow a user-authored context-root .dockerignore."); 138Assert.Equal(userIgnoreContents, File.ReadAllText(userIgnorePath)); 145File.WriteAllText(Path.Combine(workspace.Path, "server.ts"), "console.log('hi');"); 167File.WriteAllText(Path.Combine(workspace.Path, "package.json"), "{}"); 351File.WriteAllText(Path.Combine(workspace.Path, "package.json"), "{}"); 384File.WriteAllText(Path.Combine(workspace.Path, "package.json"), "{}");
AddJavaScriptAppTests.cs (30)
37await Verify(File.ReadAllText(dockerfilePath)); 60await Verify(File.ReadAllText(dockerfilePath)); 80await Verify(File.ReadAllText(dockerfilePath)); 100await Verify(File.ReadAllText(dockerfilePath)); 117File.WriteAllText(Path.Combine(appDir, "pnpm-lock.yaml"), string.Empty); 127var dockerfileContents = File.ReadAllText(dockerfilePath); 147var dockerfileLines = await File.ReadAllLinesAsync(Path.Combine(workspace.Path, "js.Dockerfile")); 177File.WriteAllText(Path.Combine(appDir, "pnpm-lock.yaml"), string.Empty); 188var dockerfileContents = File.ReadAllText(dockerfilePath); 353File.WriteAllText(Path.Combine(appDir, "pnpm-workspace.yaml"), "allowBuilds: {}\n"); 362var dockerfileLines = await File.ReadAllLinesAsync(dockerfilePath); 383await File.WriteAllTextAsync( 397var dockerfile = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "js.Dockerfile")); 417await File.WriteAllTextAsync( 432var dockerfile = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "js.Dockerfile")); 449await File.WriteAllTextAsync( 463var dockerfile = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "js.Dockerfile")); 478await File.WriteAllTextAsync( 492var dockerfile = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "js.Dockerfile")); 518File.WriteAllText( 556await File.WriteAllTextAsync(Path.Combine(appDir, "package.json"), packageJson); 565Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 568var dockerfileContent = await File.ReadAllTextAsync(dockerfilePath); 580await File.WriteAllTextAsync(dockerfileInContext, modifiedDockerfile); 651await File.WriteAllTextAsync(Path.Combine(appDir, "package.json"), packageJson); 661Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 663var dockerfileContent = await File.ReadAllTextAsync(dockerfilePath); 670await File.WriteAllTextAsync(dockerfileInContext, dockerfileContent); 725File.WriteAllText(Path.Combine(appDir, "Dockerfile"), dockerfile); 726File.WriteAllText(Path.Combine(appDir, "package.json"), """
AddNodeAppTests.cs (18)
106File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 107File.WriteAllText(Path.Combine(appDir, "package-lock.json"), "{}"); 115var dockerfileContents = File.ReadAllText(dockerfilePath); 171File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 184var dockerfileContents = File.ReadAllText(dockerfilePath); 218File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 229var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "js.Dockerfile")); 238File.WriteAllText(Path.Combine(workspace.Path, "app.js"), "{}"); 265File.WriteAllText(Path.Combine(workspace.Path, "package.json"), "{}"); 339File.WriteAllText(Path.Combine(appDirectory, "package.json"), packageJsonContent); 340File.WriteAllText(Path.Combine(appDirectory, "app.js"), appContent); 366Assert.True(File.Exists(nodeDockerfilePath), "Dockerfile should be generated for NodeApp"); 368var dockerfileContent = File.ReadAllText(nodeDockerfilePath); 396File.WriteAllText(Path.Combine(appDirectory, "package.json"), packageJsonContent); 397File.WriteAllText(Path.Combine(appDirectory, "app.js"), appContent); 423Assert.True(File.Exists(nodeDockerfilePath), "Dockerfile should be generated for NodeApp"); 425var dockerfileContent = File.ReadAllText(nodeDockerfilePath); 562File.WriteAllText(Path.Combine(workspace.Path, "app.js"), "console.log('hello');");
AddViteAppTests.cs (55)
32File.WriteAllText(Path.Combine(viteDir, "package-lock.json"), "empty"); 64var dockerfileContents = File.ReadAllText(dockerfilePath); 91File.WriteAllText(Path.Combine(viteDir, "package-lock.json"), "empty"); 100await Verify(File.ReadAllText(dockerfilePath)); 117File.WriteAllText(Path.Combine(viteDir, "package-lock.json"), "empty"); 121File.WriteAllText(Path.Combine(apiDir, "package-lock.json"), "empty"); 133await Verify(File.ReadAllText(dockerfilePath)); 144File.WriteAllText(Path.Combine(viteDir, "package-lock.json"), "empty"); 165File.WriteAllText(Path.Combine(viteDir, "package-lock.json"), "empty"); 169File.WriteAllText(Path.Combine(apiDir, "package-lock.json"), "empty"); 195File.WriteAllText(Path.Combine(appDir, "package-lock.json"), "empty"); 204await Verify(File.ReadAllText(dockerfilePath)); 221File.WriteAllText(Path.Combine(appDir, "package-lock.json"), "empty"); 230await Verify(File.ReadAllText(dockerfilePath)); 244File.WriteAllText(Path.Combine(nextDir, "package-lock.json"), "empty"); 252await Verify(File.ReadAllText(dockerfilePath)); 265File.WriteAllText(Path.Combine(nextDir, "pnpm-lock.yaml"), ""); 273await Verify(File.ReadAllText(dockerfilePath)); 284File.WriteAllText(Path.Combine(appDir, "pnpm-lock.yaml"), ""); 293await Verify(File.ReadAllText(dockerfilePath)); 304File.WriteAllText(Path.Combine(appDir, "bun.lock"), ""); 313await Verify(File.ReadAllText(dockerfilePath)); 322File.WriteAllText(Path.Combine(workspace.Path, ".nvmrc"), "18.20.0"); 330var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 342File.WriteAllText(Path.Combine(workspace.Path, ".node-version"), "v21.5.0"); 350var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 367File.WriteAllText(Path.Combine(workspace.Path, ".tool-versions"), toolVersions); 375var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 393File.WriteAllText(Path.Combine(workspace.Path, ".tool-versions"), toolVersions); 401var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 419File.WriteAllText(Path.Combine(workspace.Path, "package.json"), packageJson); 427var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 444var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 460File.WriteAllText(Path.Combine(workspace.Path, ".nvmrc"), versionString); 468var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 490var dockerfileContents = File.ReadAllText(Path.Combine(workspace.Path, "vite.Dockerfile")); 552File.WriteAllText(viteConfigPath, "export default {}"); 613File.WriteAllText(viteConfigPath, "export default {}"); 714File.WriteAllText(viteConfigPath, "export default {}"); 760File.WriteAllText(viteConfigPath, "export default {}"); 818File.WriteAllText(viteConfigPath, "export default {}"); 872var wrapperContent = File.ReadAllText(wrapperFiles[0]); 896File.WriteAllText(firstConfigPath, "export default { app: 'a' }"); 897File.WriteAllText(secondConfigPath, "export default { app: 'b' }"); 941Assert.Contains(Path.GetFullPath(firstConfigPath).Replace("\\", "\\\\"), File.ReadAllText(firstWrapperPath)); 942Assert.Contains(Path.GetFullPath(secondConfigPath).Replace("\\", "\\\\"), File.ReadAllText(secondWrapperPath)); 959File.WriteAllText(firstConfigPath, "export default { app: 'first' }"); 960File.WriteAllText(secondConfigPath, "export default { app: 'second' }"); 980Assert.Contains(Path.GetFullPath(firstConfigPath).Replace("\\", "\\\\"), File.ReadAllText(firstWrapperPath)); 981Assert.Contains(Path.GetFullPath(secondConfigPath).Replace("\\", "\\\\"), File.ReadAllText(secondWrapperPath)); 1000File.WriteAllText(viteConfigPath, "export default {}"); 1052File.WriteAllText(Path.Combine(nextDir, "package-lock.json"), "empty"); 1068File.WriteAllText(Path.Combine(nextDir, "package-lock.json"), "empty"); 1085File.WriteAllText(Path.Combine(nextDir, "package-lock.json"), "empty"); 1086File.WriteAllText(Path.Combine(nextDir, "next.config.ts"), "const nextConfig = {}; export default nextConfig;");
BunAppFixture.cs (2)
83File.WriteAllText(Path.Combine(tempDir, "server.ts"), 101File.WriteAllText(Path.Combine(tempDir, "package.json"),
NodeAppFixture.cs (2)
75File.WriteAllText(Path.Combine(tempDir, "app.js"), 95File.WriteAllText(Path.Combine(tempDir, "package.json"),
PackageInstallationTests.cs (7)
458File.WriteAllText(Path.Combine(workspace.Path, "package-lock.json"), "empty"); 485File.WriteAllText(Path.Combine(workspace.Path, "yarn.lock"), "empty"); 506File.WriteAllText(Path.Combine(workspace.Path, "yarn.lock"), "empty"); 507File.WriteAllText(Path.Combine(workspace.Path, ".yarnrc.yml"), "empty"); 522File.WriteAllText(Path.Combine(workspace.Path, "yarn.lock"), "empty"); 538File.WriteAllText(Path.Combine(workspace.Path, "pnpm-lock.yaml"), "empty"); 553File.WriteAllText(Path.Combine(workspace.Path, "bun.lock"), "empty");
RequiredCommandTests.cs (1)
157File.WriteAllText(Path.Combine(workspace.Path, "package.json"), "{}");
Aspire.Hosting.Kafka.Tests (1)
KafkaFunctionalTests.cs (1)
155File.SetUnixFileMode(bindMountPath, BindMountPermissions);
Aspire.Hosting.Keycloak.Tests (1)
KeycloakPublicApiTests.cs (1)
178File.WriteAllText(filePath, string.Empty);
Aspire.Hosting.Kubernetes (14)
CertManagerExtensions.cs (1)
452await File.WriteAllTextAsync(manifestPath, manifest, context.CancellationToken).ConfigureAwait(false);
Deployment\HelmDeploymentEngine.cs (4)
245if (!File.Exists(valuesFilePath)) 363await File.WriteAllTextAsync(overrideFilePath, overrideContent, cancellationToken).ConfigureAwait(false); 446if (File.Exists(valuesFilePath)) 452if (File.Exists(deployValuesFilePath))
KubernetesEnvironmentResource.cs (7)
1476await File.WriteAllTextAsync(patchFilePath, patchJson, context.CancellationToken).ConfigureAwait(false); 1589await File.WriteAllTextAsync(certPath, certPem, context.CancellationToken).ConfigureAwait(false); 1590await File.WriteAllTextAsync(keyPath, keyPem, context.CancellationToken).ConfigureAwait(false); 1922await File.WriteAllTextAsync(patchFilePath, patchJson, context.CancellationToken).ConfigureAwait(false); 2103await File.WriteAllTextAsync(manifestPath, minimal.ToJsonString(), context.CancellationToken).ConfigureAwait(false); 2226await File.WriteAllTextAsync(certPath, certPem, context.CancellationToken).ConfigureAwait(false); 2227await File.WriteAllTextAsync(keyPath, keyPem, context.CancellationToken).ConfigureAwait(false);
KubernetesPublishingContext.cs (2)
404await File.WriteAllTextAsync(outputFile, valuesYaml, cancellationToken).ConfigureAwait(false); 426await File.WriteAllTextAsync(outputFile, chartYaml, cancellationToken).ConfigureAwait(false);
Aspire.Hosting.Kubernetes.Tests (144)
KubernetesDeployTests.cs (37)
878var chartYaml = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "Chart.yaml")); 909var chartYaml = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "Chart.yaml")); 931var deploymentYaml = await File.ReadAllTextAsync(Path.Combine(workspace.Path, "templates", "svc", "deployment.yaml")); 983await File.WriteAllTextAsync(Path.Combine(outputPath, "values.yaml"), valuesYaml); 1003Assert.True(File.Exists(deployValuesPath), "values.env.yaml should be created"); 1005var content = await File.ReadAllTextAsync(deployValuesPath); 1022await File.WriteAllTextAsync(Path.Combine(outputPath, "values.yaml"), "parameters: {}\nsecrets: {}\nconfig: {}"); 1032Assert.False(File.Exists(deployValuesPath), "values.env.yaml should not be created when there are no captured values"); 1042await File.WriteAllTextAsync(Path.Combine(outputPath, "values.yaml"), "parameters: {}\nsecrets: {}\nconfig: {}"); 1062Assert.True(File.Exists(deployValuesPath)); 1064var content = await File.ReadAllTextAsync(deployValuesPath); 1116await File.WriteAllTextAsync(Path.Combine(outputPath, "values.yaml"), "parameters: {}\nsecrets: {}\nconfig: {}"); 1138Assert.True(File.Exists(deployValuesPath)); 1140var content = await File.ReadAllTextAsync(deployValuesPath); 1281await File.WriteAllTextAsync(Path.Combine(outputPath, "values.yaml"), valuesYaml); 1307Assert.True(File.Exists(deployValuesPath), "values.env.yaml should be created"); 1309var content = await File.ReadAllTextAsync(deployValuesPath); 1331Assert.False(File.Exists(deployValuesPath)); 1370Assert.True(File.Exists(valuesPath), "values.yaml should exist"); 1371var valuesContent = await File.ReadAllTextAsync(valuesPath); 1393if (File.Exists(serverSecretsTemplatePath)) 1395var templateContent = await File.ReadAllTextAsync(serverSecretsTemplatePath); 1445Assert.True(File.Exists(valuesPath), "values.yaml should exist"); 1446var valuesContent = await File.ReadAllTextAsync(valuesPath); 1504Assert.True(File.Exists(overridePath), "Override file should be created"); 1506var content = await File.ReadAllTextAsync(overridePath); 1562Assert.True(File.Exists(overridePath), "Override file should be created"); 1564var content = await File.ReadAllTextAsync(overridePath); 1623await Verify(await File.ReadAllTextAsync(overridePath), "yaml"); 1668await Verify(await File.ReadAllTextAsync(overridePath), "yaml"); 1708await Verify(await File.ReadAllTextAsync(Path.Combine(workspace.Path, "values.yaml")), "yaml") 1710await File.ReadAllTextAsync(Path.Combine(workspace.Path, "templates", "myapp", "config.yaml")), 1712.AppendContentAsFile(await File.ReadAllTextAsync(overridePath), "yaml"); 1781Assert.True(File.Exists(valuesPath)); 1782var content = await File.ReadAllTextAsync(valuesPath); 1816Assert.True(File.Exists(valuesPath)); 1817var content = await File.ReadAllTextAsync(valuesPath);
KubernetesEnvironmentResourceTests.cs (3)
33await Verify(File.ReadAllText(chartYaml), "yaml") 34.AppendContentAsFile(File.ReadAllText(valuesYaml), "yaml") 35.AppendContentAsFile(File.ReadAllText(deploymentYaml), "yaml");
KubernetesGatewayTests.cs (12)
43var gatewayContent = await File.ReadAllTextAsync(gatewayFile); 51var routeContent = await File.ReadAllTextAsync(routeFile); 79var content = await File.ReadAllTextAsync(routeFile); 110await Verify(File.ReadAllText(gatewayPath), "yaml") 111.AppendContentAsFile(File.ReadAllText(routePath), "yaml") 112.AppendContentAsFile(File.ReadAllText(valuesPath), "yaml"); 138await Verify(File.ReadAllText(routePath), "yaml"); 257var content = await File.ReadAllTextAsync(gatewayFile); 465var content = await File.ReadAllTextAsync(gatewayFile); 514var content = await File.ReadAllTextAsync(gatewayFile); 597Assert.True(File.Exists(gatewayFile)); 598var content = await File.ReadAllTextAsync(gatewayFile);
KubernetesIngressTests.cs (26)
35Assert.True(File.Exists(ingressPath), $"Expected ingress YAML at {ingressPath}"); 37var content = await File.ReadAllTextAsync(ingressPath); 65Assert.True(File.Exists(ingressPath), $"Expected ingress YAML at {ingressPath}"); 67var content = await File.ReadAllTextAsync(ingressPath); 109Assert.True(File.Exists(ingressPath), $"Expected ingress YAML at {ingressPath}"); 111var content = await File.ReadAllTextAsync(ingressPath); 116Assert.True(File.Exists(valuesPath), $"Expected values.yaml at {valuesPath}"); 118var values = await File.ReadAllTextAsync(valuesPath); 150var content = await File.ReadAllTextAsync(ingressPath); 180await Verify(File.ReadAllText(ingressPath), "yaml") 181.AppendContentAsFile(File.ReadAllText(valuesPath), "yaml"); 206await Verify(File.ReadAllText(ingressPath), "yaml"); 230await Verify(File.ReadAllText(ingressPath), "yaml"); 254var content = await File.ReadAllTextAsync(ingressPath); 283var content = await File.ReadAllTextAsync(ingressPath); 316var content = await File.ReadAllTextAsync(ingressPath); 344var content = await File.ReadAllTextAsync(ingressPath); 368var content = await File.ReadAllTextAsync(ingressPath); 615Assert.True(File.Exists(publicPath), $"Public ingress YAML not found at {publicPath}"); 616Assert.True(File.Exists(internalPath), $"Internal ingress YAML not found at {internalPath}"); 618var publicContent = await File.ReadAllTextAsync(publicPath); 619var internalContent = await File.ReadAllTextAsync(internalPath); 648Assert.True(File.Exists(ingressPath), $"Expected ingress YAML at {ingressPath}"); 650var content = await File.ReadAllTextAsync(ingressPath); 683var content = await File.ReadAllTextAsync(ingressPath); 799Assert.True(File.Exists(ingressPath));
KubernetesPublisherTests.cs (66)
76settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 80settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 111Assert.True(File.Exists(deploymentPath)); 113var content = await File.ReadAllTextAsync(deploymentPath); 173settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 177settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 213Assert.True(File.Exists(manifestPath), $"Manifest should exist at {manifestPath}"); 215var content = await File.ReadAllTextAsync(manifestPath); 295settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 299settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 351settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 355settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 379Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 380var actualContent = await File.ReadAllTextAsync(dockerfilePath); 454var deployment = await File.ReadAllTextAsync(deploymentPath); 547var deployment = await File.ReadAllTextAsync(deploymentPath); 647settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 651settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 692settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 696settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 715await Verify(File.ReadAllText(servicePath), "yaml"); 754settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 758settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 806settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 810settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 851settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 855settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 897settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 901settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1052settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1056settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1098settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1102settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1159settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1163settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1210settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1214settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1272settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1276settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1331settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1335settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1385settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 1389settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 1438Assert.True(File.Exists(filePath), $"Expected publisher to emit {expectedFile}."); 1440var content = await File.ReadAllTextAsync(filePath); 1457Assert.False(File.Exists(legacyPv), "DefaultStorageType=\"pvc\" must not emit a bare PV; dynamic provisioning is driven by the PVC's storageClassName."); 1487Assert.True(File.Exists(deploymentPath)); 1489var deploymentContent = await File.ReadAllTextAsync(deploymentPath); 1532Assert.True(File.Exists(filePath), $"Expected publisher to emit {expectedFile}."); 1534var content = await File.ReadAllTextAsync(filePath); 1545Assert.False(File.Exists(legacyPvc), "Bound volumes must not also be emitted via the env-default PV/PVC path."); 1549Assert.False(File.Exists(deploymentPath), "Workloads bound to a persistent volume must render as a StatefulSet, not a Deployment."); 1587Assert.True(File.Exists(filePath), $"Expected publisher to emit {expectedFile}."); 1589var content = await File.ReadAllTextAsync(filePath); 1623var content = await File.ReadAllTextAsync(statefulSetPath); 1650var content = await File.ReadAllTextAsync(statefulSetPath); 1690Assert.True(File.Exists(statefulSetPath)); 1692var statefulSetContent = await File.ReadAllTextAsync(statefulSetPath); 1696Assert.True(File.Exists(pvcPath)); 1697var pvcContent = await File.ReadAllTextAsync(pvcPath); 1760Assert.True(File.Exists(statefulSetPath), $"Expected StatefulSet manifest at {statefulSetPath}"); 1761var content = await File.ReadAllTextAsync(statefulSetPath); 1834Assert.True(File.Exists(pvcPath), $"Expected PVC manifest at {pvcPath}"); 1835var pvcContent = await File.ReadAllTextAsync(pvcPath); 1846Assert.True(File.Exists(valuesPath), $"Expected values.yaml at {valuesPath}"); 1847var valuesContent = await File.ReadAllTextAsync(valuesPath);
Aspire.Hosting.Maui (6)
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
Utilities\MauiEnvironmentHelper.cs (2)
76await File.WriteAllTextAsync(targetsFilePath, targetsContent, Encoding.UTF8, cancellationToken).ConfigureAwait(false); 252await File.WriteAllTextAsync(targetsFilePath, targetsContent, Encoding.UTF8, cancellationToken).ConfigureAwait(false);
Aspire.Hosting.Maui.Tests (53)
MauiiOSValidationTests.cs (6)
24File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 49File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 74File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 94File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 112File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 130File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios"));
MauiOtlpTemplateTests.cs (3)
26File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(tfm)); 53File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(tfm)); 76File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android"));
MauiPlatformExtensionsTests.cs (27)
95File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 118File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 138File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 157File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 186File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 234File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 253File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 277File.WriteAllText(tempFile, CreateProjectContentWithout(config.PlatformIdentifier)); 305File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 331File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 354File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 377File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 400File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 428File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 453File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 482File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 507File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 534File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 562File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 592File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 616File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 639File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(config.RequiredTfm)); 677File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 729File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 793File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 817File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 844File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android"));
MauiUnsupportedPlatformTests.cs (6)
18File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-windows10.0.19041.0")); 42File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-maccatalyst")); 66File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 90File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 115File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 130File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android"));
MauiWithArgsTests.cs (11)
21File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent(windowsTfm)); 39File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-maccatalyst")); 58File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 78File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 95File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 115File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-android")); 132File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 151File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 168File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 188File.WriteAllText(tempFile, MauiTestHelper.CreateProjectContent("net10.0-ios")); 210File.WriteAllText(tempFile, """
Aspire.Hosting.MongoDB.Tests (4)
MongoDbFunctionalTests.cs (4)
272File.SetUnixFileMode(bindMountPath, BindMountPermissions); 278await File.WriteAllTextAsync(initFilePath, $$""" 301File.SetUnixFileMode(initFilePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.OtherRead); 375await File.WriteAllTextAsync(initFilePath, $$"""
Aspire.Hosting.MySql (2)
MySqlBuilderExtensions.cs (2)
301File.SetUnixFileMode(configStoreFilename, FileMode644); 310File.Delete(tempConfigFile);
Aspire.Hosting.MySql.Tests (4)
AddMySqlTests.cs (1)
279using var stream = File.OpenRead(volume.Source!);
MySqlFunctionalTests.cs (3)
320File.SetUnixFileMode(bindMountPath, BindMountPermissions); 325File.WriteAllText(Path.Combine(bindMountPath, "init.sql"), """ 410File.WriteAllText(Path.Combine(initFilesPath, "init.sql"), """
Aspire.Hosting.Oracle.Tests (4)
OracleFunctionalTests.cs (4)
122File.SetUnixFileMode(bindMountPath, MountFilePermissions); 273File.SetUnixFileMode(bindMountPath, MountFilePermissions); 280File.WriteAllText(Path.Combine(bindMountPath, "01_init.sql"), $""" 372File.WriteAllText(Path.Combine(initFilesPath, "01_init.sql"), $"""
Aspire.Hosting.PostgreSQL.Tests (3)
PostgresFunctionalTests.cs (3)
380File.SetUnixFileMode(bindMountPath, BindMountPermissions); 385File.WriteAllText(Path.Combine(bindMountPath, "init.sql"), """ 471File.WriteAllText(Path.Combine(initFilesPath, "init.sql"), """
Aspire.Hosting.Python (15)
PythonAppResourceBuilderExtensions.cs (10)
434if (File.Exists(Path.Combine(resource.WorkingDirectory, "Dockerfile"))) 512if (File.Exists(Path.Combine(appDirectoryFullPath, "pyproject.toml")) || 513File.Exists(Path.Combine(appDirectoryFullPath, "requirements.txt"))) 533var hasUvLock = File.Exists(uvLockPath); 642var hasRequirementsTxt = File.Exists(requirementsTxtPath); 682var hasPyprojectToml = File.Exists(pyprojectTomlPath); 1157if (File.Exists(Path.Combine(workingDirectory, "pyproject.toml"))) 1162else if (File.Exists(Path.Combine(workingDirectory, "requirements.txt"))) 1271if (File.Exists(fullPath)) 1284if (File.Exists(fullPath))
PythonVersionDetector.cs (5)
21if (File.Exists(pythonVersionFile)) 23var version = File.ReadAllText(pythonVersionFile).Trim(); 32if (File.Exists(pyprojectFile)) 34var content = File.ReadAllText(pyprojectFile); 61if (!File.Exists(pythonExecutable))
Aspire.Hosting.Python.Tests (82)
AddPythonAppTests.cs (77)
290File.WriteAllText(scriptPath, scriptContent); 293File.WriteAllText(requirementsPath, requirementsContent); 297File.WriteAllText(dockerFilePath, 1269File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1270File.WriteAllText(Path.Combine(projectDirectory, "uv.lock"), uvLockContent); 1271File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1293Assert.True(File.Exists(scriptDockerfilePath), "Dockerfile should be generated for script entrypoint"); 1296Assert.True(File.Exists(moduleDockerfilePath), "Dockerfile should be generated for module entrypoint"); 1299Assert.True(File.Exists(executableDockerfilePath), "Dockerfile should be generated for executable entrypoint"); 1301var scriptDockerfileContent = File.ReadAllText(scriptDockerfilePath); 1302var moduleDockerfileContent = File.ReadAllText(moduleDockerfilePath); 1303var executableDockerfileContent = File.ReadAllText(executableDockerfilePath); 1335File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1337File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1359Assert.True(File.Exists(scriptDockerfilePath), "Dockerfile should be generated for script entrypoint"); 1362Assert.True(File.Exists(moduleDockerfilePath), "Dockerfile should be generated for module entrypoint"); 1365Assert.True(File.Exists(executableDockerfilePath), "Dockerfile should be generated for executable entrypoint"); 1367var scriptDockerfileContent = File.ReadAllText(scriptDockerfilePath); 1368var moduleDockerfileContent = File.ReadAllText(moduleDockerfilePath); 1369var executableDockerfileContent = File.ReadAllText(executableDockerfilePath); 1795File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1796File.WriteAllText(Path.Combine(projectDirectory, "uv.lock"), uvLockContent); 1797File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1813Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated"); 1815var dockerfileContent = File.ReadAllText(dockerfilePath); 1842File.WriteAllText(Path.Combine(projectDirectory, "requirements.txt"), requirementsContent); 1843File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1855Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated for non-UV Python app"); 1857var dockerfileContent = File.ReadAllText(dockerfilePath); 1892File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1893File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1905Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated for non-UV Python app"); 1907var dockerfileContent = File.ReadAllText(dockerfilePath); 1925File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1937Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated for Python app"); 1939var dockerfileContent = File.ReadAllText(dockerfilePath); 1959File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1960File.WriteAllText(Path.Combine(projectDirectory, ".python-version"), pythonVersionContent); 1974Assert.True(File.Exists(scriptDockerfilePath), "Dockerfile should be generated for script entrypoint"); 1977Assert.True(File.Exists(moduleDockerfilePath), "Dockerfile should be generated for module entrypoint"); 1980Assert.True(File.Exists(executableDockerfilePath), "Dockerfile should be generated for executable entrypoint"); 1982var scriptDockerfileContent = File.ReadAllText(scriptDockerfilePath); 1983var moduleDockerfileContent = File.ReadAllText(moduleDockerfilePath); 1984var executableDockerfileContent = File.ReadAllText(executableDockerfilePath); 2009File.WriteAllText(scriptPath, "print('Hello')"); 2013File.WriteAllText(pyprojectPath, "[project]\nname = \"test\""); 2043File.WriteAllText(scriptPath, "print('Hello')"); 2047File.WriteAllText(requirementsPath, "requests==2.31.0"); 2078File.WriteAllText(scriptPath, "print('Hello')"); 2082File.WriteAllText(pyprojectPath, "[project]\nname = \"test\""); 2084File.WriteAllText(requirementsPath, "requests==2.31.0"); 2108File.WriteAllText(scriptPath, "print('Hello')"); 2132File.WriteAllText(scriptPath, "print('Hello')"); 2155File.WriteAllText(scriptPath, "print('Hello')"); 2159File.WriteAllText(requirementsPath, "requests"); 2183File.WriteAllText(scriptPath, "print('Hello')"); 2187File.WriteAllText(requirementsPath, "requests"); 2212File.WriteAllText(scriptPath, "print('Hello')"); 2240File.WriteAllText(scriptPath, "print('Hello')"); 2244File.WriteAllText(requirementsPath, "requests"); 2283File.WriteAllText(scriptPath, "print('Hello')"); 2286File.WriteAllText(requirementsPath, "requests"); 2313File.WriteAllText(scriptPath, "print('Hello')"); 2316File.WriteAllText(requirementsPath, "requests"); 2347File.WriteAllText(scriptPath, "print('Hello')"); 2350File.WriteAllText(requirementsPath, "requests"); 2383File.WriteAllText(scriptPath, "print('Hello')"); 2386File.WriteAllText(requirementsPath, "requests"); 2413File.WriteAllText(scriptPath, "print('Hello')"); 2416File.WriteAllText(requirementsPath, "requests"); 2445File.WriteAllText(scriptPath, "print('Hello')"); 2448File.WriteAllText(requirementsPath, "requests"); 2477File.WriteAllText(scriptPath, "print('Hello')"); 2480File.WriteAllText(requirementsPath, "requests"); 2513File.WriteAllText(scriptPath, "print('Hello')"); 2567File.WriteAllText(scriptPath, "print('Hello')"); 2570File.WriteAllText(requirementsPath, "requests");
AddUvicornAppTests.cs (5)
58File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 59File.WriteAllText(Path.Combine(projectDirectory, "uv.lock"), uvLockContent); 60File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 89Assert.True(File.Exists(appDockerfilePath), "Dockerfile should be generated for script entrypoint"); 91var scriptDockerfileContent = File.ReadAllText(appDockerfilePath);
Aspire.Hosting.Radius (10)
Publishing\RadiusBicepPublishingContext.cs (3)
97await File.WriteAllTextAsync(bicepPath, bicepContent, cancellationToken).ConfigureAwait(false); 98await File.WriteAllTextAsync(configPath, bicepConfigContent, cancellationToken).ConfigureAwait(false); 183File.WriteAllBytes(destination, manifest.Content.ToArray());
Publishing\RadiusDeploymentPipelineStep.cs (3)
119if (!File.Exists(bicepPath)) 287await File.WriteAllTextAsync( 296File.SetUnixFileMode(filePath, UnixFileMode.UserRead | UnixFileMode.UserWrite);
Publishing\SealedSecretApplyStep.cs (3)
175return File.Exists(artifact) ? artifact : sourceManifestPath; 680if (!File.Exists(configPath)) 685var text = await File.ReadAllTextAsync(configPath, cancellationToken).ConfigureAwait(false);
Secrets\SealedSecretManifest.cs (1)
63content = File.ReadAllBytes(manifestPath);
Aspire.Hosting.Radius.Tests (15)
Publishing\RadiusDeployParametersTests.cs (3)
70var json = await File.ReadAllTextAsync(path); 85var mode = File.GetUnixFileMode(path); 91Assert.False(File.Exists(path));
Publishing\SealedSecretPublishTests.cs (10)
26File.WriteAllText(path, 104File.WriteAllText(manifest, 127var originalBytes = File.ReadAllBytes(manifest); 141File.WriteAllText(manifest, 160Assert.Equal(originalBytes, File.ReadAllBytes(destination)); 161Assert.NotEqual(File.ReadAllBytes(manifest), File.ReadAllBytes(destination)); 187Assert.True(File.Exists(destinationA)); 192Assert.True(File.Exists(destinationB)); 193Assert.False(File.Exists(destinationA), "The obsolete store's manifest must be pruned on republish.");
Secrets\SealedSecretManifestTests.cs (1)
17File.WriteAllText(path, content);
Secrets\SecretStoreValidationTests.cs (1)
62File.WriteAllText(
Aspire.Hosting.Redis.Tests (1)
RedisFunctionalTests.cs (1)
513File.SetUnixFileMode(bindMountPath, MountFilePermissions);
Aspire.Hosting.RemoteHost (13)
AssemblyLoader.cs (1)
357if (!File.Exists(libsPath))
AtsCapabilityScanner.cs (1)
3399if (File.Exists(xmlPath))
IntegrationLoadContext.cs (1)
140if (File.Exists(path))
JsonRpcServer.cs (5)
141if (File.Exists(_socketPath)) 143File.Delete(_socketPath); 161File.SetUnixFileMode(_socketPath, UnixFileMode.UserRead | UnixFileMode.UserWrite); 313if (File.Exists(_socketPath)) 317File.Delete(_socketPath);
src\Shared\IntegrationPackageProbeManifest.cs (4)
112if (!File.Exists(normalizedManifestPath)) 117using var stream = File.OpenRead(normalizedManifestPath); 173return File.WriteAllBytesAsync(path, stream.ToArray(), cancellationToken); 341if (!File.Exists(normalizedPath))
src\Shared\ProcessStartTimeHelper.cs (1)
345contents = File.ReadAllText(statPath);
Aspire.Hosting.RemoteHost.Tests (48)
AssemblyLoaderTests.cs (7)
84File.WriteAllText(runtimeAssemblyPath, string.Empty); 86File.WriteAllText(resourceAssemblyPath, string.Empty); 129File.WriteAllText(packageAssemblyPath, string.Empty); 206File.WriteAllText(firstAssemblyPath, string.Empty); 207File.WriteAllText(secondAssemblyPath, string.Empty); 254File.WriteAllText( 282File.WriteAllText(System.IO.Path.Combine(Path, fileName), string.Empty);
AtsExportsTests.cs (1)
140await File.WriteAllTextAsync(tempFile, "test content");
CodeGeneration\ApiReferenceExportTests.cs (2)
266File.WriteAllText( 289File.Copy(assemblyPath, destinationPath);
IntegrationLoadContextTests.cs (4)
42Assert.True(File.Exists(assemblyPath)); 77File.WriteAllText(nativeLibraryPath, string.Empty); 106File.WriteAllText(resourceAssemblyPath, string.Empty); 134File.WriteAllText(
IntegrationPackageProbeManifestTests.cs (1)
27File.WriteAllText(
JsonRpcAuthenticationTests.cs (2)
149if (!OperatingSystem.IsWindows() && File.Exists(_socketPath)) 151File.Delete(_socketPath);
LayoutCommandTests.cs (28)
28await File.WriteAllTextAsync(Path.Combine(packageRoot, "lib", "net10.0", "Test.Package.dll"), "base"); 29await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", "unix", "lib", "net10.0", "Test.Package.dll"), "unix"); 30await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", "win", "lib", "net10.0", "Test.Package.dll"), "win"); 31await File.WriteAllTextAsync(Path.Combine(packageRoot, "lib", "net10.0", "fr", "Test.Package.resources.dll"), "fr"); 32await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", GetCurrentRuntimeIdentifier(), "native", GetNativeFileName()), "runtime-native"); 35await File.WriteAllTextAsync(assetsPath, CreateAssetsJsonWithResolvedRidTarget(workspaceRoot, GetCurrentRuntimeIdentifier(), GetNativeFileName())); 49Assert.Equal(GetExpectedRuntimeContent(), await File.ReadAllTextAsync(Path.Combine(outputPath, "Test.Package.dll"))); 50Assert.Equal("fr", await File.ReadAllTextAsync(Path.Combine(outputPath, "fr", "Test.Package.resources.dll"))); 51Assert.Equal("runtime-native", await File.ReadAllTextAsync(Path.Combine(outputPath, GetNativeFileName()))); 54await File.ReadAllTextAsync(Path.Combine(outputPath, "runtimes", GetExpectedRuntimeAssetRid(), "lib", "net10.0", "Test.Package.dll"))); 57await File.ReadAllTextAsync(Path.Combine(outputPath, "runtimes", GetCurrentRuntimeIdentifier(), "native", GetNativeFileName()))); 80await File.WriteAllTextAsync(Path.Combine(packageRoot, "lib", "net10.0", "Test.Package.dll"), "base"); 81await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", "unix", "lib", "net10.0", "Test.Package.dll"), "unix"); 82await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", "win", "lib", "net10.0", "Test.Package.dll"), "win"); 85await File.WriteAllTextAsync(assetsPath, CreateAssetsJsonWithRuntimeSpecificTarget(workspaceRoot, GetCurrentRuntimeIdentifier(), GetExpectedRuntimeAssemblyPath())); 99Assert.Equal(GetExpectedRuntimeContent(), await File.ReadAllTextAsync(Path.Combine(outputPath, "Test.Package.dll"))); 120await File.WriteAllTextAsync(Path.Combine(packageRoot, "lib", "net10.0", "Test.Package.dll"), "base"); 123await File.WriteAllTextAsync(assetsPath, CreateAssetsJsonWithBaseTargetOnly(workspaceRoot)); 137Assert.Equal("base", await File.ReadAllTextAsync(Path.Combine(outputPath, "Test.Package.dll"))); 161await File.WriteAllTextAsync(Path.Combine(packageRoot, "lib", "net10.0", "Test.Package.dll"), "base"); 162await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", "unix", "lib", "net10.0", "Test.Package.dll"), "unix"); 163await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", "win", "lib", "net10.0", "Test.Package.dll"), "win"); 164await File.WriteAllTextAsync(Path.Combine(packageRoot, "lib", "net10.0", "fr", "Test.Package.resources.dll"), "fr"); 165await File.WriteAllTextAsync(Path.Combine(packageRoot, "runtimes", GetCurrentRuntimeIdentifier(), "native", GetNativeFileName()), "runtime-native"); 168await File.WriteAllTextAsync(assetsPath, CreateAssetsJsonWithResolvedRidTarget(workspaceRoot, GetCurrentRuntimeIdentifier(), GetNativeFileName())); 184await using var manifestStream = File.OpenRead(outputPath); 256await using var manifestStream = File.OpenRead(manifestPath); 416using var stream = File.OpenRead(assetsPath);
RestoreCommandTests.cs (2)
58await using var stream = File.OpenRead(manifestPath); 90using var fileStream = File.Create(packagePath);
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.Hosting.Rust (8)
RustDockerfileGenerator.cs (2)
68&& !File.Exists(Path.Combine(workingDirectory, ".dockerignore"))) 279if (!File.Exists(candidate) && !Directory.Exists(candidate))
RustHostingExtensions.cs (2)
609if (File.Exists(Path.Combine(candidate, "Cargo.lock"))) 751if (File.Exists(Path.Combine(workingDirectory, "Dockerfile")))
src\Shared\PathNormalizer.cs (4)
172: File.ResolveLinkTarget(current, returnFinalTarget: true) 253if (storedLinkTarget is null && !File.Exists(current) && !Directory.Exists(current)) 257_ = File.GetAttributes(current); 273: File.ResolveLinkTarget(current, returnFinalTarget: true)
Aspire.Hosting.Rust.Tests (58)
AddRustAppPublishTests.cs (43)
40File.WriteAllText(Path.Combine(source, "rust-toolchain.toml"), """ 418Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 473Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 497File.WriteAllText(Path.Combine(sourceDir.FullName, "Dockerfile"), "FROM scratch\n"); 503Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 515File.WriteAllText(Path.Combine(sourceDir.FullName, "Dockerfile"), "FROM scratch\n"); 521Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 533File.WriteAllText(customDockerfile, "FROM scratch\n"); 545Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 565var content = await File.ReadAllTextAsync( 591File.WriteAllText(Path.Combine(manifestDirectory.FullName, "Cargo.toml"), "[package]\nname = \"api\"\n"); 594if (!File.Exists(Path.Combine(sourceDir.FullName, differentlyCasedPath))) 604var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 619File.WriteAllText(Path.Combine(manifestDirectory.FullName, "Cargo.toml"), "[package]\nname = \"api\"\n"); 622if (!File.Exists(Path.Combine(sourceDir.FullName, composedManifestPath))) 634var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 655File.WriteAllText(Path.Combine(manifestDirectory.FullName, "Cargo.toml"), "[package]\nname = \"api\"\n"); 657var originalMode = File.GetUnixFileMode(restrictedAncestor.FullName); 662File.SetUnixFileMode(restrictedAncestor.FullName, UnixFileMode.UserExecute); 678var content = await File.ReadAllTextAsync( 686File.SetUnixFileMode(restrictedAncestor.FullName, originalMode); 718File.WriteAllText(Path.Combine(manifestDirectory.FullName, "Cargo.toml"), "[package]\nname = \"api\"\n"); 754var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 773File.WriteAllText(Path.Combine(manifestDirectory.FullName, "Cargo.toml"), "[package]\nname = \"api\"\n"); 781if (!File.Exists(differentlyCasedCanonicalManifest)) 793var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 805File.WriteAllText(Path.Combine(outsideDir.FullName, "Cargo.toml"), "[package]\nname = \"outside\"\n"); 813Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 836Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile"))); 874File.WriteAllText(Path.Combine(source, "Cargo.lock"), "version = 4\n")); 883configureSource: source => File.WriteAllText(Path.Combine(source, "Cargo.lock"), "version = 4\n"), 927var first = await File.ReadAllTextAsync(Path.Combine(firstOutputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 928var second = await File.ReadAllTextAsync(Path.Combine(secondOutputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 945var first = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 946var second = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "worker.Dockerfile"), TestContext.Current.CancellationToken); 974var ignore = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile.dockerignore"), TestContext.Current.CancellationToken); 988File.WriteAllText(Path.Combine(sourceDir.FullName, ".dockerignore"), "*.md\n"); 995Assert.False(File.Exists(Path.Combine(outputDir.FullName, "api.Dockerfile.dockerignore"))); 1010File.WriteAllText(Path.Combine(relocatedDir.FullName, "Dockerfile"), "FROM scratch\n"); 1053File.WriteAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "Cargo.lock"), "version = 4\n"); 1057File.WriteAllText(Path.Combine(sourceDir.FullName, "Cargo.lock"), "version = 4\n"); 1066var content = await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken); 1143return await File.ReadAllTextAsync(Path.Combine(outputDir.FullName, "api.Dockerfile"), TestContext.Current.CancellationToken);
RustDockerfileShellTests.cs (13)
31Assert.Equal("current", File.ReadAllText(Path.Combine(artifactDirectory, "api"))); 42await File.WriteAllTextAsync( 56Assert.False(File.Exists(Path.Combine(artifactDirectory, "api"))); 71File.WriteAllText(rootCandidate, "stale-root"); 72File.WriteAllText(staleTargetCandidate, "stale-target"); 85Assert.False(File.Exists(rootCandidate)); 86Assert.False(File.Exists(staleTargetCandidate)); 87Assert.Equal("current", File.ReadAllText(Path.Combine(artifactDirectory, "api"))); 109Assert.False(File.Exists(markerPath)); 184File.WriteAllText( 190File.SetUnixFileMode(stubPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 195=> File.Exists(invocationLog) 196? File.ReadAllLines(invocationLog)
RustReadmeTests.cs (1)
15var readme = await File.ReadAllTextAsync(readmePath, TestContext.Current.CancellationToken);
TempCrateDirectory.cs (1)
16=> File.WriteAllText(System.IO.Path.Combine(Path, fileName), content);
Aspire.Hosting.Sdk.Tests (62)
AppHostSdkTargetsTests.cs (61)
224await File.WriteAllTextAsync(nonExecutableDnxPath, ""); 227File.SetUnixFileMode(nonExecutableDnxPath, UnixFileMode.UserRead | UnixFileMode.UserWrite); 352await File.WriteAllTextAsync(appHostFile, """ 451await File.ReadAllLinesAsync(captureFile)); 452Assert.False(File.Exists(shadowCaptureFile), "The working-directory Aspire shim was invoked instead of the resolved PATH command."); 492await File.ReadAllLinesAsync(captureFile)); 493Assert.False(File.Exists(shadowCaptureFile), "The working-directory DNX shim was invoked instead of the resolved PATH command."); 530await File.ReadAllLinesAsync(captureFile)); 569await File.ReadAllLinesAsync(captureFile)); 789await File.WriteAllTextAsync(commandShimPath, """ 797await File.WriteAllTextAsync(projectPath, $$""" 830Assert.True(File.Exists(childPidPath), $"The child process did not record its PID. MSBuild output:{Environment.NewLine}{result.Output}"); 832childProcessId = int.Parse(await File.ReadAllTextAsync(childPidPath), CultureInfo.InvariantCulture); 855await File.WriteAllTextAsync( 862File.SetUnixFileMode(commandPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1074await File.WriteAllTextAsync(Path.Combine(projectDirectory, "AppHost.csproj"), 1104return await File.ReadAllLinesAsync(packageReferencesPath); 1126await File.WriteAllTextAsync(projectFile, 1149await File.WriteAllTextAsync(Path.Combine(projectDirectory, "Program.cs"), """ 1225await File.WriteAllTextAsync(aspirePath, """ 1233File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1261await File.WriteAllTextAsync(aspirePath, contents.ReplaceLineEndings(OperatingSystem.IsWindows() ? "\r\n" : "\n")); 1264File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1275File.WriteAllText(Path.Combine(bundle.DcpDirectory, OperatingSystem.IsWindows() ? "dcp.exe" : "dcp"), ""); 1276File.WriteAllText(bundle.ManagedPath, ""); 1295await File.WriteAllTextAsync(aspirePath, """ 1312await File.WriteAllTextAsync(aspirePath, (""" 1320File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1332await File.WriteAllTextAsync(Path.Combine(fakeSdkDirectory.FullName, "dotnet.dll"), ""); 1335await File.WriteAllTextAsync(dnxPath, OperatingSystem.IsWindows() 1370File.SetUnixFileMode(dnxPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1381await File.WriteAllTextAsync(Path.Combine(fakeCliDirectory, "fail-version"), ""); 1385await File.WriteAllTextAsync(dnxPath, (""" 1389File.SetUnixFileMode(dnxPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1396File.Copy(fakeDotNetPath, aspirePath, overwrite: true); 1406File.Copy(sourcePath, Path.Combine(destinationDirectory, Path.GetFileName(sourcePath)), overwrite: true); 1417await File.WriteAllTextAsync( 1433await File.WriteAllTextAsync(Path.Combine(fakeCliDirectory, "aspire.cmd"), $$""" 1446await File.WriteAllTextAsync(aspirePath, ($$""" 1454File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1461await File.WriteAllTextAsync(Path.Combine(fakeCliDirectory, "aspire.cmd"), $$""" 1475await File.WriteAllTextAsync(aspirePath, ($$""" 1488File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1495await File.WriteAllTextAsync(Path.Combine(fakeCliDirectory, "aspire.cmd"), """ 1509await File.WriteAllTextAsync(aspirePath, (""" 1518File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1525await File.WriteAllTextAsync(Path.Combine(fakeCliDirectory, "aspire.cmd"), """ 1543await File.WriteAllTextAsync(aspirePath, (""" 1556File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1563await File.WriteAllTextAsync(Path.Combine(fakeCliDirectory, "aspire.cmd"), """ 1580await File.WriteAllTextAsync(aspirePath, (""" 1587File.SetUnixFileMode(aspirePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1614Assert.True(File.Exists(toolPath), $"Aspire.RuntimeIdentifier.Tool was not built at '{toolPath}'. Build the test project to produce it."); 1626Assert.True(File.Exists(taskAssemblyPath), $"Aspire.Hosting.Tasks was not built at '{taskAssemblyPath}'. Build the test project to produce it."); 1637if (!File.Exists(vswherePath)) 1655.FirstOrDefault(File.Exists); 1665Assert.True(File.Exists(path), $"The file specified by {metadataName} was not built at '{path}'."); 1755File.Exists(Path.Combine(aspireHome, "bundle", "dcp", OperatingSystem.IsWindows() ? "dcp.exe" : "dcp")), 1758File.Exists(Path.Combine(aspireHome, "bundle", "managed", OperatingSystem.IsWindows() ? "aspire-managed.exe" : "aspire-managed")), 1807return executableNames.Any(executableName => File.Exists(Path.Combine(directory.Trim().Trim('"'), executableName))); 1916while (directory is not null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.Hosting.SqlServer.Tests (1)
SqlServerFunctionalTests.cs (1)
172File.SetUnixFileMode(bindMountPath, BindMountPermissions);
Aspire.Hosting.Tasks (10)
CommandPathResolver.cs (2)
71if (!File.Exists(path)) 86return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
ResolveAspireCliBundle.cs (6)
112if (File.Exists(AspireCliPath) && TryResolveFromCliPath(AspireCliPath, out var explicitCliBundle)) 234if (!File.Exists(dcpPath) || !File.Exists(managedPath)) 436if (!File.Exists(sidecarPath)) 448var sidecar = File.ReadAllText(sidecarPath); 476return File.ResolveLinkTarget(path, returnFinalTarget: true)?.FullName ?? path;
ResolveAspireCliInvocation.cs (2)
123if (!File.Exists(dotnetPath) || !TryGetLatestSdkVersion(dotnetPath, out var sdkVersion)) 129if (!File.Exists(sdkPath))
Aspire.Hosting.Testing (2)
src\Shared\LaunchProfiles\LaunchSettingsReader.cs (2)
24if (!File.Exists(launchSettingsFilePath)) 63using var stream = File.OpenRead(launchSettingsFilePath);
Aspire.Hosting.Testing.Tests (6)
TestingBuilderTests.cs (1)
57Assert.True(File.Exists(testProjectAssemblyPath), $"TestProject.AppHost.dll not found at {testProjectAssemblyPath}.");
tests\Aspire.Hosting.TestUtilities\Utils\MSBuildUtils.cs (1)
13while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
129var content = await File.ReadAllTextAsync(logFile, cancellationToken);
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
Aspire.Hosting.Tests (309)
ApplicationModel\Docker\DockerfileBuildAnnotationTests.cs (24)
88Assert.False(File.Exists(dockerfilePath)); 92if (File.Exists(dockerfilePath)) 94File.Delete(dockerfilePath); 122Assert.True(File.Exists(dockerfilePath)); 123var actualContent = await File.ReadAllTextAsync(dockerfilePath); 128if (File.Exists(dockerfilePath)) 130File.Delete(dockerfilePath); 164Assert.True(File.Exists(dockerfilePath)); 168if (File.Exists(dockerfilePath)) 170File.Delete(dockerfilePath); 207Assert.True(File.Exists(dockerfilePath)); 211if (File.Exists(dockerfilePath)) 213File.Delete(dockerfilePath); 224await File.WriteAllTextAsync(dockerfilePath, "FROM scratch"); 226if (!File.Exists(differentCasingDockerfilePath)) 235Assert.Equal("FROM scratch", await File.ReadAllTextAsync(dockerfilePath)); 248await File.WriteAllTextAsync(dockerfilePath, "FROM scratch"); 259Assert.Equal(generatedIgnoreContent, await File.ReadAllTextAsync(perDockerfileIgnore)); 261await File.WriteAllTextAsync(Path.Combine(contextPath, ".dockerignore"), "secrets\n"); 265Assert.False(File.Exists(perDockerfileIgnore)); 278await File.WriteAllTextAsync(dockerfilePath, "FROM scratch"); 279await File.WriteAllTextAsync(Path.Combine(contextPath, ".dockerignore"), "secrets\n"); 283await File.WriteAllTextAsync(perDockerfileIgnore, userIgnoreContent); 292Assert.Equal(userIgnoreContent, await File.ReadAllTextAsync(perDockerfileIgnore));
AspireStoreTests.cs (8)
84Assert.True(File.Exists(filePath)); 85Assert.Equal("Test content", File.ReadAllText(filePath)); 95File.WriteAllText(tempFilename, "Test content"); 98Assert.True(File.Exists(filePath)); 99Assert.Equal("Test content", File.ReadAllText(filePath)); 103File.Delete(tempFilename); 127File.WriteAllText(filePath, "updated"); 131var content2 = File.ReadAllText(filePath2);
Backchannel\AppHostRpcTargetUploadTests.cs (4)
34Assert.Equal(data, await File.ReadAllBytesAsync(filePath)); 39Assert.False(File.Exists(filePath)); 69Assert.Equal(data, await File.ReadAllBytesAsync(filePath)); 162Assert.True(File.Exists(replacementPath));
Backchannel\AuxiliaryBackchannelTests.cs (3)
42Assert.True(File.Exists(service.SocketPath)); 298Assert.True(File.Exists(service.SocketPath), $"Socket file should exist at: {service.SocketPath}"); 634File.WriteAllText(appHostFileViaSymlink, "// apphost");
Backchannel\GetTerminalInfoAsyncTests.cs (1)
456try { File.Delete(SocketPath); } catch { }
Cli\ProcessStartTimeHelperTests.cs (1)
118File.WriteAllText(Path.Combine(statDirectory.FullName, "stat"), $"{pid} (proc name) {string.Join(' ', fields)}");
Dashboard\DashboardEventHandlersTests.cs (19)
565File.Delete(tempDir); 574File.WriteAllText(dashboardDll, "mock dll content"); 597File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 622Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist"); 626var customConfigContent = File.ReadAllText((string)args[2]); 654File.Delete(tempDir); 663File.WriteAllText(dashboardExe, "mock exe content"); 664File.WriteAllText(dashboardDll, "mock dll content"); 680File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 702Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist"); 723File.Delete(tempDir); 732File.WriteAllText(dashboardExe, "mock exe content"); 733File.WriteAllText(dashboardDll, "mock dll content"); 749File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 771Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist"); 792File.Delete(tempDir); 800File.WriteAllText(dashboardDll, "mock dll content"); 816File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 838Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist");
Dashboard\DashboardServiceTests.cs (11)
857Assert.False(File.Exists(filePath)); 883Assert.True(File.Exists(filePath)); 942Assert.True(File.Exists(replacementPath)); 1122await File.WriteAllTextAsync(filePath, "content"); 1123await File.WriteAllTextAsync(secondFilePath, "second content"); 1148Assert.True(File.Exists(filePath)); 1149Assert.True(File.Exists(secondFilePath)); 1159Assert.False(File.Exists(filePath)); 1160Assert.False(File.Exists(secondFilePath)); 1232Assert.True(File.Exists(file.FilePath)); 1235var content = await File.ReadAllBytesAsync(file.FilePath);
Dashboard\InteractionFileUploadStoreTests.cs (23)
31Assert.True(File.Exists(filePath)); 89Assert.True(File.Exists(filePath)); 94Assert.False(File.Exists(filePath)); 114Assert.True(File.Exists(replacementPath)); 140Assert.True(File.Exists(replacementPath)); 159Assert.True(File.Exists(filePath)); 164Assert.False(File.Exists(filePath)); 177Assert.True(File.Exists(filePath)); 182Assert.False(File.Exists(filePath)); 195Assert.True(File.Exists(filePath)); 210Assert.False(File.Exists(filePath)); 224Assert.True(File.Exists(filePath)); 229Assert.False(File.Exists(filePath)); 244Assert.True(File.Exists(filePath)); 261Assert.True(File.Exists(acceptedFilePath)); 263Assert.False(File.Exists(lateFilePath)); 280Assert.True(File.Exists(filePath)); 314Assert.True(File.Exists(filePath)); 364Assert.True(File.Exists(replacementPath)); 512Assert.True(File.Exists(filePath1)); 513Assert.True(File.Exists(filePath2)); 519Assert.False(File.Exists(filePath1)); 520Assert.False(File.Exists(filePath2));
Dcp\DcpExecutorTests.cs (1)
5386return File.GetUnixFileMode(path);
Dcp\DcpHostNotificationTests.cs (3)
525Assert.Equal(certificate.ExportCertificatePem(), File.ReadAllText(certificatePath)); 526Assert.Contains("PRIVATE KEY", File.ReadAllText(keyPath)); 712if (File.Exists(path))
Dcp\KubernetesServiceTests.cs (5)
34Assert.False(File.Exists(kubeconfigPath)); 183File.WriteAllText(tempPath, content); 184File.Move(tempPath, path, overwrite: true); 193File.WriteAllText(path, """ 208File.AppendAllText(path, string.Format(CultureInfo.InvariantCulture, """
DistributedApplicationBuilderTests.cs (6)
178if (File.Exists(userSecretsPath)) 180File.Delete(userSecretsPath); 204File.WriteAllText(assemblyUserSecretsPath, """ 211File.WriteAllText(configuredUserSecretsPath, """ 274if (File.Exists(userSecretsPath)) 276File.Delete(userSecretsPath);
FileSystemServiceTests.cs (24)
71Assert.True(File.Exists(tempFile.Path)); 82Assert.True(File.Exists(tempFile.Path)); 93Assert.True(File.Exists(path)); 97Assert.False(File.Exists(path)); 108Assert.True(File.Exists(filePath)); 113Assert.False(File.Exists(filePath)); 155Assert.True(File.Exists(extractedPath)); 158File.Delete(extractedPath); 194Assert.True(File.Exists(tempFile1.Path)); 195Assert.True(File.Exists(tempFile2.Path)); 226Assert.True(File.Exists(filePath)); 232Assert.False(File.Exists(filePath)); 246Assert.True(File.Exists(filePath)); 253Assert.True(File.Exists(filePath)); 257File.Delete(filePath); 288Assert.True(File.Exists(filePath)); 294Assert.True(File.Exists(filePath)); 297File.Delete(filePath); 321Assert.False(File.Exists(file1Path)); 323Assert.True(File.Exists(file2Path)); 329Assert.False(File.Exists(file2Path)); 359Assert.False(File.Exists(filePath)); 375Assert.True(File.Exists(filePath)); 381Assert.False(File.Exists(filePath));
MSBuildTests.cs (58)
31File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 60File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 88File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 116File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 127var appHostMetadata = await File.ReadAllTextAsync(Path.Combine(metadataDirectory, "_AppHost.ProjectMetadata.g.cs")); 128var appMetadata = await File.ReadAllTextAsync(Path.Combine(metadataDirectory, "App.ProjectMetadata.g.cs")); 155File.WriteAllText(Path.Combine(basePath, "Directory.Build.props"), 167File.WriteAllText(Path.Combine(basePath, "Directory.Build.targets"), 185File.WriteAllText(Path.Combine(libraryDirectory, $"{name}.csproj"), 197File.WriteAllText(Path.Combine(libraryDirectory, "Class1.cs"), 212File.WriteAllText(Path.Combine(appDirectory, $"{name}.csproj"), 223File.WriteAllText(Path.Combine(appDirectory, "Program.cs"), 329File.WriteAllText(projectPath, """ 368var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 392var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 416var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 462var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 487var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 611var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 665var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 690File.WriteAllText(Path.Combine(nativeCliDirectory.FullName, ".aspire-install.json"), """{"source":"dotnet-tool"}"""); 701var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 730var resolvedPaths = await File.ReadAllLinesAsync(Path.Combine(appHostDirectory, "obj", "resolved-aspire-paths.txt")); 786File.Copy(Path.Combine(Environment.SystemDirectory, "where.exe"), dnxPath); 790File.WriteAllText(dnxPath, "#!/bin/sh\nexit 42\n"); 791File.SetUnixFileMode(dnxPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 841File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.fsproj"), 862var property = await File.ReadAllTextAsync(Path.Combine(appHostDirectory, "obj", "aspire-use-cli-bundle.txt")); 887var appMetadata = await File.ReadAllTextAsync(metadataPath); 902File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 940File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 957File.WriteAllText(Path.Combine(basePath, "Directory.Build.props"), 967File.WriteAllText(Path.Combine(basePath, "Directory.Build.targets"), 1002File.WriteAllText(Path.Combine(dcpDir, OperatingSystem.IsWindows() ? "dcp.exe" : "dcp"), ""); 1004File.WriteAllText(managedPath, ""); 1012File.WriteAllText(cliPath, ""); 1041File.WriteAllText(cliPath, contents.ReplaceLineEndings(OperatingSystem.IsWindows() ? "\r\n" : "\n")); 1044File.SetUnixFileMode(cliPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1067File.WriteAllText(cliPath, contents.ReplaceLineEndings(OperatingSystem.IsWindows() ? "\r\n" : "\n")); 1070File.SetUnixFileMode(cliPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1093File.WriteAllText(cliPath, contents.ReplaceLineEndings(OperatingSystem.IsWindows() ? "\r\n" : "\n")); 1096File.SetUnixFileMode(cliPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 1133return executableNames.Any(executableName => File.Exists(Path.Combine(directory.Trim().Trim('"'), executableName))); 1151File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 1180File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 1210File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 1239File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 1263File.WriteAllText(Path.Combine(projectDirectory, "MyHostingExtension.csproj"), 1280File.WriteAllText(Path.Combine(projectDirectory, "Extensions.cs"), 1312File.WriteAllText(Path.Combine(projectDirectory, "MyHostingExtension.csproj"), 1329File.WriteAllText(Path.Combine(projectDirectory, "Extensions.cs"), 1445File.WriteAllText(nuGetConfigPath, 1487File.WriteAllText(Path.Combine(projectDirectory, "MyHostingExtension.csproj"), 1510File.WriteAllText(Path.Combine(projectDirectory, "Extensions.cs"), 1537File.WriteAllText(Path.Combine(basePath, "Directory.Build.props"), 1549File.WriteAllText(Path.Combine(basePath, "Directory.Build.targets"), 1577File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 1605File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"),
PathLookupHelperTests.cs (15)
18File.WriteAllText(executablePath, string.Empty); 53File.WriteAllText(nonExecutablePath, string.Empty); 54File.SetUnixFileMode(nonExecutablePath, UnixFileMode.UserRead | UnixFileMode.UserWrite); 57File.WriteAllText(executablePath, string.Empty); 58File.SetUnixFileMode(executablePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 76File.WriteAllText(Path.Combine(binPath, "mycommand"), string.Empty); 96File.WriteAllText(Path.Combine(binPath, "mycommand.exe"), string.Empty); 218File.WriteAllText(nonExecutablePath, string.Empty); 219File.SetUnixFileMode(nonExecutablePath, UnixFileMode.UserRead | UnixFileMode.UserWrite); 222File.WriteAllText(executablePath, string.Empty); 223File.SetUnixFileMode(executablePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 227if (!File.Exists(path)) 238return (File.GetUnixFileMode(path) & ExecuteBits) != 0; 513File.SetUnixFileMode(path, File.GetUnixFileMode(path) | UnixFileMode.UserExecute);
ProjectResourceTests.cs (5)
67await File.WriteAllTextAsync(projectFilePath, csProjContent).DefaultTimeout(); 70await File.WriteAllTextAsync(launchSettingsFilePath, launchSettingsContent).DefaultTimeout(); 107await File.WriteAllTextAsync(projectFilePath, csProjContent).DefaultTimeout(); 110await File.WriteAllTextAsync(launchSettingsFilePath, launchSettingsContent).DefaultTimeout(); 931var dockerFileContent = File.ReadAllText(dockerfilePath);
PublishAsDockerfileTests.cs (1)
515File.WriteAllText(Path.Join(workspace.Path, "Dockerfile"), "this does not matter");
Publishing\DeploymentStateManagerTests.cs (1)
376var mode = File.GetUnixFileMode(stateDirectory);
Publishing\ResourceContainerImageManagerTests.cs (5)
861if (File.Exists(tempFile)) 863File.Delete(tempFile); 956await File.WriteAllTextAsync(tempSecretFile, "secret-file-content"); 1532await File.WriteAllTextAsync(dockerfilePath, """ 1582File.Exists(expectedArchivePath),
ResourceCommandServiceTests.cs (2)
1700File.WriteAllText(projectPath, 1716File.WriteAllText(programPath,
Schema\SchemaTests.cs (4)
63File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here"); 75File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here"); 93File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here"); 124File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here");
SecretsStoreTests.cs (5)
80if (!File.Exists(manager.FilePath)) 97if (File.Exists(filePath)) 99File.Delete(filePath); 106if (File.Exists(userSecretsPath)) 108File.Delete(userSecretsPath);
tests\Shared\TestFileSystemService.cs (1)
37File.Create(filePath).Dispose();
UserSecretsParameterDefaultTests.cs (10)
69if (File.Exists(userSecretsPath)) 71File.Delete(userSecretsPath); 80File.WriteAllText(userSecretsPath, secretsFileContents, Encoding.UTF8); 363var json = File.ReadAllText(manager.FilePath); 391if (File.Exists(manager.FilePath)) 393var json = File.ReadAllText(manager.FilePath); 415if (File.Exists(filePath)) 417File.Delete(filePath); 424if (File.Exists(userSecretsPath)) 426File.Delete(userSecretsPath);
WithTerminalTests.cs (69)
329File.Exists(host.Layout.MetadataPath), 334File.WriteAllText(host.Layout.ProducerUdsPath, string.Empty); 335File.WriteAllText(host.Layout.ConsumerUdsPath, string.Empty); 336File.WriteAllText(host.Layout.ControlUdsPath, string.Empty); 343Assert.False(File.Exists(path), $"Expected '{path}' to be deleted after ApplicationStopped."); 379Assert.True(File.Exists(host.Layout.MetadataPath)); 381using var doc = JsonDocument.Parse(await File.ReadAllTextAsync(host.Layout.MetadataPath)); 405Assert.False(File.Exists(TerminalHostPaths.GetMetadataTemporaryPath(host.Layout.MetadataPath))); 410var mode = File.GetUnixFileMode(host.Layout.MetadataPath); 449File.WriteAllText(orphanProducerPath, string.Empty); 450File.WriteAllText(orphanConsumerPath, string.Empty); 451File.WriteAllText(orphanControlPath, string.Empty); 465Assert.False(File.Exists(orphanMetadataPath), "Dead-owner sidecar should be swept on startup."); 466Assert.False(File.Exists(orphanProducerPath), "Dead-owner producer socket should be swept on startup."); 467Assert.False(File.Exists(orphanConsumerPath), "Dead-owner consumer socket should be swept on startup."); 468Assert.False(File.Exists(orphanControlPath), "Dead-owner control socket should be swept on startup."); 503File.WriteAllText(liveProducerPath, string.Empty); 517Assert.True(File.Exists(liveMetadataPath), "Live-owner sidecar must be preserved by the sweep."); 518Assert.True(File.Exists(liveProducerPath), "Live-owner socket must be preserved by the sweep."); 552File.WriteAllText(producerPath, string.Empty); 558Assert.False(File.Exists(metadataPath)); 559Assert.False(File.Exists(producerPath)); 587File.WriteAllText(producerPath, string.Empty); 588File.WriteAllText(sentinelPath, string.Empty); 589File.SetLastWriteTimeUtc( 597Assert.True(File.Exists(metadataPath)); 598Assert.True(File.Exists(producerPath)); 599Assert.True(File.Exists(sentinelPath), "Metadata content must never be used as a file search pattern."); 617File.WriteAllText(metadataPath, """{"schemaVersion":"""); 618File.WriteAllText(producerPath, string.Empty); 624Assert.True(File.Exists(metadataPath)); 625Assert.True(File.Exists(producerPath)); 643File.WriteAllText(metadataPath, """{"schemaVersion":"""); 644File.WriteAllText(producerPath, string.Empty); 645File.SetLastWriteTimeUtc( 651Assert.True(File.Exists(metadataPath)); 652Assert.True(File.Exists(producerPath)); 661File.WriteAllText(metadataPath, """{"schemaVersion":"""); 662File.SetLastWriteTimeUtc( 668Assert.False(File.Exists(metadataPath)); 681File.WriteAllText(expiredPath, string.Empty); 682File.WriteAllText(recentPath, string.Empty); 683File.SetLastWriteTimeUtc( 691Assert.False(File.Exists(expiredPath)); 692Assert.True(File.Exists(recentPath)); 717File.WriteAllText(producerPath, string.Empty); 723Assert.True(File.Exists(metadataPath)); 724Assert.True(File.Exists(producerPath)); 747File.WriteAllText(producerPath, string.Empty); 748File.SetLastWriteTimeUtc( 756Assert.True(File.Exists(metadataPath)); 757Assert.True(File.Exists(producerPath)); 783File.WriteAllText(producerPath, string.Empty); 787Assert.True(File.Exists(metadataPath)); 788Assert.True(File.Exists(producerPath)); 809File.WriteAllText(producerPath, string.Empty); 813Assert.True(File.Exists(metadataPath)); 814Assert.True(File.Exists(producerPath)); 836File.WriteAllText(producerPath, string.Empty); 840Assert.True(File.Exists(metadataPath)); 841Assert.True(File.Exists(producerPath)); 867File.WriteAllText(producerPath, string.Empty); 871Assert.False(File.Exists(metadataPath)); 872Assert.False(File.Exists(producerPath)); 885File.WriteAllText(metadataPath, "{}"); 891Assert.True(File.Exists(metadataPath)); 896File.Delete(metadataPath); 991File.WriteAllText(metadataPath, JsonSerializer.Serialize(metadata)); 1027File.Delete(path);
Aspire.Hosting.TestUtilities (5)
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
129var content = await File.ReadAllTextAsync(logFile, cancellationToken);
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Utils\DockerfileUtils.cs (1)
55await File.WriteAllTextAsync(tempDockerfilePath, dockerfileContent);
Utils\DotnetFileAppProcess.cs (1)
18File.WriteAllText(appPath, content);
Utils\MSBuildUtils.cs (1)
13while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
Aspire.Hosting.Yarp (1)
YarpJsonConfigGeneratorBuilder.cs (1)
66return await File.ReadAllTextAsync(_configFilePath, ct).ConfigureAwait(false);
Aspire.Hosting.Yarp.Tests (2)
YarpConfigGeneratorTests.cs (2)
293Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 295var content = await File.ReadAllTextAsync(composeFile);
Aspire.Managed.Tests (9)
NuGet\RestoreCommandTests.cs (5)
22File.WriteAllText(nugetConfigPath, $""" 46var assetsContent = File.ReadAllText(Path.Combine(_workspace.Path, "obj", "project.assets.json")); 69var assetsContent = File.ReadAllText(Path.Combine(_workspace.Path, "obj", "project.assets.json")); 80File.WriteAllText(nugetConfigPath, $""" 111var assetsContent = File.ReadAllText(Path.Combine(_workspace.Path, "obj", "project.assets.json"));
TerminalHostSignalTests.cs (3)
68Assert.All(socketPaths, path => Assert.False(File.Exists(path), $"Expected '{path}' to be unlinked.")); 166Assert.All(socketPaths, path => Assert.False(File.Exists(path), $"Expected '{path}' to be unlinked.")); 238while (expectedPaths.Any(path => !File.Exists(path)))
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.Playground.Tests (6)
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
tests\Aspire.TestUtilities\TestcontainersPodmanConfiguration.cs (1)
288private static bool SocketExists(string? path) => !string.IsNullOrEmpty(path) && File.Exists(path);
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
Aspire.RuntimeIdentifier.Tool (1)
Program.cs (1)
49if (!File.Exists(rgp))
Aspire.Templates.Tests (40)
AppHostTemplateTests.cs (2)
30var newContents = AppHostPackageReferenceRegex().Replace(File.ReadAllText(projectPath), @"$1""8.1.0"""); 32File.WriteAllText(projectPath, newContents);
BuildAndRunTemplateTests.cs (8)
70var projectContents = File.ReadAllText(projectName); 74File.WriteAllText( 107File.WriteAllText(cpmFilePath, cpmContent); 134var projectContents = File.ReadAllText(projectName); 140File.WriteAllText( 151File.WriteAllText( 234var projectContents = File.ReadAllText(projectName); 238File.WriteAllText(projectName, modifiedContents);
LocalhostTldHostnameTests.cs (2)
74Assert.True(File.Exists(launchSettingsPath), $"launchSettings.json/apphost.run.json file not found at {launchSettingsPath}"); 76var launchSettingsContent = await File.ReadAllTextAsync(launchSettingsPath);
NewUpAndBuildStandaloneTemplateTests.cs (5)
59var appContent = await File.ReadAllTextAsync(Path.Combine(webProjectDirectory, "Components", "App.razor")); 63var importsContent = await File.ReadAllTextAsync(Path.Combine(webProjectDirectory, "Components", "_Imports.razor")); 66var errorPageContent = await File.ReadAllTextAsync(Path.Combine(webProjectDirectory, "Components", "Pages", "Error.razor")); 69var navMenuContent = await File.ReadAllTextAsync(Path.Combine(webProjectDirectory, "Components", "Layout", "NavMenu.razor")); 76Assert.True(File.Exists(Path.Combine(webProjectDirectory, "Components", "Layout", "NavMenu.razor.js")));
TemplateTestsBase.cs (5)
75Assert.True(File.Exists(testProjectPath), $"Expected tests project file at {testProjectPath}"); 104var newContents = File.ReadAllText(projectPath) 106File.WriteAllText(projectPath, newContents); 124foreach (var line in File.ReadAllLines(testCsPath)) 142File.WriteAllText(testCsPath, sb.ToString());
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
tests\Shared\TemplatesTesting\AspireProject.cs (9)
65File.WriteAllText(Path.Combine(dir, "Directory.Build.props"), "<Project />"); 66File.WriteAllText(Path.Combine(dir, "Directory.Build.targets"), "<Project />"); 73File.Copy(srcNuGetConfigPath, targetNuGetConfigPath); 107File.WriteAllText(Path.Combine(rootDir, "Directory.Build.props"), "<Project />"); 108File.WriteAllText(Path.Combine(rootDir, "Directory.Build.targets"), "<Project />"); 133var csprojContent = File.ReadAllText(csprojPath); 153File.Copy(Path.Combine(BuildEnvironment.TestAssetsPath, "EndPointWriterHook_cs"), Path.Combine(project.AppHostProjectDirectory, "EndPointWriterHook.cs")); 155string programCs = File.ReadAllText(programCsPath); 158File.WriteAllText(programCsPath, programCs);
tests\Shared\TemplatesTesting\BuildEnvironment.cs (2)
103.FirstOrDefault(File.Exists); 126.FirstOrDefault(File.Exists);
tests\Shared\TemplatesTesting\TemplateCustomHive.cs (4)
18public string CustomHiveDirectory => File.Exists(_stampFilePath) 37if (BuildEnvironment.IsRunningOnCI && File.Exists(_stampFilePath)) 51if (File.Exists(_stampFilePath)) 80File.WriteAllText(_stampFilePath, "");
Aspire.TerminalHost (10)
src\Shared\ProcessStartTimeHelper.cs (1)
345contents = File.ReadAllText(statPath);
TerminalHostControlListener.cs (5)
59if (File.Exists(_socketPath)) 63File.Delete(_socketPath); 86File.SetUnixFileMode(_socketPath, UnixFileMode.UserRead | UnixFileMode.UserWrite); 107try { File.Delete(_socketPath); } catch { } 325File.Delete(_socketPath);
TerminalReplica.cs (4)
580if (File.Exists(path)) 584File.SetUnixFileMode(path, UnixFileMode.UserRead | UnixFileMode.UserWrite); 615if (File.Exists(path)) 617File.Delete(path);
Aspire.TerminalHost.Tests (13)
TerminalHostAppTests.cs (12)
59Assert.True(File.Exists(control)); 260File.WriteAllBytes(args.ProducerUdsPath, []); 261File.WriteAllBytes(args.ConsumerUdsPath, []); 262Assert.True(File.Exists(args.ProducerUdsPath)); 263Assert.True(File.Exists(args.ConsumerUdsPath)); 405Assert.True(File.Exists(args.ProducerUdsPath), "Producer socket should be bound while the replica waits."); 406Assert.True(File.Exists(args.ConsumerUdsPath), "Consumer socket should be bound while the replica waits."); 418File.Exists(args.ProducerUdsPath), 421File.Exists(args.ConsumerUdsPath), 837var mode = File.GetUnixFileMode(control); 912last = File.GetUnixFileMode(path); 934if (File.Exists(path))
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
Aspire.TestTools (10)
GitHubCli.cs (10)
32return File.ReadAllTextAsync(fixturePath, cancellationToken); 37return File.ReadAllTextAsync(fixturePath, cancellationToken); 42return Task.FromException<string>(new InvalidOperationException(File.ReadAllText(fixturePath))); 66File.Copy(fixturePath, outputPath, overwrite: true); 219if (File.Exists(fixturePath)) 221content = File.ReadAllText(fixturePath); 320using var outputStream = File.Create(outputPath); 344if (File.Exists(outputPath)) 346File.Delete(outputPath); 382return File.Exists(fixturePath);
Aspire.TestUtilities (3)
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
TestcontainersPodmanConfiguration.cs (1)
288private static bool SocketExists(string? path) => !string.IsNullOrEmpty(path) && File.Exists(path);
AzureSearch.ApiService (1)
Program.cs (1)
148using var openStream = File.OpenRead(hotelsJson);
blazor-devserver (1)
Server\Program.cs (1)
30name = !File.Exists(name) ? Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml") : name;
CatalogService (1)
CatalogApi.cs (1)
42if (!File.Exists(path))
cdac-build-tool (3)
ComposeCommand.cs (1)
61if (!System.IO.File.Exists(templateFilePath))
ContractDescriptorSourceFileEmitter.cs (1)
31return File.ReadAllText(_templateFilePath);
ObjectFileScraper.cs (1)
31var bytes = await File.ReadAllBytesAsync(inputPath, token).ConfigureAwait(false);
CodeStyleConfigFileGenerator (2)
Program.cs (2)
92File.WriteAllText(configFilePath, text); 206File.WriteAllText(fileWithPath, $@"<Project>{GetTargetContents(language)}
ConfigurationSchemaGenerator (1)
ConfigSchemaGenerator.cs (1)
44File.WriteAllText(outputFile, schema);
ConfigurationSchemaGenerator.Tests (3)
GeneratorTests.cs (3)
42private static readonly SyntaxTree s_attributesSyntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText("ConfigurationSchemaAttributes.cs")); 1601var actual = File.ReadAllText(outputPath); 1606var baseline = File.ReadAllText(Path.Combine("Baselines", "IntegrationTest.baseline.json")).ReplaceLineEndings();
crossgen2 (5)
Program.cs (2)
315System.IO.File.Move(tmpOutFile, outFile); 624byte[] compositeStrongNameKey = File.ReadAllBytes(compositeKeyFile);
src\runtime\src\coreclr\tools\Common\CommandLineHelpers.cs (3)
204details.AddRange(File.ReadAllLines(rspFileName)); 351&& File.Exists(originalPdbPath)) 431foreach (string line in File.ReadAllLines(filePath))
Crossgen2Tasks (13)
PrepareForReadyToRunCompilation.cs (1)
120!string.IsNullOrEmpty(diaSymReaderPath) && File.Exists(diaSymReaderPath);
ResolveReadyToRunCompilers.cs (4)
390return File.Exists(_crossgenTool.ToolPath) && File.Exists(_crossgenTool.ClrJitPath); 418if (!File.Exists(_crossgen2Tool.ClrJitPath)) 425return File.Exists(_crossgen2Tool.ToolPath);
RunReadyToRunCompiler.cs (8)
103if (!File.Exists(Crossgen2Tool.ItemSpec)) 109if (!string.IsNullOrEmpty(hostPath) && !File.Exists(hostPath)) 117if (!File.Exists(jitPath)) 151if (!File.Exists(CrossgenTool.ItemSpec)) 156if (!File.Exists(CrossgenTool.GetMetadata(MetadataKeys.JitPath))) 169if (!string.IsNullOrEmpty(DiaSymReader) && !File.Exists(DiaSymReader)) 181if (!File.Exists(_outputR2RImage)) 194if (!File.Exists(_inputAssembly))
csc (6)
src\roslyn\src\Compilers\Shared\BuildServerConnection.cs (4)
455if (!File.Exists(processFilePath)) 556if (!File.Exists(serverInfo.processFilePath)) 848if (!File.Exists(FilePath)) 878File.Delete(FilePath);
src\roslyn\src\Compilers\Shared\RuntimeHostInfo.cs (2)
54var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 102if (File.Exists(filePath))
CSharpSyntaxGenerator (3)
Program.cs (3)
72if (!File.Exists(inputFile)) 106using var outFile = new StreamWriter(File.Open(outputMainFile, FileMode.Create), Encoding.UTF8); 177using var outFile = new StreamWriter(File.Open(outputFile, FileMode.Create), Encoding.UTF8);
datacollector (2)
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
datacollector.arm64 (2)
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
dotnet (179)
BuildServer\VBCSCompilerServer.cs (1)
49if (File.Exists(vbcsCompilerPath))
CommandFactory\CommandResolution\AppBaseDllCommandResolver.cs (1)
23if (File.Exists(localPath))
CommandFactory\CommandResolution\MSBuildProject.cs (2)
166if (!File.Exists(lockFilePath)) 183.FirstOrDefault(p => Path.IsPathRooted(p) && File.Exists(p));
CommandFactory\CommandResolution\PackagedCommandSpecFactory.cs (1)
53if (!File.Exists(commandPath))
CommandFactory\CommandResolution\PackagedCommandSpecFactoryWithCliRuntime.cs (2)
22if (!File.Exists(runtimeConfigFile)) 77return File.Exists(preferCliRuntimePath);
CommandFactory\CommandResolution\ProjectDependenciesCommandResolver.cs (2)
97if (!File.Exists(depsFilePath)) 108if (!File.Exists(runtimeConfigPath))
CommandFactory\CommandResolution\ProjectToolsCommandResolver.cs (6)
235lockedToken => Task.FromResult(File.Exists(path)), 308if (!File.Exists(depsPath)) 322!File.Exists(toolDepsJsonGeneratorProject)) 374File.Delete(tempDepsFile); 439File.Move(tempDepsFile, depsPath); 449File.Delete(tempDepsFile);
CommandFactory\CommandResolution\PublishedPathCommandResolver.cs (2)
39if (!File.Exists(depsFilePath)) 49if (!File.Exists(runtimeConfigPath))
Commands\Fsi\FsiForwardingApp.cs (1)
32return File.Exists(path);
Commands\Help\HelpCommand.cs (3)
66var fileName = File.Exists(@"/usr/bin/xdg-open") ? @"/usr/bin/xdg-open" : 67File.Exists(@"/usr/sbin/xdg-open") ? @"/usr/sbin/xdg-open" : 68File.Exists(@"/sbin/xdg-open") ? @"/sbin/xdg-open" :
Commands\New\BuiltInTemplatePackageProvider.cs (1)
38packages.Add(new TemplatePackage(this, nupkgPath, File.GetLastWriteTime(nupkgPath)));
Commands\New\MSBuildEvaluation\MSBuildEvaluator.cs (1)
205if (!File.Exists(projectToLoad))
Commands\Package\Add\PackageAddCommand.cs (3)
34if (!File.Exists(fileOrDirectory)) 136if (File.Exists(filePath)) 138File.Delete(filePath);
Commands\Package\List\PackageListCommand.cs (1)
180if (!File.Exists(resultPath))
Commands\Package\Remove\PackageRemoveCommand.cs (1)
38if (!File.Exists(fileOrDirectory))
Commands\Project\Convert\ProjectConvertCommand.cs (5)
187using var stream = File.Open(projectFile, FileMode.Create, FileAccess.Write); 223File.Copy(source, target); 235File.Delete(path); 247if (File.Exists(targetItemFullPath)) 369if (!File.Exists(itemFullPath))
Commands\Run\CSharpCompilerCommand.cs (12)
134File.Copy(objFile.FullName, binFile.FullName, overwrite: true); 213File.WriteAllLines(rspPath, cscArguments); 239File.WriteAllText(assemblyAttributes, GetAssemblyAttributesContent()); 245File.WriteAllText(globalUsings, GetGlobalUsingsContent()); 251File.WriteAllText(assemblyInfo, GetAssemblyInfoContent()); 257File.WriteAllText(editorconfig, GetGeneratedMSBuildEditorConfigContent()); 276File.WriteAllText(runtimeConfig, GetRuntimeConfigContent()); 285File.WriteAllLines(rspPath, args.Select(EscapeSingleArg)); 295if (!File.Exists(file)) 356if (!File.Exists(runtimeConfigPath)) return null; 358using var stream = File.OpenRead(runtimeConfigPath); 413if (!File.Exists(frameworkListPath))
Commands\Run\EnvironmentVariablesToMSBuild.cs (3)
111using (var stream = File.Create(propsFilePath)) 125if (propsFilePath is not null && File.Exists(propsFilePath)) 129File.Delete(propsFilePath);
Commands\Run\FileBasedAppRunPlan.cs (5)
113if (!File.Exists(entryPointFileFullPath)) 259if (!File.Exists(filePath)) 295using var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); 322if (File.Exists(implicitBuildFilePath)) 449!File.Exists(previousRunCommand))
Commands\Run\RunCommand.cs (1)
726if (projectFilePath is not null && !emptyProjectOption && !File.Exists(projectFilePath))
Commands\Run\VirtualProjectBuildingCommand.cs (3)
526File.WriteAllText(path: resultOutputFile, contents: result + Environment.NewLine); 706File.WriteAllText(Path.Join(directory, FileBasedAppRunPlan.BuildStartCacheFileName), Builder.EntryPointFileFullPath); 717using var stream = File.Open(successCacheFile, FileMode.Create, FileAccess.Write, FileShare.None);
Commands\Sdk\Check\SdkCheckCommand.cs (2)
35_sdkCheckConfig = File.Exists(configFilePath) ? JsonSerializer.Deserialize(File.ReadAllText(configFilePath), SdkCheckJsonSerializerContext.Default.SdkCheckConfig) : null;
Commands\Test\MTP\ArtifactPostProcessingManager.cs (1)
312using FileStream stream = File.Create(manifestPath);
Commands\Test\MTP\Logger.cs (1)
104using StreamWriter logFile = File.AppendText(_traceFilePath!);
Commands\Test\MTP\MicrosoftTestingPlatformTestCommand.cs (2)
404if (!recursionStack.Add(fullPath) || !File.Exists(fullPath)) 412File.ReadAllLines(fullPath)
Commands\Test\MTP\MSBuildUtility.cs (3)
372token.EndsWith(".slnx", StringComparison.OrdinalIgnoreCase)) && File.Exists(token)) 385else if (Path.GetExtension(token).EndsWith("proj", StringComparison.OrdinalIgnoreCase) && File.Exists(token)) 417File.Exists(token))
Commands\Test\MTP\SolutionAndProjectUtility.cs (2)
724bool hasLaunchSettings = File.Exists(launchSettingsPath); 727bool hasRunJson = File.Exists(runJsonPath);
Commands\Test\MTP\Terminal\FileUtilities.cs (1)
26return !File.Exists(lowerCased);
Commands\Test\MTP\TestApplication.cs (2)
490File.Delete(path); 1146File.Delete(_httpResponseFilePath);
Commands\Test\MTP\ValidationUtility.cs (1)
149if (!File.Exists(filePath))
Commands\Test\VSTest\VSTestTrace.cs (1)
37using StreamWriter logFile = File.AppendText(s_traceFilePath);
Commands\Tool\Install\ToolInstallGlobalOrToolPathCommand.cs (2)
176if (!string.IsNullOrEmpty(_configFilePath) && !File.Exists(_configFilePath)) 303if (!string.IsNullOrEmpty(_configFilePath) && !File.Exists(_configFilePath))
Commands\Tool\Install\ToolInstallLocalInstaller.cs (1)
28if (!string.IsNullOrEmpty(configFilePath) && !File.Exists(configFilePath))
Commands\Workload\FileBasedWorkloadInstallationRecordRepositoryFactory.cs (1)
27=> File.Exists(Path.Combine(dotnetDir, "metadata", "workloads", sdkFeatureBand.ToString(), "userlocal"));
Commands\Workload\GlobalJsonWorkloadSetFile.cs (2)
21using (var fileStream = File.Open(Path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) 45return File.Open(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
Commands\Workload\Install\FileBasedInstaller.cs (18)
181if (!File.Exists(packagePath)) 204File.Copy(packagePath, packInfo.Path, overwrite: overwriteExistingPacks); 252if (File.Exists(file)) 254File.Delete(file); 323if (!File.Exists(packagePath)) 363if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath) && (offlineCache == null || !offlineCache.HasValue)) 365File.Delete(packagePath); 536var jsonPackInfo = File.ReadAllText(GetPackInstallRecordPath(packId, packVersion, featureBandsToRemove.First())); 540File.Delete(GetPackInstallRecordPath(packId, packVersion, featureBand)); 598File.WriteAllText(path, installStateContents.ToString()); 639File.WriteAllText(logFile, JsonSerializer.Serialize(workloadHistoryRecord, WorkloadHistoryJsonSerializerContext.Default.WorkloadHistoryRecord)); 664return File.Exists(packInfo.Path); 679File.Delete(packInfo.Path); 704using var _ = File.Create(path); 755using var _ = File.Create(path); 848File.WriteAllText(path, JsonSerializer.Serialize(packInfo, PackInfoJsonSerializerContext.Default.PackInfo)); 854if (File.Exists(packInstallRecord)) 856File.Delete(packInstallRecord);
Commands\Workload\Install\WorkloadAdvertisingManifestUpdater.cs (19)
89if (File.Exists(sentinelPath)) 91File.SetLastAccessTime(sentinelPath, DateTime.Now); 95File.Create(sentinelPath).Close(); 103var installStateContents = File.Exists(path) ? InstallStateContents.FromString(File.ReadAllText(path)) : new InstallStateContents(); 114File.WriteAllText(filePath, jsonContent); 120if (File.Exists(filePath)) 122File.Delete(filePath); 130if (File.Exists(workloadSetVersionFilePath)) 132return File.ReadAllText(workloadSetVersionFilePath); 222File.WriteAllText(Path.Combine(adManifestPath, "AdvertisedManifestFeatureBand.txt"), band.ToString()); 235File.WriteAllText(Path.Combine(adManifestPath, Constants.workloadSetVersionFileName), workloadSetVersion); 252if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath) && (offlineCache == null || !offlineCache.HasValue)) 254File.Delete(packagePath); 292if (!File.Exists(manifestPath)) 304if (File.Exists(adManifestFeatureBandPath)) 306adManifestFeatureBand = new SdkFeatureBand(File.ReadAllText(adManifestFeatureBandPath)); 329if (File.Exists(sentinelPath)) 331var lastAccessTime = File.GetLastAccessTime(sentinelPath);
Commands\Workload\Install\WorkloadInstallerFactory.cs (1)
105using FileStream fs = File.Create(testPath, 1, FileOptions.DeleteOnClose);
Commands\Workload\Install\WorkloadInstallRecords\FileBasedInstallationRecordInstaller.cs (4)
47if (!File.Exists(path)) 54File.Create(path).Close(); 61if (File.Exists(path)) 63File.Delete(path);
Commands\Workload\Install\WorkloadManifestUpdater.cs (2)
99if (!backgroundUpdatesDisabled && File.Exists(adUpdatesFile)) 101var updatableWorkloads = JsonSerializer.Deserialize(File.ReadAllText(adUpdatesFile), WorkloadManifestUpdaterJsonSerializerContext.Default.StringArray);
Commands\Workload\Install\WorkloadManifestUpdater.Managed.cs (2)
193else if (File.Exists(rollbackDefinitionFilePath)) 195fileContent = File.ReadAllText(rollbackDefinitionFilePath);
Commands\Workload\InstallStateContents.cs (2)
31return File.Exists(path) ? FromString(File.ReadAllText(path)) : new InstallStateContents();
MsbuildProject.cs (2)
55if (File.Exists(fileOrDirectory)) 67if (!File.Exists(projectPath))
NugetPackageDownloader\NuGetPackageDownloader.cs (3)
192using FileStream destinationStream = File.Create(nupkgPath); 216File.Delete(nupkgPath); 324await using FileStream packageStream = File.OpenRead(packagePath);
Parser.cs (2)
311if (File.Exists(filePath)) 313var lines = File.ReadAllLines(filePath);
ReleasePropertyProjectLocator.cs (2)
269return File.Exists(path) && Path.GetExtension(path).EndsWith("proj"); 275return File.Exists(path) && (Path.GetExtension(path).Equals(".sln") || Path.GetExtension(path).Equals(".slnx"));
RuntimeConfig.cs (1)
23using (var stream = File.OpenRead(runtimeConfigPath))
SdkVulnerability\SdkReleaseMetadataCache.cs (9)
60if (File.Exists(sentinelPath)) 62var lastWriteTime = File.GetLastWriteTimeUtc(sentinelPath); 84if (!File.Exists(summaryPath)) 91var json = File.ReadAllText(summaryPath); 158File.WriteAllText(tempPath, json); 159File.Move(tempPath, summaryPath, overwrite: true); 176if (File.Exists(sentinelPath)) 178File.SetLastWriteTimeUtc(sentinelPath, DateTime.UtcNow); 182File.Create(sentinelPath).Close();
ShellShim\ShellShimRepository.cs (3)
74File.WriteAllText(shimPath, batchContent); 78File.CreateSymbolicLink(shimPath, relativePathToExe); 111File.Delete(file.Value);
SlnfFileHelper.cs (2)
88File.WriteAllText(slnfPath, json); 121File.WriteAllText(slnfPath, json);
SlnFileFactory.cs (2)
28if (File.Exists(slnFileOrDirectory)) 98string fileContent = File.ReadAllText(filteredSolutionPath);
src\sdk\artifacts\.packages\microsoft.codeanalysis.buildclient\5.11.0-1.26425.101\contentFiles\cs\net11.0\BuildServerConnection.cs (4)
455if (!File.Exists(processFilePath)) 556if (!File.Exists(serverInfo.processFilePath)) 848if (!File.Exists(FilePath)) 878File.Delete(FilePath);
src\sdk\artifacts\.packages\microsoft.codeanalysis.buildclient\5.11.0-1.26425.101\contentFiles\cs\net11.0\RuntimeHostInfo.cs (2)
54var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 102if (File.Exists(filePath))
src\sdk\src\Common\SdkVulnerabilityCacheReader.cs (2)
49if (!File.Exists(summaryPath)) 56string json = File.ReadAllText(summaryPath);
src\sdk\src\Common\WorkloadFileBasedInstall.cs (3)
16=> dotnetDir is not null && File.Exists(GetUserInstallFilePath(dotnetDir, sdkFeatureBand)); 23File.WriteAllText(filePath, ""); 61var historyRecord = JsonSerializer.Deserialize(File.ReadAllText(file), WorkloadHistoryJsonSerializerContext.Default.WorkloadHistoryRecord);
SudoEnvironmentDirectoryOverride.cs (4)
65.FirstOrDefault(f => File.Exists(f)); 70if (File.Exists(overriddenNugetConfig)) 75() => File.Delete(overriddenNugetConfig)); 88() => File.Copy(userNuGetConfig, overriddenNugetConfig, overwrite: true));
Telemetry\DevDeviceIDGetter.cs (5)
63if (File.Exists(cacheFilePath)) 65deviceId = File.ReadAllText(cacheFilePath); 72if (File.Exists(cacheFilePath)) 74deviceId = File.ReadAllText(cacheFilePath); 129File.WriteAllText(filePath, content);
Telemetry\DockerContainerDetectorForTelemetry.cs (1)
36bool isDocker = File
Telemetry\TelemetryDiskLogger.cs (3)
54var jsonText = !File.Exists(logPath) ? """{"activities":[]}""" : File.ReadAllText(logPath); 63File.WriteAllText(logPath, root.ToJsonString(s_jsonOptions));
ToolPackage\ToolPackageDownloader.cs (2)
79using (FileStream packageStream = File.OpenRead(packagePath)) 88File.WriteAllText(hashPath, packageHash);
dotnet-aot (72)
NativeEntryPoint.cs (2)
255if (File.Exists(dotnetDll) && File.Exists(runtimeConfig))
src\sdk\src\Cli\dotnet\CommandFactory\CommandResolution\AppBaseDllCommandResolver.cs (1)
23if (File.Exists(localPath))
src\sdk\src\Cli\dotnet\CommandFactory\CommandResolution\PublishedPathCommandResolver.cs (2)
39if (!File.Exists(depsFilePath)) 49if (!File.Exists(runtimeConfigPath))
src\sdk\src\Cli\dotnet\Commands\Fsi\FsiForwardingApp.cs (1)
32return File.Exists(path);
src\sdk\src\Cli\dotnet\Commands\Run\AotRunCommand.cs (1)
263using var stream = File.OpenRead(Path.Join(SdkPaths.SdkDirectory, "dotnet.runtimeconfig.json"));
src\sdk\src\Cli\dotnet\Commands\Run\FileBasedAppRunPlan.cs (5)
113if (!File.Exists(entryPointFileFullPath)) 259if (!File.Exists(filePath)) 295using var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); 322if (File.Exists(implicitBuildFilePath)) 449!File.Exists(previousRunCommand))
src\sdk\src\Cli\dotnet\Commands\Sdk\Check\SdkCheckCommand.cs (2)
35_sdkCheckConfig = File.Exists(configFilePath) ? JsonSerializer.Deserialize(File.ReadAllText(configFilePath), SdkCheckJsonSerializerContext.Default.SdkCheckConfig) : null;
src\sdk\src\Cli\dotnet\Commands\Test\VSTest\VSTestTrace.cs (1)
37using StreamWriter logFile = File.AppendText(s_traceFilePath);
src\sdk\src\Cli\dotnet\Commands\Workload\FileBasedWorkloadInstallationRecordRepositoryFactory.cs (1)
27=> File.Exists(Path.Combine(dotnetDir, "metadata", "workloads", sdkFeatureBand.ToString(), "userlocal"));
src\sdk\src\Cli\dotnet\Commands\Workload\Install\WorkloadAdvertisingManifestUpdater.cs (19)
89if (File.Exists(sentinelPath)) 91File.SetLastAccessTime(sentinelPath, DateTime.Now); 95File.Create(sentinelPath).Close(); 103var installStateContents = File.Exists(path) ? InstallStateContents.FromString(File.ReadAllText(path)) : new InstallStateContents(); 114File.WriteAllText(filePath, jsonContent); 120if (File.Exists(filePath)) 122File.Delete(filePath); 130if (File.Exists(workloadSetVersionFilePath)) 132return File.ReadAllText(workloadSetVersionFilePath); 222File.WriteAllText(Path.Combine(adManifestPath, "AdvertisedManifestFeatureBand.txt"), band.ToString()); 235File.WriteAllText(Path.Combine(adManifestPath, Constants.workloadSetVersionFileName), workloadSetVersion); 252if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath) && (offlineCache == null || !offlineCache.HasValue)) 254File.Delete(packagePath); 292if (!File.Exists(manifestPath)) 304if (File.Exists(adManifestFeatureBandPath)) 306adManifestFeatureBand = new SdkFeatureBand(File.ReadAllText(adManifestFeatureBandPath)); 329if (File.Exists(sentinelPath)) 331var lastAccessTime = File.GetLastAccessTime(sentinelPath);
src\sdk\src\Cli\dotnet\Commands\Workload\Install\WorkloadInstallRecords\FileBasedInstallationRecordInstaller.cs (4)
47if (!File.Exists(path)) 54File.Create(path).Close(); 61if (File.Exists(path)) 63File.Delete(path);
src\sdk\src\Cli\dotnet\Commands\Workload\Install\WorkloadManifestUpdater.cs (2)
99if (!backgroundUpdatesDisabled && File.Exists(adUpdatesFile)) 101var updatableWorkloads = JsonSerializer.Deserialize(File.ReadAllText(adUpdatesFile), WorkloadManifestUpdaterJsonSerializerContext.Default.StringArray);
src\sdk\src\Cli\dotnet\Commands\Workload\InstallStateContents.cs (2)
31return File.Exists(path) ? FromString(File.ReadAllText(path)) : new InstallStateContents();
src\sdk\src\Cli\dotnet\MsbuildProject.cs (2)
55if (File.Exists(fileOrDirectory)) 67if (!File.Exists(projectPath))
src\sdk\src\Cli\dotnet\NugetPackageDownloader\NuGetPackageDownloader.cs (3)
192using FileStream destinationStream = File.Create(nupkgPath); 216File.Delete(nupkgPath); 324await using FileStream packageStream = File.OpenRead(packagePath);
src\sdk\src\Cli\dotnet\Parser.cs (2)
311if (File.Exists(filePath)) 313var lines = File.ReadAllLines(filePath);
src\sdk\src\Cli\dotnet\SdkVulnerability\SdkReleaseMetadataCache.cs (9)
60if (File.Exists(sentinelPath)) 62var lastWriteTime = File.GetLastWriteTimeUtc(sentinelPath); 84if (!File.Exists(summaryPath)) 91var json = File.ReadAllText(summaryPath); 158File.WriteAllText(tempPath, json); 159File.Move(tempPath, summaryPath, overwrite: true); 176if (File.Exists(sentinelPath)) 178File.SetLastWriteTimeUtc(sentinelPath, DateTime.UtcNow); 182File.Create(sentinelPath).Close();
src\sdk\src\Cli\dotnet\SlnfFileHelper.cs (2)
88File.WriteAllText(slnfPath, json); 121File.WriteAllText(slnfPath, json);
src\sdk\src\Cli\dotnet\SlnFileFactory.cs (2)
28if (File.Exists(slnFileOrDirectory)) 98string fileContent = File.ReadAllText(filteredSolutionPath);
src\sdk\src\Cli\dotnet\Telemetry\DevDeviceIDGetter.cs (5)
63if (File.Exists(cacheFilePath)) 65deviceId = File.ReadAllText(cacheFilePath); 72if (File.Exists(cacheFilePath)) 74deviceId = File.ReadAllText(cacheFilePath); 129File.WriteAllText(filePath, content);
src\sdk\src\Cli\dotnet\Telemetry\DockerContainerDetectorForTelemetry.cs (1)
36bool isDocker = File
src\sdk\src\Cli\dotnet\Telemetry\TelemetryDiskLogger.cs (3)
54var jsonText = !File.Exists(logPath) ? """{"activities":[]}""" : File.ReadAllText(logPath); 63File.WriteAllText(logPath, root.ToJsonString(s_jsonOptions));
dotnet-dev-certs (29)
src\aspnetcore\src\Shared\CertificateGeneration\CertificateManager.cs (5)
540if (!File.Exists(certificatePath)) 748File.Move(tempFilename, path, overwrite: true); 751File.WriteAllBytes(path, bytes); 776File.Move(tempFilename, keyPath, overwrite: true); 779File.WriteAllBytes(keyPath, pemEnvelope);
src\aspnetcore\src\Shared\CertificateGeneration\MacOSCertificateManager.cs (10)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 159using SafeFileHandle nullHandle = File.OpenNullHandle(); 175File.Delete(tmpFile); 207File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 319File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 339File.WriteAllBytes(certificatePath, certBytes); 457if (File.Exists(certificatePath)) 459File.Delete(certificatePath);
src\aspnetcore\src\Shared\CertificateGeneration\UnixCertificateManager.cs (13)
115if (File.Exists(certPath)) 247if (File.Exists(certPath)) 473if (File.Exists(certPath)) 610if (File.Exists(Path.Combine(searchFolder, command))) 646if (File.Exists(WslInteropPath) || File.Exists(WslInteropLatePath)) 689using SafeFileHandle nullHandle = File.OpenNullHandle(); 709using SafeFileHandle nullHandle = File.OpenNullHandle(); 737using SafeFileHandle nullHandle = File.OpenNullHandle(); 760using SafeFileHandle nullHandle = File.OpenNullHandle(); 820File.Delete(certPath); 1051if (!File.Exists(linkPath)) 1054File.CreateSymbolicLink(linkPath, cert.Name);
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-format (7)
Analyzers\AnalyzerReferenceInformationProvider.cs (1)
43if (path is null || !File.Exists(path))
CodeFormatter.cs (1)
220(formatOptions.FileMatcher.HasMatches(document.FilePath) && File.Exists(document.FilePath));
ReportWriter.cs (1)
29File.WriteAllText(reportFilePath, formattedFilesJson);
Utilities\EditorConfigFinder.cs (1)
31if (File.Exists(editorConfigPath))
Utilities\ProcessRunner.cs (1)
45if (File.Exists(file))
Workspaces\FolderWorkspace_FolderSolutionLoader.cs (1)
79if (File.Exists(filePath))
Workspaces\MSBuildWorkspaceFinder.cs (1)
75if (!File.Exists(workspacePath))
dotnet-getdocument (9)
Commands\InvokeCommand.cs (8)
66File.Copy(executableSource, executable, overwrite: true); 69if (File.Exists(configPath)) 71File.Copy(configPath, executable + ".config", overwrite: true); 94if (!string.IsNullOrEmpty(projectAssetsFile) && File.Exists(projectAssetsFile)) 96using var reader = new JsonTextReader(File.OpenText(projectAssetsFile)); 110if (File.Exists(runtimeConfigPath)) 175File.Delete(executable); 183File.Delete(executable + ".config");
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-Microsoft.XmlSerializer.Generator (9)
Sgen.cs (9)
341if (File.Exists(codePath)) 355if (File.Exists(codePath)) 357File.Delete(codePath); 360using (FileStream fs = File.Create(codePath)) 397if (!success && toDeleteFile && File.Exists(codePath)) 399File.Delete(codePath); 590if (File.Exists(reference)) 645if (File.Exists(reference)) 678foreach (string line in File.ReadAllLines(arg))
dotnet-openapi (9)
Commands\AddFileCommand.cs (1)
54return File.Exists(GetFullPath(file));
Commands\BaseCommand.cs (6)
102if (!File.Exists(project)) 137return File.Exists(Path.GetFullPath(file)) && file.EndsWith(".csproj", StringComparison.Ordinal); 350if (!File.Exists(filePath)) 515var destinationExists = File.Exists(destinationPath); 531using (var destinationStream = File.OpenRead(destinationPath)) 575File.Delete(destinationPath);
Commands\RemoveCommand.cs (1)
44File.Delete(GetFullPath(file));
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-razorpagegenerator (3)
Program.cs (3)
44File.WriteAllText(result.FilePath, result.GeneratedCode); 195var cshtmlContent = File.ReadAllText(_source.PhysicalPath); 214var includeFileContent = File.ReadAllText(System.IO.Path.Combine(basePath, includeFileName));
dotnet-sourcelink (3)
dotnet-sql-cache (1)
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-suggest (5)
FileSuggestionRegistration.cs (2)
45|| !File.Exists(_registrationConfigurationFilePath)) 75if (_registrationConfigurationFilePath != null && File.Exists(_registrationConfigurationFilePath))
Program.cs (1)
38File.AppendAllText(logFile, string.Join("|", args) + Environment.NewLine);
SuggestionShellScriptHandler.cs (1)
33string scriptContent = File.ReadAllText(Path.Combine(directory, scriptName));
SuggestionStore.cs (1)
61if (!File.Exists(exeFileName))
dotnet-svcutil-lib (48)
Bootstrapper\SvcutilBootstrapper.cs (1)
172File.WriteAllText(programFilePath, s_programClass);
CodeSerializer.cs (2)
79if (File.Exists(_outputFilePath)) 81File.Delete(_outputFilePath);
CommandProcessorOptions.cs (4)
445if (!IsUpdateOperation && this.ToolContext <= OperationalContext.Global && File.Exists(filePath)) 532if (!PathHelper.IsUnderDirectory(svcutilParmasFile, projectDirInfo, out paramsFilePath, out fileRelPath) || !File.Exists(paramsFilePath)) 535if (!PathHelper.IsUnderDirectory(wcfcsParamsFile, projectDirInfo, out paramsFilePath, out fileRelPath) || !File.Exists(paramsFilePath)) 706if (File.Exists(projectFullPath))
FrameworkFork\Microsoft.CodeDom\Compiler\CodeCompiler.cs (2)
121using (Stream str = File.OpenRead(fileName)) { } 215using (Stream str = File.OpenRead(fileName)) { }
FrameworkFork\Microsoft.CodeDom\Compiler\TempFiles.cs (1)
292File.Delete(fileName);
FrameworkFork\Microsoft.CodeDom\Microsoft\CSharpCodeProvider.cs (4)
3938File.Delete(options.OutputAssembly); 3954using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read, share)) 4055using (Stream str = File.OpenRead(fileName)) { } 4125using (Stream str = File.OpenRead(fileName)) { }
FrameworkFork\Microsoft.CodeDom\Microsoft\VBCodeProvider.cs (2)
3293File.Delete(outputAssemblyFile); 3309using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read, share))
FrameworkFork\Microsoft.Xml\Xml\Core\XmlReader.cs (1)
1895} while (File.Exists(dumpFileName));
FrameworkFork\Microsoft.Xml\Xml\schema\GenerateConverter.cs (1)
1050public AutoGenWriter(string fileName, string regionName) : this(File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite), regionName)
FrameworkFork\System.Web.Services\Services\Description\ServiceDescription.cs (2)
376StreamReader reader = new StreamReader(File.OpenRead(fileName), detectEncodingFromByteOrderMarks: true); 435StreamWriter writer = new StreamWriter(File.OpenWrite(fileName));
Metadata\MetadataDocumentLoader.cs (5)
527if (!File.Exists(fullFileName)) 535if (!File.Exists(fullFileName) && !string.IsNullOrWhiteSpace(specNamespace)) 544if (!File.Exists(fullFileName) && !Path.IsPathRooted(schemaLocation)) 548if (!File.Exists(fullFileName)) 555if (File.Exists(fullFileName))
Metadata\MetadataDocumentSaver.cs (1)
71var fileInfo = this.MetadataFiles.FirstOrDefault(fi => File.Exists(fi.FilePath));
Metadata\MetadataFileNameManager.cs (1)
183if (File.Exists(filePath))
Shared\MSBuildProj.cs (10)
147var project = await ParseAsync(File.ReadAllText(filePath), filePath, logger, cancellationToken).ConfigureAwait(false); 154var project = await ParseAsync(File.ReadAllText(filePath), filePath, logger, cancellationToken, tfMoniker).ConfigureAwait(false); 322if (fullPath == null || !File.Exists(fullPath)) 396if (File.Exists(fullPath)) 412project = await ParseAsync(File.ReadAllText(fullPath), fullPath, logger, cancellationToken).ConfigureAwait(false); 706using (StreamWriter writer = File.CreateText(this.FullPath)) 803if (File.Exists(assetsFile) && !(this.TargetFramework.Contains("-") && !this.TargetFramework.ToLower().Contains("windows"))) 888if (File.Exists(depsFile)) 895using (var stream = File.OpenRead(depsFile)) 920if (File.Exists(dependency.FullPath) && !assemblyDependencies.Contains(dependency))
Shared\Options\ApplicationOptions.cs (2)
140jsonText = File.ReadAllText(fileInfo.FullName); 173File.WriteAllText(filePath, this.Json);
Shared\ProjectPropertyResolver.cs (2)
149while (dotnetDir != null && !(File.Exists(Path.Combine(dotnetDir, "dotnet")) || File.Exists(Path.Combine(dotnetDir, "dotnet.exe"))))
Shared\Utilities\PathHelper.cs (2)
209if (File.Exists(filePath)) 216File.Copy(filePath, dstFilePath, overwrite: true);
Shared\Utilities\RuntimeEnvironmentHelper.cs (4)
47if (!File.Exists(Path.Combine(destinationDirectory, "global.json"))) 53if (!File.Exists(Path.Combine(destinationDirectory, "nuget.config"))) 73if (File.Exists(nugetConfigPath)) 79using (var stream = File.Open(nugetConfigPath, FileMode.Open, FileAccess.ReadWrite))
Tool.cs (1)
145if (!File.Exists(options.OutputFile.FullName))
dotnet-svcutil-lib.Tests (52)
E2ETests.cs (9)
174if (!File.Exists(wsdlFile)) 180Assert.True(File.Exists(wsdlFile), $"{wsdlFile} not initialized!"); 226if (!File.Exists(assemblyPath)) 238Assert.True(File.Exists(binProjPath), $"{nameof(binProjPath)} not initialized!"); 239Assert.True(File.Exists(libProjPath), $"{nameof(libProjPath)} not initialized!"); 369Assert.True(File.Exists(srcParamsFilePath), $"{nameof(srcParamsFilePath)} not initialized!"); 374File.Copy(f, Path.Combine(this_TestCaseProject.DirectoryPath, Path.GetFileName(f))); 383File.WriteAllText(dstParamsFile, File.ReadAllText(dstParamsFile).Replace("$testCasesPath$", g_TestCasesDir.Replace("\\", "/")));
FixupUtil.cs (2)
107var originalText = System.IO.File.ReadAllText(fileName); 112System.IO.File.WriteAllText(fileName, updatedText);
GlobalToolTests.cs (4)
113File.Copy(Path.Combine(g_TestCasesDir, "FullFramework", "FullFramework.cs"), Path.Combine(this_TestCaseOutputDir, "FullFramework.cs"), true); 114File.Copy(Path.Combine(g_TestCasesDir, "FullFramework", "FullFramework.csproj"), Path.Combine(this_TestCaseOutputDir, "FullFramework.csproj"), true); 141File.Copy(Path.Combine(g_TestCasesDir, this_TestCaseName, testCaseName, "Program.cs"), Path.Combine(this_TestCaseOutputDir, "Program.cs"), true); 142File.Copy(Path.Combine(g_TestCasesDir, this_TestCaseName, testCaseName, $"{testCaseName}.csproj"), Path.Combine(this_TestCaseOutputDir, $"{testCaseName}.csproj"), true);
ProjectUtils.cs (9)
28if (forceNew && File.Exists(filePath)) 30File.Delete(filePath); 31if (File.Exists(dstProgramFile)) 32File.Delete(dstProgramFile); 36if (File.Exists(filePath)) 51File.Move(srcProgramFile, dstProgramFile); 87Assert.True(File.Exists(project?.FullPath), $"{nameof(project)} is not initialized!"); 175Assert.True(File.Exists(project?.FullPath), $"{nameof(project)} is not initialized!"); 181File.Copy(srcParamsFile, dstParamsFile);
TestInit.cs (20)
60File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.props"), "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" />"); 61File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.targets"), "<Project></Project>"); 95if (!File.Exists(filePath)) 115File.Copy(project.FullPath, projectPath); 116File.Copy(srcProgramPath, programPath); 118File.WriteAllText(programPath, File.ReadAllText(programPath) 167Assert.True(File.Exists(g_StarterProject.FullPath), $"{nameof(g_StarterProject)} is not initialized!"); 173File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.props"), "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" />"); 174File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.targets"), "<Project></Project>"); 268if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists(Path.Combine(linuxBaselinePath, Path.GetFileName(this_TestCaseLogFile)))) 335File.WriteAllText(this.this_TestCaseLogFile, logText); 354if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists(Path.Combine(linuxBaselinePath, Path.GetFileName(this_TestCaseLogFile)))) 430File.Copy(generated, expected); 458File.WriteAllText(scriptPath, cmdStr.ToString()); 472fileLines1.AddRange(File.ReadAllLines(baselineFile)); 473fileLines2.AddRange(File.ReadAllLines(generatedFile)); 590Assert.True(rootSolutionFolder != null && File.Exists(rootSolutionFolder), $"Unable to find dotnet-svcutil.sln file, current dir: {parentDir}"); 606File.WriteAllText(Path.Combine(directory, "global.json"), globalConfig); 624File.WriteAllText(Path.Combine(g_TestOutputDir, "nuget.config"), nugetConfigText.Replace("$svcutilTestFeed$", g_SvcutilNugetFeed));
UnitTest.cs (8)
225File.Copy(Path.Combine(g_TestCasesDir, "wsdl", "Simple.wsdl"), Path.Combine(this_TestGroupOutputDir, "wsdl", "Simple.wsdl")); 271File.WriteAllText(this_TestCaseLogFile, this_FixupUtil.ReplaceText(log)); 309File.WriteAllText(this_TestCaseLogFile, this_FixupUtil.ReplaceText(log)); 331File.Copy(jsonFileSrcPath, jsonFileDstPath); 332File.WriteAllText(jsonFileDstPath, File.ReadAllText(jsonFileDstPath).Replace("$testCaseProject$", this_TestCaseProject.FullPath.Replace("\\", "/"))); 348var jsonText = File.ReadAllText(jsonFileSrcPath); 354File.WriteAllText(outJsonFile, options.Json);
dotnet-svcutil.xmlserializer (9)
Microsoft\Tools\ServiceModel\SvcUtil\CommandLineParser.cs (1)
209if (File.Exists(potentialPath))
Microsoft\Tools\ServiceModel\SvcUtil\XmlSerializerGenerator.cs (8)
70if (File.Exists(codePath)) 72File.Delete(codePath); 75using (FileStream fs = File.Create(codePath)) 90if (!success && toDeleteFile && File.Exists(codePath)) 92File.Delete(codePath); 100if (File.Exists(sgenSource)) 101File.Delete(sgenSource); 111File.Copy(codePath, sourceFilePath, true);
dotnet-svcutil.xmlserializer.IntegrationTests (4)
SvcutilTests.cs (4)
22Assert.False(File.Exists(outputFile)); 25if (File.Exists(smassemblypath)) 28Assert.True(File.Exists(outputFile)); 29File.Delete(outputFile);
dotnet-user-jwts (17)
Helpers\DevJwtCliHelpers.cs (4)
95if (!File.Exists(fullPath)) 116else if (!File.Exists(Path.Combine(Path.GetDirectoryName(projectPath), appsettingsFile))) 139if (File.Exists(fileBasedAppLaunchSettingsFilePath)) 147if (File.Exists(launchSettingsFilePath))
Helpers\JwtAuthenticationSchemeSettings.cs (1)
18var config = File.Exists(filePath)
Helpers\JwtStore.cs (2)
28if (File.Exists(_filePath)) 46File.Move(tempFilename, _filePath, overwrite: true);
Helpers\SigningKeysHandler.cs (1)
66if (File.Exists(secretsFilePath))
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\aspnetcore\src\Tools\Shared\SecretsHelpers\MsBuildProjectFinder.cs (1)
47if (!File.Exists(projectPath))
src\aspnetcore\src\Tools\Shared\SecretsHelpers\ProjectIdResolver.cs (7)
119if (!File.Exists(outputFile)) 125var id = File.ReadAllText(outputFile)?.Trim(); 203if (!File.Exists(outputFile)) 211var id = File.ReadAllText(outputFile).Trim(); 257var targetPath = searchPaths.Select(p => Path.Combine(p, "SecretManager.targets")).FirstOrDefault(File.Exists); 270if (File.Exists(file)) 272File.Delete(file);
dotnet-user-secrets (11)
Internal\SecretsStore.cs (2)
80File.Move(tempFilename, _secretsFilePath, overwrite: true); 83File.WriteAllText(_secretsFilePath, contents, Encoding.UTF8);
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\aspnetcore\src\Tools\Shared\SecretsHelpers\MsBuildProjectFinder.cs (1)
47if (!File.Exists(projectPath))
src\aspnetcore\src\Tools\Shared\SecretsHelpers\ProjectIdResolver.cs (7)
119if (!File.Exists(outputFile)) 125var id = File.ReadAllText(outputFile)?.Trim(); 203if (!File.Exists(outputFile)) 211var id = File.ReadAllText(outputFile).Trim(); 257var targetPath = searchPaths.Select(p => Path.Combine(p, "SecretManager.targets")).FirstOrDefault(File.Exists); 270if (File.Exists(file)) 272File.Delete(file);
dotnet-watch (6)
Program.cs (1)
235if (!File.Exists(projectPath))
Watch\BuildEvaluator.cs (1)
196return File.GetLastWriteTimeUtc(file);
Watch\MsBuildFileSetFactory.cs (4)
75var success = exitCode == 0 && File.Exists(watchList); 89using var watchFile = File.OpenRead(watchList); 146File.Delete(watchList); 196var targetPath = searchPaths.Select(p => Path.Combine(p, WatchTargetsFileName)).FirstOrDefault(File.Exists);
DotNetWatchTasks (1)
FileSetSerializer.cs (1)
73using var fileStream = File.Create(OutputPath);
GenerateAnalyzerNuspec (6)
Program.cs (6)
159if (File.Exists(resourceAssemblyFullPath)) 192if (File.Exists(fileWithPath)) 269if (File.Exists(fileWithPath)) 278if (File.Exists(fileWithPath)) 287if (File.Exists(fileWithPath)) 298File.WriteAllText(nuspecFile, result.ToString());
GenerateDocumentationAndConfigFiles (21)
Program.cs (16)
275if (!File.Exists(path)) 436File.WriteAllText(fileWithPath, fileContents); 457File.WriteAllText(fileWithPath, fileContents); 612File.WriteAllText(fileWithPath, builder.ToString()); 789actualContent = File.ReadAllLines(fileWithPath); 836File.WriteAllText(fileWithPath, builder.ToString()); 875if (!File.Exists(assemblyPath)) 908var shippedFileExists = File.Exists(shippedFile); 909var unshippedFileExists = File.Exists(unshippedFile); 932using var fileStream = File.OpenRead(shippedFile); 942using var fileStreamUnshipped = File.OpenRead(unshippedFile); 1115File.WriteAllText(rulesetFilePath, text); 1180File.WriteAllText(editorconfigFilePath, text); 1365string actual = File.ReadAllText(fileWithPath); 1402File.WriteAllText(configFilePath, text); 1613File.WriteAllText(fileWithPath, fileContents);
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
GetDocument.Insider (5)
Commands\GetDocumentCommand.cs (1)
96if (!File.Exists(assemblyPath))
Commands\GetDocumentCommandWorker.cs (3)
323var stream = File.Create(_context.FileListPath); 398using var outStream = File.Create(filePath); 403File.Delete(filePath);
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
HelixTestTasks (1)
GroupWorkItems.cs (1)
50if (File.Exists(item.ItemSpec))
ilasm (13)
Program.cs (13)
51if (!File.Exists(file)) 79contentBuilder.AppendLine(File.ReadAllText(file)); 177if (File.Exists(path)) 179return new SourceText(File.ReadAllText(path), path); 184if (File.Exists(fullPath)) 186return new SourceText(File.ReadAllText(fullPath), fullPath); 193if (File.Exists(fullPath)) 195return new SourceText(File.ReadAllText(fullPath), fullPath); 205if (File.Exists(path)) 207return File.ReadAllBytes(path); 212if (File.Exists(fullPath)) 214return File.ReadAllBytes(fullPath); 257using var outputStream = File.Create(outputPath);
ILAssembler (1)
GrammarVisitor.cs (1)
688byte[] keyBytes = File.ReadAllBytes(keyFilePath);
ilc (8)
ConfigurablePInvokePolicy.cs (1)
28foreach (var entry in File.ReadLines(file))
Program.cs (4)
307if (!File.Exists(linkTrimFilePath)) 396using FileStream fs = File.OpenRead(substitutionFilePath); 735File.Delete(tempOutputFilePath); 747File.Move(tempOutputFilePath, outputFilePath, overwrite: true);
src\runtime\src\coreclr\tools\Common\CommandLineHelpers.cs (3)
204details.AddRange(File.ReadAllLines(rspFileName)); 351&& File.Exists(originalPdbPath)) 431foreach (string line in File.ReadAllLines(filePath))
ILCompiler.Build.Tasks (3)
DumpNativeResources.cs (3)
42using (FileStream fs = File.OpenRead(MainAssembly)) 49using (var bw = new BinaryWriter(File.Create(ResourceFile))) 56using (var bw = new BinaryWriter(File.Create(ResourceFile)))
ILCompiler.Compiler (8)
Compiler\DependencyAnalysis\TrimmingDescriptorNode.cs (1)
27using (Stream fs = File.OpenRead(_fileName))
Compiler\MetadataManager.cs (1)
812using (var logWriter = _metadataLogFile != null ? new StreamWriter(File.Open(_metadataLogFile, FileMode.Create, FileAccess.Write, FileShare.Read), noThrowUtf8Encoding) : null)
Compiler\MstatObjectDumper.cs (1)
207using (var fs = File.Create(_fileName))
Compiler\ReachabilityInstrumentationFilter.cs (1)
32using BinaryReader reader = new BinaryReader(File.OpenRead(profileDataFileName));
Compiler\SourceLinkWriter.cs (1)
27_writer = File.CreateText(sourceLinkFileName);
Compiler\XmlObjectDumper.cs (1)
37_writer = XmlWriter.Create(File.CreateText(_fileName), settings);
src\runtime\src\coreclr\tools\Common\Compiler\CompilerTypeSystemContext.cs (2)
346if (!Path.IsPathRooted(candidatePath) || !File.Exists(candidatePath)) 350if (!File.Exists(candidatePath))
ILCompiler.Diagnostics (4)
PdbWriter.cs (4)
145File.Delete(_tempSourceDllName); 155File.Delete(_pdbFilePath); 188File.Copy(dllPath, _tempSourceDllName, overwrite: true); 194File.Delete(_pdbFilePath);
ILCompiler.ReadyToRun (4)
CodeGen\ReadyToRunObjectWriter.cs (1)
271File.Delete(_objectFilePath);
Compiler\CallChainProfile.cs (1)
249using (StreamReader stream = File.OpenText(jsonProfileFile))
src\runtime\src\coreclr\tools\Common\Compiler\CompilerTypeSystemContext.cs (2)
346if (!Path.IsPathRooted(candidatePath) || !File.Exists(candidatePath)) 350if (!File.Exists(candidatePath))
illink (23)
ILLink.Tasks (9)
CreateRuntimeRootDescriptorFile.cs (9)
103if (!File.Exists(namespaceFilePath)) 110if (!File.Exists(mscorlibFilePath)) 117if (!File.Exists(cortypeFilePath)) 124if (!File.Exists(rexcepFilePath)) 133if (!File.Exists(iLLinkTrimXmlFilePath)) 154string[] namespaces = File.ReadAllLines(namespaceFile); 187string[] types = File.ReadAllLines(typeFile); 293string[] corTypes = File.ReadAllLines(corTypeFile); 316string[] excTypes = File.ReadAllLines(excTypeFile);
Infrastructure.Common (1)
CertificateManager.cs (1)
274if (!File.Exists(OSXCustomKeychainFilePath))
Infrastructure.Tests (287)
CreateFailingTestIssue\CreateFailingTestIssueFixture.cs (1)
20if (!File.Exists(ToolProjectPath))
CreateFailingTestIssue\CreateFailingTestIssueToolTests.cs (23)
72var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 83File.WriteAllText( 88File.WriteAllText( 122File.WriteAllText( 133File.WriteAllText(Path.Combine(fixtureDirectory, "add-issue-comment.json"), "{}"); 153var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 163File.WriteAllText( 174File.WriteAllText(Path.Combine(fixtureDirectory, "reopen-issue.json"), "{}"); 175File.WriteAllText(Path.Combine(fixtureDirectory, "add-issue-comment.json"), "{}"); 195var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 205File.WriteAllText( 210File.WriteAllText( 237var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 247File.WriteAllText( 257File.WriteAllText( 285var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 431var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 530var diagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 560var queuedDiagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 586var failedDiagnosticsLog = File.ReadAllText(Path.Combine(fixtureDirectory, "diagnostics.log")); 977=> File.WriteAllText(GetFixturePath(fixtureDirectory, endpoint, ".json"), json); 980=> File.WriteAllText(GetFixturePath(fixtureDirectory, endpoint, ".txt"), text); 983=> File.WriteAllText(GetFixturePath(fixtureDirectory, endpoint, ".err"), text);
DownloadFailingJobLogs\DownloadFailingJobLogsFixture.cs (2)
22if (!File.Exists(ToolPath)) 27if (!File.Exists(DotNetPath))
DownloadFailingJobLogs\DownloadFailingJobLogsToolTests.cs (4)
62Assert.True(File.Exists(logPath)); 63Assert.Contains("Expected 1 but found 2.", File.ReadAllText(logPath), StringComparison.Ordinal); 66Assert.True(File.Exists(extractedTrx)); 198File.WriteAllText(path, content);
ExtractTestPartitions\ExtractTestPartitionsFixture.cs (1)
56if (!File.Exists(projectPath))
ExtractTestPartitions\ExtractTestPartitionsTests.cs (15)
44Assert.True(File.Exists(outputFile), "Output file should be created"); 46var partitions = File.ReadAllLines(outputFile); 69Assert.False(File.Exists(outputFile), "Output file should NOT be created for Collection-only attributes"); 90Assert.True(File.Exists(outputFile), "Output file should be created"); 92var partitions = File.ReadAllLines(outputFile); 111Assert.False(File.Exists(outputFile), "Output file should NOT be created when no partitions found"); 133var partitions = File.ReadAllLines(outputFile); 158var partitions = File.ReadAllLines(outputFile); 206Assert.True(File.Exists(outputFile), "Output file should be created in nested directory"); 225Assert.True(File.Exists(outputFile), "Output file should be created"); 227var partitions = File.ReadAllLines(outputFile); 249Assert.True(File.Exists(outputFile), "Output file should be created"); 251var partitions = File.ReadAllLines(outputFile); 274Assert.True(File.Exists(outputFile), "Output file should be created"); 276var partitions = File.ReadAllLines(outputFile);
ExtractTestPartitions\MockAssemblyBuilder.cs (2)
244if (File.Exists(netstandardPath)) 253if (File.Exists(runtimePath))
GenerateTestSummary\GenerateTestSummaryFixture.cs (1)
20if (!File.Exists(ToolProjectPath))
GenerateTestSummary\GenerateTestSummaryToolTests.cs (10)
65await File.ReadAllTextAsync(jsonPath), 92await File.ReadAllTextAsync(jsonPath), 115await File.ReadAllTextAsync(jsonPath), 135await File.WriteAllTextAsync(Path.Combine(trxDir, "broken.trx"), "this is not valid trx xml <<<"); 142await File.ReadAllTextAsync(jsonPath), 165await File.WriteAllTextAsync(Path.Combine(trxDir, "broken.trx"), "this is not valid trx xml <<<"); 172await File.ReadAllTextAsync(jsonPath), 192await File.WriteAllTextAsync(Path.Combine(trxDir, "broken.trx"), "this is not valid trx xml <<<"); 199await File.ReadAllTextAsync(jsonPath), 230await File.ReadAllTextAsync(jsonPath),
Pipelines\ExtensionE2eRecorderStepTests.cs (6)
70File.WriteAllText(scriptPath, BuildStepScript(stepScript, keepExplicitExit)); 77var invocations = File.Exists(invocationLog) ? File.ReadAllLines(invocationLog) : []; 199File.CreateSymbolicLink(Path.Combine(stubDirectory, "pwsh"), pwshPath); 207File.WriteAllText(stubPath, contents); 213File.SetUnixFileMode(stubPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
Pipelines\ExtensionE2eWorkflow.cs (1)
19using var reader = new StringReader(File.ReadAllText(Path.Combine(RepoRoot.Path, WorkflowRelativePath)));
Pipelines\ExtensionE2eWorkflowTests.cs (1)
58using var reader = new StringReader(File.ReadAllText(Path.Combine(RepoRoot.Path, CallerWorkflowRelativePath)));
Pipelines\NixCliPackageTests.cs (7)
78await File.WriteAllTextAsync(curlPath, """ 87File.SetUnixFileMode(curlPath, 125await File.WriteAllTextAsync(curlPath, """ 133File.SetUnixFileMode(curlPath, 194Assert.False(File.Exists(outputPath), "versions.json must not be written when the override set is incomplete."); 253? File.ReadAllTextAsync(relativePath) 254: File.ReadAllTextAsync(Path.Combine(RepoRoot.Path, relativePath));
Pipelines\NpmCliPackageTests.cs (14)
181await File.WriteAllTextAsync( 221await File.WriteAllTextAsync( 270var readme = await File.ReadAllTextAsync(Path.Combine(package.PointerPackageRoot, "README.md")); 353Assert.True(File.Exists(Path.Combine(package.RidPackageRoot, "bin", expectation.BinaryName))); 355var readme = await File.ReadAllTextAsync(Path.Combine(package.RidPackageRoot, "README.md")); 502=> File.ReadAllTextAsync(Path.Combine(_repoRoot, relativePath.Replace('/', Path.DirectorySeparatorChar))); 512File.Copy( 516await File.WriteAllTextAsync( 531await File.WriteAllTextAsync(Path.Combine(pointerBinRoot, "aspire-package-map.json"), packageMap.ToJsonString()); 541await File.WriteAllTextAsync( 550await File.WriteAllTextAsync(Path.Combine(ridBinRoot, "aspire"), "native binary stub"); 551await File.WriteAllTextAsync(Path.Combine(ridBinRoot, "aspire.exe"), "native binary stub"); 577await File.WriteAllTextAsync(nativeBinaryPath, "native binary stub"); 696var json = File.ReadAllText(path);
Pipelines\ReleasePublishNugetPipelineTests.cs (1)
804=> File.ReadAllTextAsync(Path.Combine(_repoRoot, relativePath.Replace('/', Path.DirectorySeparatorChar)));
PowerShellScripts\AspireSkillsBundleHashTests.cs (2)
55File.WriteAllBytes(inputPath, BuildInput(lineEndings)); 151File.WriteAllText(path, content);
PowerShellScripts\BuildTestMatrixTests.cs (3)
627File.WriteAllText( 659Assert.True(File.Exists(propsPath), $"CITestsProperties.props not found at {propsPath}"); 746var json = File.ReadAllText(path);
PowerShellScripts\DownloadNativeArchivesTests.cs (5)
197File.Exists(Path.Combine(_workspace.Path, "escaped", "aspire-cli-linux-x64-13.4.0.tar.gz")), 236Assert.True(File.Exists(Path.Combine( 272Assert.True(File.Exists(Path.Combine( 335Assert.True(File.Exists(Path.Combine( 373Assert.True(File.Exists(Path.Combine(
PowerShellScripts\ExpandTestMatrixGitHubTests.cs (6)
151var json = File.ReadAllText(outputFile); 178var json = File.ReadAllText(outputFile); 209var json = File.ReadAllText(outputFile); 565File.WriteAllText(githubOutputFile, ""); 640var json = File.ReadAllText(path); 647foreach (var line in File.ReadAllLines(path))
PowerShellScripts\ScanTestPartitionsFromSourceGuardTests.cs (1)
62var content = File.ReadAllText(file);
PowerShellScripts\SplitTestMatrixByDepsTests.cs (4)
26File.WriteAllText(_githubOutputFile, ""); 207File.WriteAllText(matrixFile, matrixJson); 263File.WriteAllText(tempMatrixFile, allTestsMatrix); 308foreach (var line in File.ReadAllLines(_githubOutputFile))
PowerShellScripts\SplitTestProjectsTests.cs (3)
117Assert.True(File.Exists(outputFile), "Output file should exist"); 120var json = File.ReadAllText(outputFile); 204var json = File.ReadAllText(path);
PowerShellScripts\StageNativeCliToolPackagesTests.cs (1)
334File.WriteAllText(path, "package");
PowerShellScripts\TrustedExtensionReleasePrTests.cs (16)
42File.WriteAllText(PackageJsonPath, BasePackageJson); 43File.WriteAllText(ChangelogPath, BaseChangelog); 84File.WriteAllText(Path.Combine(_workspace.Path, "base-only.txt"), "unrelated base change"); 115File.WriteAllText(Path.Combine(_workspace.Path, "unexpected.txt"), "unexpected"); 126File.WriteAllText( 129File.WriteAllText(ChangelogPath, TrustedChangelog); 140File.WriteAllText( 151File.WriteAllText( 168File.WriteAllText(PackageJsonPath, TrustedPackageJson); 169File.WriteAllText(ChangelogPath, headChangelog); 180File.WriteAllText(PackageJsonPath, TrustedPackageJson); 181File.WriteAllText( 217File.WriteAllText(PackageJsonPath, TrustedPackageJson); 218File.WriteAllText(ChangelogPath, TrustedChangelog); 238File.WriteAllText(_githubOutputPath, string.Empty); 262private string ReadGitHubOutput() => File.ReadAllText(_githubOutputPath).Trim();
PowerShellScripts\ValidateNpmPackageSignaturesTests.cs (14)
55File.WriteAllText(filePath, "hi"); 71File.WriteAllText(Path.Combine(shipping, "Aspire.Hosting.13.4.0.nupkg"), "decoy"); 85File.WriteAllBytes(tgz, [0x1f, 0x8b]); // anything; content not inspected 101File.WriteAllBytes(tgz, [0x1f, 0x8b]); 104File.WriteAllBytes($"{tgz}.sig", Enumerable.Repeat((byte)0xC2, 32).ToArray()); 119File.WriteAllBytes(tgz, [0x1f, 0x8b]); 123File.WriteAllBytes($"{tgz}.sig", new byte[128]); 138File.WriteAllBytes(tgz, [0x1f, 0x8b]); 144File.WriteAllBytes($"{tgz}.sig", armored); 164File.WriteAllBytes(tgz, [0x1f, 0x8b]); 170File.WriteAllBytes($"{tgz}.sig", sig); 189File.WriteAllBytes(tgzMissing, [0x1f, 0x8b]); 190File.WriteAllBytes(tgzBadPrefix, [0x1f, 0x8b]); 191File.WriteAllBytes($"{tgzBadPrefix}.sig", new byte[128]); // bad prefix
PowerShellScripts\WriteClassModeTestPropsTests.cs (3)
57var propsXml = File.ReadAllText(outputPropsPath); 86var propsXml = File.ReadAllText(outputPropsPath); 97File.WriteAllText(
Shared\RepoRoot.cs (1)
27if (File.Exists(System.IO.Path.Combine(directory.FullName, "Aspire.slnx")))
Shared\TestDataBuilder.cs (5)
62File.WriteAllText(outputPath, json); 108File.WriteAllText(outputPath, json); 133File.WriteAllText(outputPath, json); 152File.WriteAllText(outputPath, json); 174File.WriteAllText(outputPath, json);
src\Shared\PathLookupHelper.cs (2)
228if (!File.Exists(path)) 243return (File.GetUnixFileMode(path) & ExecuteBits) != 0;
tests\Shared\TemporaryWorkspace.cs (1)
241File.WriteAllText(settingsPath, "{}");
TestTriggerMap\GraphAffectedProjectsTests.cs (4)
283File.WriteAllLines(changedFilesPath, changedRepoRelativePaths); 290File.WriteAllLines(changedFilesPath, changedRepoRelativePaths); 298File.WriteAllText(fullPath, contents); 399File.WriteAllText(fullPath, contents);
TestTriggerMap\SelectTestsAcceptanceTests.cs (5)
121File.WriteAllText(path, SyntheticMap); 785File.WriteAllText(mapPath, map); 944if (File.Exists(baseline) && Directory.Exists(Path.Combine(polyglotRoot, name))) 973.Where(name => name is not null && File.Exists(Path.Combine(testsDir, name!, $"{name}.csproj"))) 980var slnx = File.ReadAllText(Path.Combine(RepoRoot.Path, "Aspire.slnx"));
TestTriggerMap\SelectTestsCliTests.cs (38)
74Assert.False(File.Exists(propsPath)); 93File.WriteAllText(slnxPath, Slnx); 94File.WriteAllText(Path.Combine(dir.FullName, "map.yml"), Map); 106Assert.Contains("Aspire.Hosting.Tests", File.ReadAllText(propsPath)); 132var props = File.ReadAllText(propsPath); 156var comment = File.ReadAllText(commentPath); 208var comment = File.ReadAllText(commentPath); 264var comment = File.ReadAllText(commentPath); 305var comment = File.ReadAllText(commentPath); 336var comment = File.ReadAllText(commentPath); 367using var doc = JsonDocument.Parse(File.ReadAllText(jsonPath)); 454Assert.False(File.Exists(propsPath)); 561Assert.False(File.Exists(propsPath)); 602var summary = File.ReadAllText(Path.Combine(repoRoot, "summary")); 643var props = File.ReadAllText(propsPath); 683Assert.False(File.Exists(propsPath)); 687var summary = File.ReadAllText(Path.Combine(repoRoot, "summary")); 724var summary = File.ReadAllText(Path.Combine(repoRoot, "summary")); 730var comment = File.ReadAllText(commentPath); 735using var doc = JsonDocument.Parse(File.ReadAllText(jsonPath)); 768var props = File.ReadAllText(propsPath); 809Assert.Contains("Aspire.Cli.Tests", File.ReadAllText(propsPath)); 847Assert.Contains("Aspire.Hosting.Tests", File.ReadAllText(propsPath)); 861File.WriteAllText(changed, "\n trigger.txt \n\n\t\n"); 865Assert.Contains("Aspire.Hosting.Tests", File.ReadAllText(propsPath)); 888Assert.False(File.Exists(propsPath)); 906var props = File.ReadAllText(propsPath); 938Assert.False(File.Exists(propsPath)); 965File.WriteAllText(Path.Combine(repoRoot, "skip-patterns.txt"), "# docs\n**.md\n"); 971var summary = File.ReadAllText(Path.Combine(repoRoot, "summary")); 979File.WriteAllText(Path.Combine(repoRoot, "skip-patterns.txt"), ".github/workflows/**\n"); 984Assert.Contains("Aspire.Hosting.Tests", File.ReadAllText(propsPath)); 1015File.WriteAllLines(changed, paths); 1030File.WriteAllText(Path.Combine(dir.FullName, "Aspire.slnx"), slnx); 1031File.WriteAllText(Path.Combine(dir.FullName, "map.yml"), map); 1075if (File.Exists(outputPath)) 1077foreach (var line in File.ReadAllLines(outputPath)) 1115File.WriteAllText(fullPath, contents);
TestTriggerMap\SelectTestsLayer1IntegrationTests.cs (11)
57Assert.Contains("tests/Core.Tests/Core.Tests.csproj", File.ReadAllText(propsPath)); 107var props = File.ReadAllText(propsPath); 154var summary = File.ReadAllText(System.IO.Path.Combine(fixture.Path, "summary")); 157var comment = File.ReadAllText(commentPath); 163using var doc = System.Text.Json.JsonDocument.Parse(File.ReadAllText(jsonPath)); 217using var doc = System.Text.Json.JsonDocument.Parse(File.ReadAllText(jsonPath)); 224var comment = File.ReadAllText(commentPath); 321File.WriteAllLines(changed, paths); 358if (File.Exists(outputPath)) 360foreach (var line in File.ReadAllLines(outputPath)) 386File.WriteAllText(fullPath, contents);
TestTriggerMap\SelectTestsWorkflowTests.cs (6)
23var action = File.ReadAllText(SelectTestsActionPath); 41var testsYml = File.ReadAllText(TestsWorkflowPath); 82var testsYml = File.ReadAllText(TestsWorkflowPath); 88var action = File.ReadAllText(SelectTestsActionPath); 102var action = File.ReadAllText(SelectTestsActionPath); 143var testsYml = File.ReadAllText(TestsWorkflowPath);
TestTriggerMap\TestTriggerMapModel.cs (1)
128var yaml = File.ReadAllText(path);
TestTriggerMap\TestTriggerMapTests.cs (9)
142var slnx = File.ReadAllText(Path.Combine(RepoRoot.Path, "Aspire.slnx")); 170.Where(rel => File.Exists(Path.Combine(RepoRoot.Path, rel))) 270var testsYml = File.ReadAllText(Path.Combine(workflowsDir, "tests.yml")); 272bool WorkflowExists(string file) => File.Exists(Path.Combine(workflowsDir, file)); 314var testsYml = File.ReadAllText(Path.Combine(RepoRoot.Path, ".github", "workflows", "tests.yml")); 373var testsYml = File.ReadAllText(Path.Combine(RepoRoot.Path, ".github", "workflows", "tests.yml")); 413.Where(name => !File.Exists(Path.Combine(RepoRoot.Path, "tests", name, $"{name}.csproj"))) 427Assert.True(File.Exists(Path.Combine(RepoRoot.Path, s_map.Prefilter.PatternsFile!)), 505.SelectMany(f => usesLocalAction.Matches(File.ReadAllText(f)).Select(m => m.Groups["name"].Value))
tools\GenerateCITimeline\GitHubApi.cs (1)
156var text = File.ReadAllText(path);
TypeScriptApiCompat\TypeScriptApiCompatTests.cs (8)
198File.WriteAllText(suppressionPath, """ 232File.WriteAllText(currentSuppressionPath, """ 236File.WriteAllText(baselineSuppressionPath, """ 280var report = File.ReadAllText(reportPath); 301File.WriteAllText(excludedPackagesPath, """ 305File.WriteAllText(suppressionPath, """ 319var report = File.ReadAllText(reportPath); 330File.WriteAllText(Path.Combine(apiDirectory, $"{packageName}.ats.txt"), content);
WorkflowScripts\AutoRerunTransientCiFailuresTests.cs (2)
2228await File.WriteAllTextAsync(inputPath, requestJson); 2256=> File.ReadAllTextAsync(Path.Combine(_repoRoot, relativePath.Replace('/', Path.DirectorySeparatorChar)));
WorkflowScripts\CiWorkflowTests.cs (1)
13var workflow = File.ReadAllText(Path.Combine(RepoRoot.Path, ".github", "workflows", "ci.yml"));
WorkflowScripts\CreateFailingTestIssueWorkflowTests.cs (1)
271await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { operation, payload }, s_jsonOptions));
WorkflowScripts\ExtensionChangelogFinalizedWorkflowTests.cs (5)
307await File.WriteAllTextAsync(changelogPath, content.ReplaceLineEndings("\n")); 316Assert.True(File.Exists(scriptPath), $"Expected helper script at '{ScriptRelativePath}'."); 457await File.WriteAllTextAsync(fullPath, content.ReplaceLineEndings("\n")); 523Assert.True(File.Exists(workflowPath), $"Expected workflow file at '{WorkflowRelativePath}'."); 525return File.ReadAllText(workflowPath);
WorkflowScripts\ExtensionReleaseFastPathWorkflowTests.cs (5)
191Assert.False(File.Exists(RepoPath(".github", "workflows", "copilot-review-dispatch.yml"))); 193var skill = File.ReadAllText(RepoPath(".agents", "skills", "code-review", "SKILL.md")); 211var action = File.ReadAllText( 220var skill = File.ReadAllText(RepoPath(".agents", "skills", "code-review", "SKILL.md")); 398using var reader = new StringReader(File.ReadAllText(RepoPath(".github", "workflows", workflowName)));
WorkflowScripts\ExtensionReleaseWorkflowTests.cs (19)
39var workflow = File.ReadAllText(s_releaseWorkflowPath); 53var prompt = File.ReadAllText(s_changelogWorkflowPath); 54var compiledWorkflow = File.ReadAllText(s_changelogWorkflowLockPath); 167var workflow = File.ReadAllText(s_releaseWorkflowPath); 180using var reader = new StringReader(File.ReadAllText(s_releaseWorkflowPath)); 204var workflow = File.ReadAllText(s_releaseWorkflowPath); 234var workflow = File.ReadAllText(s_changelogWorkflowLockPath); 298(await File.ReadAllTextAsync(fakeGh.CallLogPath)).Contains("--add-label vscode-extension-release", StringComparison.Ordinal), 327var callLog = await File.ReadAllTextAsync(fakeGh.CallLogPath); 358var callLog = (await File.ReadAllTextAsync(fakeGh.CallLogPath)).ReplaceLineEndings("\n"); 550await File.WriteAllTextAsync(bodyPath, new string('a', 65_536)); 569await File.WriteAllTextAsync(bodyPath, new string('a', 65_537)); 584Assert.True(File.Exists(s_releaseNotesGeneratorPath), $"Expected release notes generator at '{s_releaseNotesGeneratorPath}'."); 592await File.WriteAllTextAsync( 633return await File.ReadAllTextAsync(outputPath); 643Assert.True(File.Exists(scriptPath), $"Expected helper script at '{scriptPath}'."); 696using var reader = new StringReader(File.ReadAllText(s_changelogWorkflowLockPath)); 755Assert.True(File.Exists(scriptPath), $"Expected helper script at '{scriptPath}'."); 797await File.WriteAllTextAsync(
WorkflowScripts\MonitorScheduledWorkflowsIntegrationTests.cs (1)
393await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(scenario, s_requestOptions));
WorkflowScripts\MonitorScheduledWorkflowsTests.cs (1)
246await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { operation, payload }, s_jsonOptions));
WorkflowScripts\PrDocsCheckWorkflowTests.cs (2)
81var validator = File.ReadAllText( 217=> File.ReadAllText(Path.Combine(RepoRoot.Path, ".github", "workflows", fileName));
WorkflowScripts\ReportCiFailureIntegrationTests.cs (1)
285await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(scenario, s_requestOptions));
WorkflowScripts\ReportCiFailureTests.cs (1)
82await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { operation, payload }, s_jsonOptions));
WorkflowScripts\ReportPipelineFailureIntegrationTests.cs (1)
291await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(scenario, s_requestOptions));
WorkflowScripts\ReportPipelineFailureTests.cs (1)
140await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { operation, payload }, s_jsonOptions));
WorkflowScripts\ReportSpecializedTestFailuresTests.cs (1)
229await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { operation, payload }, s_jsonOptions));
WorkflowScripts\SelectTestsCommentScriptTests.cs (4)
181File.WriteAllText(path, content); 232await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { script, commentFile, context, liveHeadSha, existingComments }, s_jsonOptions)); 242var response = JsonSerializer.Deserialize<HarnessResponse<CommentScriptResult>>(await File.ReadAllTextAsync(outputPath), s_jsonOptions); 252var lines = File.ReadAllText(Path.Combine(_repoRoot, ".github", "workflows", "tests.yml"))
WorkflowScripts\SpecializedTestFailureRunnerTests.cs (1)
229await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(scenario, s_requestOptions));
WorkflowScripts\TrackingIssueTests.cs (1)
287await File.WriteAllTextAsync(requestPath, JsonSerializer.Serialize(new { operation, payload }, s_jsonOptions));
installer.tasks (7)
GenerateFileVersionProps.cs (2)
136using (var manifestWriter = File.CreateText(PlatformManifestFile)) 167if (File.Exists(filePath))
GenerateRunScript.cs (2)
34if (!File.Exists(TemplatePath)) 40string templateContent = File.ReadAllText(TemplatePath);
GenerateTestSharedFrameworkDepsFile.cs (1)
101using (var depsFileStream = File.Create(Path.Combine(SharedFrameworkDirectory, $"{sharedFxName}.deps.json")))
StaticFileRegeneration\RegenerateThirdPartyNotices.cs (2)
129TpnDocument existingTpn = TpnDocument.Parse(File.ReadAllLines(TpnFile)); 184File.WriteAllText(TpnFile, newTpn.ToString());
Microsoft.Agents.AI.ProjectTemplates.Tests (2)
WellKnownPaths.cs (2)
47if (Directory.Exists(gitPath) || File.Exists(gitPath)) 68if (!File.Exists(dotNetExePath))
Microsoft.Analyzers.Extra.Tests (1)
FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Microsoft.Analyzers.Local.Tests (1)
FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Microsoft.Arcade.Common (10)
CommandFactory.cs (2)
64if (File.Exists(executable + ".exe")) 76if (File.Exists(candidate))
FileSystem.cs (5)
17public bool FileExists(string path) => File.Exists(path); 19public void DeleteFile(string path) => File.Delete(path); 39File.WriteAllText(path, content); 42public virtual void CopyFile(string sourceFileName, string destFileName, bool overwrite = false) => File.Copy(sourceFileName, destFileName, overwrite); 46public FileAttributes GetAttributes(string path) => File.GetAttributes(path);
NupkgInfoFactory.cs (1)
31using Stream stream = File.OpenRead(path);
ZipArchiveManager.cs (2)
29bool archiveExists = File.Exists(archivePath); 32using FileStream fs = File.OpenWrite(archivePath);
Microsoft.AspNetCore.Components.Testing (6)
_generated\0\StartupHook.g.cs (1)
17if (File.Exists(candidatePath))
Infrastructure\E2EManifest.cs (2)
24if (!File.Exists(manifestPath)) 33var json = File.ReadAllText(manifestPath);
Infrastructure\ServerInstance.cs (3)
157File.WriteAllText(stdoutPath, _stdoutBuffer.ToString()); 161File.WriteAllText(stderrPath, _stderrBuffer.ToString()); 170File.WriteAllText(startupPath, exception.ToString());
Microsoft.AspNetCore.Components.Testing.Tasks (3)
GenerateE2EManifest.cs (3)
145if (File.Exists(appHostPath)) 150else if (!isCompiledHarness && File.Exists(appDllPath)) 183using var fileStream = File.Create(ManifestPath);
Microsoft.AspNetCore.Components.WebAssembly (2)
Hosting\WebAssemblyHostBuilder.cs (2)
210if (File.Exists(configFile)) 212var appSettingsJson = File.ReadAllBytes(configFile);
Microsoft.AspNetCore.Components.WebAssembly.Server (2)
DebugProxyLauncher.cs (1)
130if (!File.Exists(debugProxyPath))
src\aspnetcore\src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
Microsoft.AspNetCore.Components.WebView (2)
WebViewManager.cs (2)
284if (File.Exists(manifestPath)) 286using var manifestStream = File.OpenRead(manifestPath);
Microsoft.AspNetCore.DataProtection (10)
Internal\ContainerUtils.cs (4)
34if (!File.Exists(mountsFile)) 39var lines = File.ReadAllLines(mountsFile); 99if (!File.Exists(procFile)) 104var lines = File.ReadAllLines(procFile);
Repositories\FileSystemXmlRepository.cs (6)
111using (var fileStream = File.OpenRead(fullPath)) 147File.Move(tempTempFilename, tempFilename); 152using (var tempFileStream = File.OpenWrite(tempFilename)) 164File.Move(tempFilename, finalFilename); 170File.Copy(tempFilename, finalFilename); 175File.Delete(tempFilename); // won't throw if the file doesn't exist
Microsoft.AspNetCore.DeveloperCertificates.XPlat (28)
src\aspnetcore\src\Shared\CertificateGeneration\CertificateManager.cs (5)
540if (!File.Exists(certificatePath)) 748File.Move(tempFilename, path, overwrite: true); 751File.WriteAllBytes(path, bytes); 776File.Move(tempFilename, keyPath, overwrite: true); 779File.WriteAllBytes(keyPath, pemEnvelope);
src\aspnetcore\src\Shared\CertificateGeneration\MacOSCertificateManager.cs (10)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 159using SafeFileHandle nullHandle = File.OpenNullHandle(); 175File.Delete(tmpFile); 207File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 319File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 339File.WriteAllBytes(certificatePath, certBytes); 457if (File.Exists(certificatePath)) 459File.Delete(certificatePath);
src\aspnetcore\src\Shared\CertificateGeneration\UnixCertificateManager.cs (13)
115if (File.Exists(certPath)) 247if (File.Exists(certPath)) 473if (File.Exists(certPath)) 610if (File.Exists(Path.Combine(searchFolder, command))) 646if (File.Exists(WslInteropPath) || File.Exists(WslInteropLatePath)) 689using SafeFileHandle nullHandle = File.OpenNullHandle(); 709using SafeFileHandle nullHandle = File.OpenNullHandle(); 737using SafeFileHandle nullHandle = File.OpenNullHandle(); 760using SafeFileHandle nullHandle = File.OpenNullHandle(); 820File.Delete(certPath); 1051if (!File.Exists(linkPath)) 1054File.CreateSymbolicLink(linkPath, cert.Name);
Microsoft.AspNetCore.Diagnostics (3)
src\aspnetcore\src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (3)
110if (File.Exists(stackFrame.File)) 112lines = File.ReadLines(stackFrame.File); 124lines = File.ReadLines(fileInfo.PhysicalPath);
Microsoft.AspNetCore.Hosting (5)
src\aspnetcore\src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (3)
110if (File.Exists(stackFrame.File)) 112lines = File.ReadLines(stackFrame.File); 124lines = File.ReadLines(fileInfo.PhysicalPath);
StaticWebAssets\StaticWebAssetsLoader.cs (2)
51if (candidate != null && File.Exists(candidate)) 53return File.OpenRead(candidate);
Microsoft.AspNetCore.HttpLogging (1)
FileLoggerProcessor.cs (1)
273return File.AppendText(fileName);
Microsoft.AspNetCore.InternalTesting (10)
AssemblyTestLog.cs (4)
142if (File.Exists(testOutputFile)) 150if (!File.Exists(testOutputFile)) 280if (File.Exists(fileName)) 282File.Delete(fileName);
HelixHelper.cs (1)
22File.Copy(filePath, uploadPath, overwrite: true);
TestFileOutputContext.cs (1)
67while (File.Exists(path))
xunit\DockerOnlyAttribute.cs (2)
27if (!File.Exists(procFile)) 32var lines = File.ReadAllLines(procFile);
xunit\SkipOnAlpineAttribute.cs (2)
30RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/etc/os-release") && 31File.ReadAllLines("/etc/os-release").Any(line =>
Microsoft.AspNetCore.Mvc.Core (1)
ApplicationParts\RelatedAssemblyAttribute.cs (1)
44return GetRelatedAssemblies(assembly, throwOnError, File.Exists, new AssemblyLoadContextWrapper(loadContext));
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
RazorReferenceManager.cs (1)
79using (var stream = File.OpenRead(path))
Microsoft.AspNetCore.Mvc.Testing (3)
WebApplicationFactory.cs (3)
422var fromFile = File.Exists("MvcTestingAppManifest.json"); 437var data = JsonSerializer.Deserialize(File.ReadAllBytes(file), CustomJsonSerializerContext.Default.IDictionaryStringString)!; 471if (File.Exists(contentRootMarker))
Microsoft.AspNetCore.Mvc.Testing.Tasks (1)
GenerateMvcTestManifestTask.cs (1)
34using var fileStream = File.Create(ManifestPath);
Microsoft.AspNetCore.Razor.Utilities.Shared (1)
src\roslyn\src\Razor\src\Shared\Microsoft.AspNetCore.Razor.SharedUtilities\FileUtilities.cs (1)
75while (File.Exists(uniquePath));
Microsoft.AspNetCore.Server.IIS (3)
src\aspnetcore\src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (3)
110if (File.Exists(stackFrame.File)) 112lines = File.ReadLines(stackFrame.File); 124lines = File.ReadLines(fileInfo.PhysicalPath);
Microsoft.AspNetCore.Server.IntegrationTesting (10)
Deployers\ApplicationDeployer.cs (1)
106if (!File.Exists(executableName))
Deployers\NginxDeployer.cs (5)
155File.WriteAllText(_configFile, DeploymentParameters.ServerConfigTemplateContent); 180if (!File.Exists(pidFile)) 186var pid = File.ReadAllText(pidFile); 197if (File.Exists(_configFile)) 219File.Delete(_configFile);
Deployers\RemoteWindowsDeployer\RemoteWindowsDeployer.cs (2)
186using (var fileStream = File.Open(webConfigFilePath, FileMode.Open)) 325var destinationStream = File.Create(physicalFilePath);
Deployers\SelfHostDeployer.cs (1)
137Logger.LogInformation($"{File.Exists(executableName)}");
xunit\IISExpressAncmSchema.cs (1)
25if (!File.Exists(ancmConfigPath))
Microsoft.AspNetCore.Server.Kestrel.Core (30)
Internal\Certificates\CertificateConfigLoader.cs (1)
137var keyText = File.ReadAllText(keyPath);
src\aspnetcore\src\Shared\CertificateGeneration\CertificateManager.cs (5)
540if (!File.Exists(certificatePath)) 748File.Move(tempFilename, path, overwrite: true); 751File.WriteAllBytes(path, bytes); 776File.Move(tempFilename, keyPath, overwrite: true); 779File.WriteAllBytes(keyPath, pemEnvelope);
src\aspnetcore\src\Shared\CertificateGeneration\MacOSCertificateManager.cs (10)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 159using SafeFileHandle nullHandle = File.OpenNullHandle(); 175File.Delete(tmpFile); 207File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 319File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 339File.WriteAllBytes(certificatePath, certBytes); 457if (File.Exists(certificatePath)) 459File.Delete(certificatePath);
src\aspnetcore\src\Shared\CertificateGeneration\UnixCertificateManager.cs (13)
115if (File.Exists(certPath)) 247if (File.Exists(certPath)) 473if (File.Exists(certPath)) 610if (File.Exists(Path.Combine(searchFolder, command))) 646if (File.Exists(WslInteropPath) || File.Exists(WslInteropLatePath)) 689using SafeFileHandle nullHandle = File.OpenNullHandle(); 709using SafeFileHandle nullHandle = File.OpenNullHandle(); 737using SafeFileHandle nullHandle = File.OpenNullHandle(); 760using SafeFileHandle nullHandle = File.OpenNullHandle(); 820File.Delete(certPath); 1051if (!File.Exists(linkPath)) 1054File.CreateSymbolicLink(linkPath, cert.Name);
TlsConfigurationLoader.cs (1)
157File.Exists(certificatePath))
Microsoft.AspNetCore.SpaProxy (2)
SpaHostingStartup.cs (1)
21if (File.Exists(spaProxyConfigFile))
SpaProxyLaunchManager.cs (1)
300File.WriteAllText(scriptPath, stopScript.ReplaceLineEndings());
Microsoft.AspNetCore.StaticAssets (2)
StaticAssetsEndpointRouteBuilderExtensions.cs (1)
65if (!File.Exists(manifestPath))
StaticAssetsManifest.cs (1)
28using var stream = File.OpenRead(manifestPath);
Microsoft.AspNetCore.WebUtilities (2)
FileBufferingReadStream.cs (1)
249File.Move(tempTempFileName, _tempFileName);
FileBufferingWriteStream.cs (1)
276File.Move(tempTempFileName, tempFileName);
Microsoft.Build (30)
BackEnd\BuildManager\BuildManager.cs (1)
2352File.WriteAllText(logPath, graph.ToDot(targetList));
BackEnd\BuildManager\CacheSerialization.cs (1)
108using (var fileStream = File.OpenRead(inputCacheFile))
BackEnd\BuildManager\CoordinatorClient.cs (2)
492if (File.Exists(coordinatorDll) && 505if (File.Exists(coordinatorExe))
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (1)
569return File.Exists(dllPath) ? dllPath : msbuildLocation;
BackEnd\Components\Scheduler\SchedulingPlan.cs (2)
107using (StreamWriter file = new StreamWriter(File.Open(planName, FileMode.Create))) 161using (StreamReader file = new StreamReader(File.Open(planName, FileMode.Open)))
BackEnd\Shared\BuildRequestConfiguration.cs (2)
788using Stream stream = File.Create(cacheFile); 827using Stream stream = File.OpenRead(cacheFile);
BackEnd\Shared\TargetResult.cs (3)
119using Stream stream = File.OpenRead(cacheFile); 251using Stream stream = File.OpenRead(cacheFile); 321using Stream stream = File.Create(cacheFile);
Construction\Solution\ProjectInSolution.cs (1)
314FileStream fs = File.OpenRead(AbsolutePath);
Construction\Solution\SolutionFile.cs (3)
553fileStream = File.OpenRead(solutionFile); 744fileStream = File.OpenRead(_solutionFile); 1172FileStream fs = File.OpenRead(fullPathToEtpProj);
Evaluation\Expander.Function.cs (2)
425if (_receiverType == typeof(System.IO.File) || _receiverType == typeof(System.IO.Directory) 440if ((_receiverType == typeof(System.IO.File) || _receiverType == typeof(System.IO.Directory))
Evaluation\Expander\WellKnownFunctions.cs (1)
44File.AppendAllText(logFile, $"ReceiverType={receiverType?.FullName}; ObjectInstanceType={objectInstance?.GetType().FullName}; MethodName={methodName}({argSignature})\n");
Evaluation\ParserIgnoreConfiguration.cs (1)
297using (var stream = File.OpenRead(fullPath))
Evaluation\ToolsetElement.cs (2)
99File.Delete(tempFileName + ".config"); 100File.Delete(tempFileName);
Logging\BinaryLogger\BinaryLogger.cs (1)
569File.Copy(FilePath, additionalPath, overwrite: true);
Logging\BinaryLogger\ProjectImportsCollector.cs (1)
270using FileStream fileStream = File.OpenRead(_archiveFilePath);
Logging\ProfilerLogger.cs (1)
296File.WriteAllText(FileToLog, content);
Resources\Constants.cs (2)
249[DynamicDependency(PropertyFunctionMembers, typeof(File))] 318var fileType = new Tuple<string, Type>(null, typeof(File));
src\msbuild\src\Shared\Debugging\PrintLineDebuggerWriters.cs (2)
28File.AppendAllText(file, CsvFormat(string.Empty, callsite, args)); 33File.AppendAllText(errorFile, $"{SimpleFormat(id, callsite, args)}\n{e.Message}\n{e.StackTrace}");
src\msbuild\src\Shared\TypeLoader.cs (1)
267if (string.IsNullOrEmpty(assemblyFilePath) || !File.Exists(assemblyFilePath))
Microsoft.Build.Framework (15)
FileSystem\ManagedFileSystem.cs (5)
49return File.ReadAllText(path); 54return File.ReadAllBytes(path); 129return File.GetAttributes(path); 134return File.GetLastWriteTimeUtc(path); 144return File.Exists(path);
FileUtilities_TempFiles.cs (1)
199File.WriteAllText(file, string.Empty);
FileUtilities.cs (3)
455File.WriteAllText(testFilePath, $"MSBuild process {EnvironmentUtilities.CurrentProcessId} successfully wrote to file."); 456File.Delete(testFilePath); 1064File.Delete(FixFilePath(path));
NativeMethods.cs (3)
576return !File.Exists(pathWithUpperCase.ToLowerInvariant()); 918return File.Exists(path) 919? File.GetLastWriteTimeUtc(path)
Utilities\ProcessExtensions.cs (1)
486byte[] cmdlineBytes = File.ReadAllBytes(cmdlinePath);
Utilities\TaskFactoryUtilities.cs (2)
90File.WriteAllLines(manifestPath, directoriesToAdd); 198string[] directories = File.ReadAllLines(manifestPath);
Microsoft.Build.NuGetSdkResolver (1)
GlobalJsonReader.cs (1)
249json = File.ReadAllText(globalJsonPath);
Microsoft.Build.Tasks.CodeAnalysis (19)
src\roslyn\src\Compilers\Core\MSBuildTask\CopyRefAssembly.cs (6)
36if (!File.Exists(SourcePath)) 42if (File.Exists(DestinationPath)) 70Log.LogMessageFromResources(MessageImportance.Low, "CopyRefAssembly_Changed", SourcePath, File.GetLastWriteTimeUtc(SourcePath).ToString("O"), source, DestinationPath, File.GetLastWriteTimeUtc(DestinationPath).ToString("O"), destination); 87File.Copy(SourcePath, DestinationPath, overwrite: true); 101using (FileStream source = File.OpenRead(path))
src\roslyn\src\Compilers\Core\MSBuildTask\GenerateMSBuildEditorConfig.cs (3)
117if (File.Exists(targetFileName)) 119string existingContents = File.ReadAllText(targetFileName); 126File.WriteAllText(targetFileName, ConfigFileContents, encoding);
src\roslyn\src\Compilers\Core\MSBuildTask\ManagedCompiler.cs (1)
1249if (!File.Exists(reference.ItemSpec))
src\roslyn\src\Compilers\Core\MSBuildTask\ManagedToolTask.cs (1)
85_useAppHost = useAppHost = File.Exists(Path.Combine(GetToolDirectory(), AppHostToolName));
src\roslyn\src\Compilers\Core\MSBuildTask\Utilities.cs (1)
140File.Delete(path);
src\roslyn\src\Compilers\Core\MSBuildTask\Vbc.cs (1)
329File.Move(actualPdbInfo.FullName, desiredLocation);
src\roslyn\src\Compilers\Shared\BuildServerConnection.cs (4)
455if (!File.Exists(processFilePath)) 556if (!File.Exists(serverInfo.processFilePath)) 848if (!File.Exists(FilePath)) 878File.Delete(FilePath);
src\roslyn\src\Compilers\Shared\RuntimeHostInfo.cs (2)
54var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 102if (File.Exists(filePath))
Microsoft.Build.Tasks.Core (72)
AddToWin32Manifest.cs (1)
124: File.OpenRead(path.Value);
AppConfig\AppConfig.cs (1)
35FileStream fs = File.OpenRead(appConfigFilePath);
AssemblyDependency\AssemblyInformation.cs (2)
518using (var stream = File.OpenRead(_sourceFile)) 999using Stream stream = File.OpenRead(path);
AssemblyDependency\GenerateBindingRedirects.cs (1)
354using (XmlReader xr = XmlReader.Create(File.OpenRead(appConfigFile), xrs))
BootstrapperUtil\BootstrapperBuilder.cs (5)
374File.Copy(setupSourceFile, strOutputExe, true); 545FileStream fs = File.OpenRead(resourceFilePath); 1480File.Copy(packageFileSource.Value, strDestinationFileName, true); 1592FileAttributes attribs = File.GetAttributes(strFileName); 1596File.SetAttributes(strFileName, attribs);
Copy.cs (2)
380File.Copy(sourceFileState.Path, destinationFileState.Path, true); 421File.SetAttributes(file.Path, FileAttributes.Normal);
Delete.cs (1)
140File.Delete(filePath);
DependencyFile.cs (1)
67lastModified = File.GetLastWriteTime(FileName);
FileIO\GetFileHash.cs (1)
148using (var stream = File.OpenRead(filePath))
FileIO\ReadLinesFromFile.cs (1)
50string[] textLines = System.IO.File.ReadAllLines(filePath);
FileIO\WriteLinesToFile.cs (6)
36System.IO.File.Move(source, destination, overwrite: true); 182System.IO.File.WriteAllText(temporaryFilePath, contentsAsString, encoding); 226if (System.IO.File.Exists(temporaryFilePath)) 228System.IO.File.Delete(temporaryFilePath); 252System.IO.File.AppendAllText(filePath, contentsAsString, encoding); 308/// account for the encoding preamble (BOM), because <see cref="System.IO.File.WriteAllText(string, string, Encoding)"/>
GenerateApplicationManifest.cs (1)
459using (Stream s = File.Open(inputManifestPath, FileMode.Open, FileAccess.Read, FileShare.Read))
GenerateResource.cs (2)
2959File.Delete(filename); 3642using var fs = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
GetSDKReferenceFiles.cs (1)
968File.Delete(existingCacheFile);
ManifestUtil\ApplicationManifest.cs (1)
530FileStream fs = File.OpenRead(configFile.ResolvedPath);
ManifestUtil\AssemblyIdentity.cs (1)
208FileStream fs = File.OpenRead(path);
ManifestUtil\DeployManifest.cs (1)
218FileStream fs = File.OpenRead(redistListFilePath);
ManifestUtil\LauncherBuilder.cs (3)
109File.Copy(launcher.Value, outputExe.Value, true); 131FileAttributes attribs = File.GetAttributes(strFileName); 135File.SetAttributes(strFileName, attribs);
ManifestUtil\Manifest.cs (1)
384FileStream fs = File.OpenRead(inputPath);
ManifestUtil\ManifestReader.cs (2)
55using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) 145using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
ManifestUtil\ManifestWriter.cs (5)
63using (Stream s = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Write)) 79using (Stream s = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Write)) 146File.Copy(temp, Path.Combine(Util.logPath, n + ".trust-file.xml"), true); 169File.Delete(temp); 194File.Delete(temp);
ManifestUtil\PathUtil.cs (1)
168using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
ManifestUtil\SecurityUtil.cs (1)
715FileStream fs = File.OpenRead(path);
ManifestUtil\TrustInfo.cs (6)
435using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) 474using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) 552using (Stream s = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None)) 643File.Delete(tempPrivilegeDocument); 661s = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None); 665s = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
Move.cs (4)
266File.Move(sourceFile, destinationFile); 314if (targetExists && (File.GetAttributes(newFileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) 326File.Delete(newFileName); 329File.Move(existingFileName, newFileName);
RedistList.cs (1)
704FileStream fs = File.OpenRead(path);
RoslynCodeTaskFactory\RoslynCodeTaskFactory.cs (3)
769File.WriteAllText(sourceCodePath, taskInfo.SourceCode); 856File.Delete(sourceCodePath); 862File.Delete(_assemblyPath);
src\msbuild\src\Shared\Debugging\PrintLineDebuggerWriters.cs (2)
28File.AppendAllText(file, CsvFormat(string.Empty, callsite, args)); 33File.AppendAllText(errorFile, $"{SimpleFormat(id, callsite, args)}\n{e.Message}\n{e.StackTrace}");
StateFileBase.cs (3)
65File.Delete(stateFile); 120using (FileStream s = File.OpenRead(stateFile)) 178File.Delete(stateFile);
TarDirectory.cs (1)
173File.Delete(_destinationFile.FullName);
Touch.cs (6)
167File.Exists, 168File.Create, 169File.GetAttributes, 170File.SetAttributes, 171File.SetLastAccessTime, 172File.SetLastWriteTime);
WriteCodeFragment.cs (1)
133File.WriteAllText(outputFilePath, code); // Overwrites file if it already exists (and can be overwritten)
XmlPoke.cs (1)
162using (Stream stream = File.Create(inputPath))
XmlTaskUtility.cs (1)
89using var stream = File.OpenRead(filePath.Value);
ZipDirectory.cs (1)
93File.Delete(destinationFile.FullName);
Microsoft.Build.Tasks.Git (23)
GitDataReader\GitConfig.Reader.cs (6)
70_fileOpener = fileOpener ?? File.OpenText; 120if (File.Exists(programDataConfig)) 131if (File.Exists(systemConfig)) 142if (File.Exists(xdgConfig)) 152if (File.Exists(globalConfig)) 160if (File.Exists(localConfig))
GitDataReader\GitEnvironment.cs (2)
138var gitExe = paths.FirstOrDefault(dir => !string.IsNullOrWhiteSpace(dir) && File.Exists(PathUtils.CombinePaths(dir, "git.exe"))); 144var gitCmd = paths.FirstOrDefault(dir => !string.IsNullOrWhiteSpace(dir) && File.Exists(PathUtils.CombinePaths(dir, "git.cmd")));
GitDataReader\GitIgnore.cs (2)
105if (!File.Exists(path)) 113reader = File.OpenText(path!);
GitDataReader\GitReferenceResolver.cs (6)
71if (!File.Exists(packedRefsPath)) 79reader = File.OpenText(packedRefsPath); 193var readers = File.ReadAllLines(tablesFilePath) 203stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); 361if (!File.Exists(path)) 384return File.ReadAllText(path).TrimEnd(CharUtils.AsciiWhitespace);
GitDataReader\GitRepository.cs (7)
186File.Exists(dotGitPath) ? ReadDotGitFile(dotGitPath) : null; 282if (!File.Exists(submodulesConfigFile)) 401else if (File.Exists(dotGitPath)) 432content = File.ReadAllText(path); 460if (!File.Exists(Path.Combine(directory, GitHeadFileName))) 468if (File.Exists(commonLinkPath)) 472commonDirectory = Path.Combine(directory, File.ReadAllText(commonLinkPath).TrimEnd(CharUtils.AsciiWhitespace));
Microsoft.Build.Utilities.Core (12)
PlatformManifest.cs (1)
102FileStream fs = File.OpenRead(platformManifestPath);
SDKManifest.cs (1)
320FileStream fs = File.OpenRead(sdkManifestPath);
src\msbuild\src\Shared\Debugging\PrintLineDebuggerWriters.cs (2)
28File.AppendAllText(file, CsvFormat(string.Empty, callsite, args)); 33File.AppendAllText(errorFile, $"{SimpleFormat(id, callsite, args)}\n{e.Message}\n{e.StackTrace}");
ToolLocationHelper.cs (3)
2870FileExists fileExists = new FileExists(File.Exists); 3138FileStream fs = File.OpenRead(redistFilePath); 3587if (!File.Exists(toolPath))
ToolTask.cs (5)
909File.Delete(filePath); 1526File.AppendAllText(_temporaryBatchFile, "#!/bin/sh\n"); // first line for UNIX is ANSI 1528File.AppendAllText(_temporaryBatchFile, AdjustCommandsForOperatingSystem(commandLineCommands), EncodingUtilities.CurrentSystemOemEncoding); 1550File.AppendAllText(_temporaryBatchFile, 1556File.AppendAllText(_temporaryBatchFile, commandLineCommands, encoding);
Microsoft.CodeAnalysis (32)
AssemblyUtilities.cs (2)
39if (File.Exists(satelliteAssemblyPath)) 45if (File.Exists(satelliteAssemblyPath))
CommandLine\CommandLineArguments.cs (1)
578string? resolvedPath = FileUtilities.ResolveRelativePath(reference.FilePath, basePath: null, baseDirectory: BaseDirectory, searchPaths: ReferencePaths, fileExists: File.Exists);
CommandLine\CommonCompiler.CompilerEmitStreamProvider.cs (4)
76File.Delete(_filePath); 84File.Move(_filePath, newFilePath); 87File.SetAttributes(newFilePath, FileAttributes.Hidden); 90File.Delete(newFilePath);
CommandLine\CommonCompiler.cs (1)
131if (!SuppressDefaultResponseFile(args) && File.Exists(responseFile))
Compilation.EmitStream.cs (1)
88File.Delete(tempFilePath);
DiagnosticAnalyzer\AnalyzerAssemblyLoader.Core.cs (1)
278using var stream = File.Open(assemblyPath, FileMode.Open, FileAccess.Read, FileShare.Read);
DiagnosticAnalyzer\AnalyzerAssemblyLoader.cs (1)
319if (File.Exists(filePath))
DiagnosticAnalyzer\ShadowCopyAnalyzerPathResolver.cs (7)
284File.Delete(pair.file); 385if (File.Exists(originalPath)) 401if (File.Exists(cachePath)) 406try { File.Delete(cachePath); } catch { } 407File.Copy(originalPath, shadowCopyPath); 411File.Copy(originalPath, shadowCopyPath); 419File.Copy(originalPath, shadowCopyPath);
FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
FileSystem\ICommonCompilerFileSystem.cs (1)
61public bool FileExists(string filePath) => File.Exists(filePath);
FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
FileSystemExtensions.cs (4)
46using (var outputStream = FileUtilities.CreateFileStreamChecked(File.Create, outputPath, nameof(outputPath))) 47using (var pdbStream = (pdbPath == null ? null : FileUtilities.CreateFileStreamChecked(File.Create, pdbPath, nameof(pdbPath)))) 48using (var xmlDocStream = (xmlDocPath == null ? null : FileUtilities.CreateFileStreamChecked(File.Create, xmlDocPath, nameof(xmlDocPath)))) 49using (var win32ResourcesStream = (win32ResourcesPath == null ? null : FileUtilities.CreateFileStreamChecked(File.OpenRead, win32ResourcesPath, nameof(win32ResourcesPath))))
RuleSet\RuleSetInclude.cs (2)
112if (File.Exists(includePath)) 121if (File.Exists(includePath))
SourceFileResolver.cs (1)
121return File.Exists(resolvedPath);
StrongName\StrongNameFileSystem.cs (2)
34return File.ReadAllBytes(fullPath); 40return File.Exists(fullPath);
StrongName\StrongNameKeys.cs (1)
112var fileContent = ImmutableArray.Create(File.ReadAllBytes(keyFilePath));
XmlFileResolver.cs (1)
87return File.Exists(resolvedPath);
Microsoft.CodeAnalysis.Analyzers (5)
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Microsoft.CodeAnalysis.AnalyzerUtilities (4)
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.CodeAnalysis.CodeStyle (2)
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Microsoft.CodeAnalysis.CSharp.Workspaces (7)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (4)
228using var stream = File.OpenRead(filePath); 235using var stream = File.Open(Path, FileMode.Create, FileAccess.Write); 573else if (!File.Exists(resolvedProjectPath)) 668if (!File.Exists(resolvedFilePath))
SyncedSource\FileBasedPrograms\VirtualProjectBuilder.cs (3)
176if (!File.Exists(entryPointFilePath)) 189using var stream = File.OpenRead(entryPointFilePath); 417if (!File.Exists(filePath))
Microsoft.CodeAnalysis.ExternalAccess.HotReload (2)
Api\HotReloadMSBuildWorkspace.cs (2)
220using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)) 236using var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Microsoft.CodeAnalysis.Features (19)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs (1)
100if (hasDocWithSuppressionsName || File.Exists(suppressionsFilePath))
Completion\FileSystemCompletionHelper.cs (1)
83return IOUtilities.PerformIO(() => (File.GetAttributes(fullPath) & (FileAttributes.Hidden | FileAttributes.System)) == 0, false);
Diagnostics\Service\DiagnosticAnalyzerComparer.cs (2)
39if (path == null || !File.Exists(path)) 42return File.GetLastWriteTimeUtc(path);
EditAndContinue\TraceLog.cs (2)
45File.AppendAllLines(path, [entry]); 84File.WriteAllBytes(path, [.. bytes]);
MetadataAsSource\DecompilationMetadataAsSourceFileProvider.cs (2)
111if (!File.Exists(fileInfo.TemporaryFilePath)) 187if (!skipWritingFile && !File.Exists(fileInfo.TemporaryFilePath))
PdbSourceDocument\ImplementationAssemblyLookupService.cs (5)
69while (File.Exists(dllPath)) 88using var fileStream = File.OpenRead(dllPath); 137if (IOUtilities.PerformIO(() => File.Exists(pathToTry))) 161using var fr = File.OpenRead(frameworkXml); 183if (IOUtilities.PerformIO(() => File.Exists(dllPath)))
PdbSourceDocument\PdbFileLocatorService.cs (3)
77pdbStream = IOUtilities.PerformIO(() => File.OpenRead(pdbResult.PdbFilePath)); 124if (File.Exists(fileName)) 125return File.OpenRead(fileName);
PdbSourceDocument\PdbSourceDocumentLoaderService.cs (3)
50if (File.Exists(filePath) && 88using (var file = File.OpenWrite(filePath)) 166if (PathUtilities.IsAbsolute(sourceDocument.FilePath) && File.Exists(sourceDocument.FilePath))
Microsoft.CodeAnalysis.NetAnalyzers (2)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
37File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 95using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.CodeAnalysis.Razor.Compiler (1)
Language\DefaultRazorProjectItem.cs (1)
61public override bool Exists => _fileInfo?.Exists ?? System.IO.File.Exists(PhysicalPath);
Microsoft.CodeAnalysis.ResxSourceGenerator (4)
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.CodeAnalysis.Scripting (15)
Hosting\AssemblyLoader\InteractiveAssemblyLoader.cs (1)
333if (File.Exists(path))
Hosting\AssemblyLoader\MetadataShadowCopyProvider.cs (5)
513if (File.Exists(dir) || Directory.Exists(dir)) 527if (File.Exists(dir)) 593if (File.Exists(Path.Combine(assemblyDirectory, docSubdirectory, docFileName))) 603if (File.Exists(Path.Combine(assemblyDirectory, docFileName))) 616File.Copy(originalPath, shadowCopyPath, overwrite: true);
Hosting\Resolvers\RuntimeMetadataReferenceResolver.cs (2)
126if (File.Exists(fullPath)) 198=> TrustedPlatformAssemblies.TryGetValue(name, out var path) && File.Exists(path) ? CreateFromFile(path, properties) : null;
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\Compilers\Shared\GlobalAssemblyCacheHelpers\GacFileResolver.cs (1)
77return File.Exists(path) ? path : null;
src\roslyn\src\Compilers\Shared\GlobalAssemblyCacheHelpers\MonoGlobalAssemblyCache.cs (5)
46if (!File.Exists(corlibFriendPath)) 54if (File.Exists(corlibFriendPath)) 89if (File.Exists(assemblyPath)) 112if (!File.Exists(assemblyPath)) 189if (!File.Exists(assemblyPath))
Microsoft.CodeAnalysis.VisualBasic (1)
CommandLine\VisualBasicCommandLineParser.vb (1)
1600If File.Exists(filePath) Then
Microsoft.CodeAnalysis.Workspaces (16)
Rename\ConflictEngine\MutableConflictResolution.cs (2)
102if (File.Exists(document.FilePath)) 109while (File.Exists(newDocumentFilePath))
src\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerAssemblyLoader.Core.cs (1)
278using var stream = File.Open(assemblyPath, FileMode.Open, FileAccess.Read, FileShare.Read);
src\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerAssemblyLoader.cs (1)
319if (File.Exists(filePath))
src\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\ShadowCopyAnalyzerPathResolver.cs (7)
284File.Delete(pair.file); 385if (File.Exists(originalPath)) 401if (File.Exists(cachePath)) 406try { File.Delete(cachePath); } catch { } 407File.Copy(originalPath, shadowCopyPath); 411File.Copy(originalPath, shadowCopyPath); 419File.Copy(originalPath, shadowCopyPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Utilities\Documentation\XmlDocumentationProvider.cs (1)
49if (!File.Exists(xmlDocCommentFilePath))
Workspace\ProjectSystem\ProjectSystemProjectFactory.cs (1)
111? VersionStamp.Create(File.GetLastWriteTimeUtc(creationInfo.FilePath))
Microsoft.CodeAnalysis.Workspaces.MSBuild (15)
MSBuild\BuildHostProcessManager.cs (3)
37private static bool IsLoadedFromNuGetPackage => File.Exists(Path.Combine(MSBuildWorkspaceDirectory, "..", "..", "microsoft.codeanalysis.workspaces.msbuild.nuspec")); 167if (dotnetPath is null || processPath == dotnetPath || !File.Exists(dotnetPath)) 329if (!File.Exists(buildHostPath))
MSBuild\MSBuildProjectLoader.Worker_ResolveReferences.cs (5)
320if (outputRefFilePath != null && !File.Exists(outputRefFilePath)) 326if (outputFilePath != null && !File.Exists(outputFilePath)) 343return outputFilePaths.Any(path => builder.Contains(path) && File.Exists(path)); 356if ((builder.Contains(outputFilePath) && File.Exists(outputFilePath)) || 357(builder.Contains(outputRefFilePath) && File.Exists(outputRefFilePath)))
MSBuild\MSBuildProjectLoader.Worker.cs (1)
336if (fullPath != null && File.Exists(fullPath))
MSBuild\MSBuildWorkspace.cs (2)
553if (File.Exists(fullPath)) 555File.Delete(fullPath);
MSBuild\PathResolver.cs (2)
34if (!File.Exists(absolutePath)) 59if (!File.Exists(absolutePath))
MSBuild\SolutionFileReader.SolutionFilterReader.cs (2)
27using var document = JsonDocument.Parse(File.ReadAllText(filterFilename)); 40if (!File.Exists(solutionFilename))
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (1)
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts (1)
MonoMSBuildDiscovery.cs (1)
78.FirstOrDefault(File.Exists);
Microsoft.Data.Analysis (1)
TextFieldParser.cs (1)
585if (!File.Exists(path))
Microsoft.Data.Analysis.Tests (3)
DataFrame.IOTests.cs (2)
1333if (File.Exists(SQLitePath)) 1334File.Delete(SQLitePath);
src\Microsoft.Data.Analysis\TextFieldParser.cs (1)
585if (!File.Exists(path))
Microsoft.Deployment.DotNet.Releases (10)
ReleaseFile.cs (4)
117string tempPath = !File.Exists(destinationPath) ? destinationPath : Path.GetTempFileName(); 126File.Delete(tempPath); 133File.Delete(destinationPath); 134File.Move(tempPath, destinationPath);
Utils.cs (6)
58using Stream source = File.Open(address.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read); 59using Stream destination = File.Create(fileName); 67using FileStream stream = File.Create(fileName); 98if (!File.Exists(fileName)) 103using FileStream stream = File.OpenRead(fileName); 135if (!File.Exists(path))
Microsoft.Diagnostics.NETCore.Client (4)
DiagnosticsIpc\IpcTransport.cs (2)
380lines = File.ReadAllLines(string.Format(_procStatusPathFormat, hostPid)); 442environData = File.ReadAllBytes(string.Format(_procEnvironPathFormat, hostPid));
DiagnosticsIpc\IpcUnixDomainSocket.cs (2)
38if (_ownsSocketFile && !string.IsNullOrEmpty(_path) && File.Exists(_path)) 40File.Delete(_path);
Microsoft.DotNet.ApiCompat.Task (4)
ValidateAssembliesTask.cs (4)
165if (File.Exists(SemaphoreFile)) 166File.Delete(SemaphoreFile); 171File.Create(SemaphoreFile).Dispose(); 172File.SetLastWriteTimeUtc(SemaphoreFile, DateTime.UtcNow);
Microsoft.DotNet.ApiSymbolExtensions (9)
AssemblySymbolLoader.cs (8)
183using FileStream stream = File.OpenRead(archivePath); 284syntaxTrees.Add(CSharpSyntaxTree.ParseText(File.ReadAllText(filePath))); 311if (File.Exists(possiblePath)) 362else if (File.Exists(path)) 387using FileStream stream = File.OpenRead(path); 456using FileStream resolvedStream = File.OpenRead(Path.Combine(fullReferencePath, assemblyReferenceName)); 468if (File.Exists(potentialPath)) 471using FileStream resolvedStream = File.OpenRead(potentialPath);
Filtering\DocIdSymbolFilter.cs (1)
35foreach (string docId in ReadDocIdsFromList(File.ReadAllLines(docIdsFile)))
Microsoft.DotNet.Arcade.Sdk (23)
src\CheckRequiredDotNetVersion.cs (2)
48lastWrite = File.GetLastWriteTimeUtc(globalJsonPath); 73globalJson = File.ReadAllText(globalJsonPath);
src\DownloadFile.cs (4)
62if (File.Exists(DestinationPath) && !Overwrite) 115if (File.Exists(filePath)) { 117File.Copy(filePath, DestinationPath, overwrite: true); 194using (var outStream = File.Create(DestinationPath))
src\ExtractNgenMethodList.cs (1)
97using (var stream = File.Open(AssemblyFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
src\GenerateChecksums.cs (3)
34if (!File.Exists(item.ItemSpec)) 42using (FileStream stream = File.OpenRead(item.ItemSpec)) 48File.WriteAllText(destinationPath, checksum);
src\GenerateResxSource.cs (1)
364File.WriteAllText(OutputPath, result);
src\GenerateSourcePackageSourceLinkTargetsFile.cs (1)
38File.WriteAllText(OutputPath, GetOutputFileContent(), Encoding.UTF8);
src\InstallDotNetCore.cs (4)
48if (!File.Exists(GlobalJsonPath)) 53if (!File.Exists(DotNetInstallScript)) 59var jsonContent = File.ReadAllText(GlobalJsonPath); 87if (!File.Exists(VersionsPropsPath))
src\LocateDotNet.cs (3)
47var lastWrite = File.GetLastWriteTimeUtc(globalJsonPath); 58var globalJson = File.ReadAllText(globalJsonPath); 71var dotNetDir = paths.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(p => File.Exists(Path.Combine(p, fileName)));
src\SetCorFlags.cs (1)
67using (var stream = File.Open(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
src\Unsign.cs (1)
34using (var stream = File.Open(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
src\ValidateLicense.cs (2)
38var actualLines = File.ReadAllLines(LicensePath, Encoding.UTF8); 39var expectedLines = File.ReadAllLines(ExpectedLicensePath, Encoding.UTF8);
Microsoft.DotNet.Build.Tasks.Feed (3)
src\PushToBuildStorage.cs (3)
587File.Copy(sourceFileName, destFileName, overwrite); 592File.Copy(sourceFileName, destFileName, overwrite); 607File.SetAttributes(destFile.FullName, FileAttributes.Normal);
Microsoft.DotNet.Build.Tasks.FileCatalog (5)
CatalogBuilder.cs (1)
104File.WriteAllBytes(path, Build());
CatalogEntry.cs (1)
38using (FileStream stream = File.OpenRead(filePath))
GenerateFileCatalog.cs (3)
40if (File.Exists(OutputPath)) 42File.Delete(OutputPath); 59if (!File.Exists(path))
Microsoft.DotNet.Build.Tasks.Installers (39)
src\CreateChangelogFile.cs (1)
40using GZipStream stream = new(File.Create(ChangelogOutputPath), CompressionLevel.Optimal);
src\CreateControlFile.cs (1)
45using Stream stream = File.Create(ControlFileOutputPath);
src\CreateDebPackage.cs (3)
34using ArWriter arWriter = new(File.Open(OutputDebPackagePath, FileMode.Create), false); 36using Stream controlFile = File.OpenRead(ControlFile.ItemSpec); 38using Stream dataFile = File.OpenRead(DataFile.ItemSpec);
src\CreateLightCommandPackageDrop.cs (1)
56File.Copy(WixProjectFile, destinationPath, true);
src\CreateMD5SumsFile.cs (2)
32using FileStream outputFile = File.Create(OutputFile); 38using FileStream fileStream = File.OpenRead(file.ItemSpec);
src\CreateRpmPackage.cs (4)
130builder.AddScript(script.GetMetadata("Kind"), File.ReadAllText(script.ItemSpec)); 151if (!File.Exists(trigger.ItemSpec)) 157builder.AddFileTrigger(kind, File.ReadAllText(trigger.ItemSpec), paths); 175using (CpioReader reader = new(File.OpenRead(Payload), leaveOpen: false))
src\CreateWixBuildWixpack.cs (18)
115File.Copy(projectPath, destPath, overwrite: true); 148if (File.Exists(OutputFile)) 150File.Delete(OutputFile); 202File.Copy(includeFile, tempFilePath, overwrite: true); 212File.Delete(tempFilePath); 432File.WriteAllText(Path.Combine(WixpackWorkingDir, "create.rsp"), string.Join(System.Environment.NewLine, commandLineArgs)); 446File.WriteAllText(Path.Combine(WixpackWorkingDir, "create.cmd"), createCmdFileContents.ToString()); 511if (!File.Exists(xmlPath)) 519File.Copy(xmlPath, copiedXmlPath, overwrite: true); 639string content = File.ReadAllText(file); 649if (File.Exists(includeFilePath)) 667if (File.Exists(potentialPath)) 683File.WriteAllText(file, content); 749string input = File.ReadAllText(sourceFile); 933File.WriteAllText(sourceFile, output.ToString()); 1021if (File.Exists(source)) 1024File.Copy(source, destPath, overwrite: true); 1108File.Copy(file, Path.Combine(destDir, Path.GetFileName(file)), overwrite: true);
src\CreateWixCommandPackageDropBase.cs (8)
68if(File.Exists(OutputFile)) 70File.Delete(OutputFile); 129File.WriteAllText(commandFilename, commandString.ToString()); 145File.Copy(wixSrcFile.ItemSpec, newWixSrcFilePath, true); 177File.Copy(locItem.ItemSpec, destinationPath, true); 293if (File.Exists(possiblePath)) 301else if (File.Exists(oldPath)) 331File.Copy(oldPath, Path.Combine(outputPath, newRelativePath), true);
src\GenerateMacOSDistributionFile.cs (1)
120using XmlWriter writer = XmlWriter.Create(File.Create(DestinationFile));
Microsoft.DotNet.Build.Tasks.Packaging (23)
GenerateNuSpec.cs (4)
125using (var file = File.Create(OutputFileName)) 133if (!File.Exists(OutputFileName)) 138var oldSource = Encoding.UTF8.GetString(File.ReadAllBytes(OutputFileName)); 181using (var stream = File.OpenRead(InputFileName))
GetApplicableAssetsFromPackages.cs (1)
208if (File.Exists(pdbPath))
GetAssemblyReferences.cs (1)
50if (!File.Exists(assemblyItem.ItemSpec))
GetLayoutFiles.cs (1)
139if (File.Exists(symbolSource))
GetPackageDescription.cs (1)
55if (!File.Exists(descriptionPath))
GetRuntimeJsonValues.cs (2)
31if (string.IsNullOrEmpty(JsonFilename) || !File.Exists(JsonFilename)) 34JObject jObject = JObject.Parse(File.ReadAllText(JsonFilename));
GetRuntimeTargets.cs (2)
30if (string.IsNullOrEmpty(JsonFilename) || !File.Exists(JsonFilename)) 33JObject jObject = JObject.Parse(File.ReadAllText(JsonFilename));
NuGetPack.cs (4)
173if (!File.Exists(nuspecPath)) 209using (var nuspecFile = File.Open(nuspecPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)) 316using (var fileStream = File.Create(nupkgPath)) 394file.Source = File.Exists(packedPackageSourcePath) ? packedPackageSourcePath : fileName;
PackageIndex.cs (2)
67using (var file = File.OpenText(packageIndexFile)) 84using (var file = File.CreateText(path))
PackageItem.cs (1)
76if (_version == null && IsDll && File.Exists(SourcePath))
PackageMetadata.cs (1)
18string packageMetadata = File.ReadAllText(path);
PackageReport.cs (2)
40using (var file = File.CreateText(path)) 55using (var file = File.OpenText(path))
UpdatePackageIndex.cs (1)
91PackageIndex index = File.Exists(indexFilePath) ?
Microsoft.DotNet.Build.Tasks.Templating (3)
GenerateFileFromTemplate.cs (3)
71if (!File.Exists(TemplateFile)) 78string template = File.ReadAllText(TemplateFile); 98File.WriteAllBytes(ResolvedOutputPath, resultBytes);
Microsoft.DotNet.Build.Tasks.VisualStudio (8)
OptProf\FindLatestDrop.cs (1)
41DropName = GetLatestDropName(File.ReadAllText(DropListPath));
OptProf\GenerateTrainingInputFiles.cs (4)
50config = OptProfTrainingConfiguration.Deserialize(File.ReadAllText(ConfigurationFile, Encoding.UTF8)); 99using (var archive = new ZipArchive(File.Open(vsixPath, FileMode.Open), ZipArchiveMode.Read)) 155while (File.Exists(fullPath)); 157using (var writer = new StreamWriter(File.Open(fullPath, FileMode.Create, FileAccess.Write, FileShare.Read)))
OptProf\GenerateTrainingPropsFile.cs (1)
55File.WriteAllText(outputFilePath,
OptProf\GetRunSettingsSessionConfiguration.cs (2)
55var buildDropName = GetTestsDropName(File.ReadAllText(BootstrapperInfoPath, Encoding.UTF8)); 56var (testContainersString, testCaseFilterString) = GetTestContainersAndFilters(File.ReadAllText(ConfigurationFile, Encoding.UTF8), ConfigurationFile);
Microsoft.DotNet.Build.Tasks.Workloads (13)
EmbeddedTemplates.cs (2)
42if (File.Exists(destinationPath)) 44File.Delete(destinationPath);
Swix\ComponentSwixProject.cs (1)
49using StreamWriter swrWriter = File.AppendText(componentSwr);
Utils.cs (7)
68FileAttributes oldAttributes = File.GetAttributes(fileName); 69File.SetAttributes(fileName, oldAttributes & ~FileAttributes.ReadOnly); 71string content = File.ReadAllText(fileName); 78File.WriteAllText(fileName, content, encoding); 79File.SetAttributes(fileName, oldAttributes); 201if (File.Exists(path)) 203File.Delete(path);
Wix\WixToolTaskBase.cs (1)
42if (!File.Exists(toolPath))
WorkloadPackageBase.cs (2)
246File.Copy(PackagePath, Path.Combine(DestinationDirectory, Path.GetFileName(PackagePath)), overwrite: true); 268File.Delete(file);
Microsoft.DotNet.Cli.CoreUtils (2)
DotnetVersionFile.cs (2)
33Exists = File.Exists(versionFilePath); 37IEnumerable<string> lines = File.ReadLines(versionFilePath);
Microsoft.DotNet.Cli.Definitions (5)
Commands\Test\TestCommandDefinition.cs (2)
92string jsonText = File.ReadAllText(globalJsonPath); 113if (File.Exists(globalJsonPath))
Common\TargetPlatformOptions.cs (2)
120string[] currentRuntimeIdentifiers = File.Exists(runtimeIdentifierChainPath) ? [.. File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l))] : [];
src\sdk\src\Resolvers\Microsoft.DotNet.NativeWrapper\EnvironmentProvider.cs (1)
47.FirstOrDefault(File.Exists);
Microsoft.DotNet.Cli.Telemetry (1)
Implementation\FileSystemTelemetryBlobStorage.cs (1)
65File.Move(lockedPath, lockedPath[..atSignIndex]);
Microsoft.DotNet.Cli.Utils (13)
EnvironmentProvider.cs (2)
82.FirstOrDefault(File.Exists); 95.FirstOrDefault(File.Exists);
Extensions\LockFileFormatExtensions.cs (1)
17if (!File.Exists(path))
FrameworkDependencyFile.cs (1)
105using (Stream depsFileStream = File.OpenRead(_depsFilePath ?? string.Empty))
Muxer.cs (1)
47if (File.Exists(muxerPathMaybe))
PathUtility.cs (6)
86if (!File.Exists(path)) 91File.Delete(path); 104return !File.Exists(path); 348if (!File.Exists(p) && (!allowDirectories || !Directory.Exists(p))) 364File.GetAttributes(path).HasFlag(FileAttributes.Directory); 383if (File.Exists(filePath))
RuntimeEnvironment.cs (2)
128if (File.Exists("/etc/os-release")) 130var lines = File.ReadAllLines("/etc/os-release");
Microsoft.DotNet.CMake.Sdk (6)
src\CreateCMakeFileApiQuery.cs (1)
34File.WriteAllText(queryFile, string.Empty);
src\GetCMakeArtifactsFromFileApi.cs (5)
67string indexJson = File.ReadAllText(indexFile); 83if (!File.Exists(codeModelFile)) 91string codeModelJson = File.ReadAllText(codeModelFile); 166if (!File.Exists(targetFile)) 174string targetJson = File.ReadAllText(targetFile);
Microsoft.DotNet.GenFacades (9)
ClearAssemblyReferenceVersions.cs (1)
30using (FileStream stream = File.Open(Assembly, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
NotSupportedAssemblyGenerator.cs (5)
47if (!string.IsNullOrEmpty(ApiExclusionListPath) && File.Exists(ApiExclusionListPath)) 49apiExclusions = File.ReadAllLines(ApiExclusionListPath); 57if (!File.Exists(sourceFile)) 79syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile), new CSharpParseOptions(languageVersion)); 90File.WriteAllText(outputPath, text);
SourceGenerator.cs (1)
91File.WriteAllText(_outputSourcePath, BuildAliasDeclarations(externAliases) + sb.ToString());
TypeParser.cs (2)
143if (!File.Exists(sourceFile)) 147SyntaxTree tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile), options);
Microsoft.DotNet.HotReload.Utils.Generator (7)
BaselineProject.cs (1)
95if (!File.Exists(outputAsm)) {
DeltaProject.cs (5)
49var metaStream = File.Create(dinfo.Dmeta); 50var ilStream = File.Create(dinfo.Dil); 51var pdbStream = File.Create(dinfo.Dpdb); 52var updateHandlerInfoStream = File.Create(dinfo.UpdateHandlerInfo); 76await using (var contents = File.OpenRead (change.Update)) {
Runners\ScriptRunner.cs (1)
42using var s = File.OpenWrite(OutputPath);
Microsoft.DotNet.HotReload.Utils.Generator.Tasks (2)
HotReloadDeltaGeneratorComputeScriptOutputs.cs (2)
56if (!System.IO.File.Exists(DeltaScript)) 132using var stream = System.IO.File.OpenRead(scriptPath);
Microsoft.DotNet.HotReload.Watch (7)
Build\ProjectGraphFactory.cs (1)
117if (!File.Exists(projectPath))
HotReload\HotReloadDotNetWatcher.cs (3)
732if (!File.Exists(targetPath)) 744File.Copy(sourcePath, targetPath, overwrite: false); 1170File.Delete(solutionFile);
Process\LaunchSettingsProfile.cs (1)
49File.ReadAllText(launchSettingsPath),
src\sdk\src\Dotnet.Watch\HotReloadClient\HotReloadStaticAssetUpdate.cs (1)
24var blob = await File.ReadAllBytesAsync(asset.FilePath, cancellationToken);
src\sdk\src\Dotnet.Watch\HotReloadClient\Web\StaticWebAssetsManifest.cs (1)
113stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
Microsoft.DotNet.InternalAbstractions (8)
FileWrapper.cs (8)
10return File.Exists(path); 15return File.ReadAllText(path); 20return File.OpenRead(path); 36using (File.Create(path)) 43File.WriteAllText(path, content); 48File.Move(source, destination); 53File.Copy(sourceFileName, destFileName); 58File.Delete(path);
Microsoft.DotNet.MacOsPkg.Core (9)
AppBundle.cs (1)
29File.Exists(Path.Combine(path, "Contents", "Info.plist"));
MacOsPkgCore.cs (2)
20if (!File.Exists(srcPath) || !Utilities.IsPkg(srcPath) && !Utilities.IsAppBundle(srcPath)) 102if (!File.Exists(srcPath) || (!Utilities.IsPkg(srcPath) && !Utilities.IsAppBundle(srcPath)))
Package.cs (4)
68File.Move(tempDest, packageName); 112File.Move(tempDest, app); 151File.Delete(appZip); 190File.Delete(payloadFilePath);
Utilities.cs (2)
29else if (File.Exists(path)) 31File.Delete(path);
Microsoft.DotNet.NativeWrapper (2)
EnvironmentProvider.cs (1)
47.FirstOrDefault(File.Exists);
HostFxrLocator.cs (1)
48fileExists: File.Exists);
Microsoft.DotNet.NuGetRepack.Tasks (9)
src\NuGetVersionUpdater.cs (3)
117File.Copy(packagePath, tempPathOpt); 255File.Delete(tempPathOpt); 374File.Copy(package.TempPathOpt, finalPath, overwrite: true);
src\ReplacePackageParts.cs (5)
113File.Copy(SourcePackage, tempPackagePath); 181replacementStream = File.OpenRead(replacementFilePath); 219using (var archive = new ZipArchive(File.Open(tempPackagePath, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) 227File.Copy(tempPackagePath, NewPackage, overwrite: true); 231File.Delete(tempPackagePath);
src\UpdatePackageVersionTask.cs (1)
78File.WriteAllLines(Path.Combine(OutputDirectory, "PreReleaseDependencies.txt"), preReleaseDependencies.Distinct());
Microsoft.DotNet.PackageTesting (1)
VerifyClosure.cs (1)
390using (var file = File.Create(dependencyGraphFilePath))
Microsoft.DotNet.PackageValidation (1)
Package.cs (1)
130if (!File.Exists(Path.GetFullPath(packagePath)))
Microsoft.DotNet.ProjectTools (11)
LaunchSettings\LaunchSettings.cs (3)
42bool hasLaunchSetttings = File.Exists(launchSettingsPath); 46bool hasRunJson = File.Exists(runJsonPath); 78var launchSettingsJsonContents = File.ReadAllText(launchSettingsPath);
src\sdk\src\Cli\Microsoft.DotNet.FileBasedPrograms\FileLevelDirectiveHelpers.cs (4)
228using var stream = File.OpenRead(filePath); 235using var stream = File.Open(Path, FileMode.Create, FileAccess.Write); 573else if (!File.Exists(resolvedProjectPath)) 668if (!File.Exists(resolvedFilePath))
src\sdk\src\Cli\Microsoft.DotNet.FileBasedPrograms\VirtualProjectBuilder.cs (4)
176if (requireFileToExist && !File.Exists(entryPointFilePath)) 187if (!requireFileToExist && !File.Exists(entryPointFilePath)) 195using var stream = File.OpenRead(entryPointFilePath); 423if (!File.Exists(filePath))
Microsoft.DotNet.SdkResolver (2)
NETCoreSdkResolver.cs (2)
138if (!File.Exists(minimumVersionFilePath)) 146return Version.Parse(File.ReadLines(minimumVersionFilePath).First().Trim());
Microsoft.DotNet.SharedFramework.Sdk (7)
src\arcade\src\Microsoft.DotNet.PackageTesting\VerifyClosure.cs (1)
390using (var file = File.Create(dependencyGraphFilePath))
src\CreateFrameworkListFile.cs (1)
261File.WriteAllText(TargetFile, frameworkManifest.ToString());
src\FileUtilities.cs (1)
41using (var stream = File.OpenRead(path))
src\GenerateSharedFrameworkDepsFile.cs (3)
118using var depsStream = File.Create(depsFilePath); 125if (File.Exists(depsFilePath)) 127File.Delete(depsFilePath);
src\ValidateFileVersions.cs (1)
96if (File.Exists(filePath))
Microsoft.DotNet.SourceBuild.Tasks (13)
src\UsageReport\WritePackageUsageData.cs (5)
153File.Open( 163using (var stream = File.OpenRead(Path.Combine(RootDir, relativePath))) 184using (var file = File.OpenRead(Path.Combine(RootDir, assetFile))) 255File.WriteAllText(DataFile, data.ToXml().ToString()); 276var root = JObject.Parse(File.ReadAllText(path));
src\UsageReport\WriteUsageReports.cs (7)
63UsageData data = UsageData.Parse(XElement.Parse(File.ReadAllText(DataFile))); 79if (File.Exists(ProdConBuildManifestFile)) 81var xml = XElement.Parse(File.ReadAllText(ProdConBuildManifestFile)); 93if (File.Exists(PoisonedReportFile)) 95foreach (string line in File.ReadAllLines(PoisonedReportFile)) 161File.WriteAllText( 173var content = File.ReadAllText(item.ItemSpec);
src\WriteBuildOutputProps.cs (1)
77using (var outStream = File.Open(OutputPath, FileMode.Create))
Microsoft.DotNet.StrongName (1)
Signing.cs (1)
168if (!TryParseKey(File.ReadAllBytes(keyFile).ToImmutableArray(), out ImmutableArray<byte> snkPublicKey, out RSAParameters? privateKey) ||
Microsoft.DotNet.TemplateLocator (22)
src\sdk\src\Cli\dotnet\Commands\Workload\InstallStateContents.cs (2)
31return File.Exists(path) ? FromString(File.ReadAllText(path)) : new InstallStateContents();
src\sdk\src\Common\WorkloadFileBasedInstall.cs (2)
16=> dotnetDir is not null && File.Exists(GetUserInstallFilePath(dotnetDir, sdkFeatureBand)); 23File.WriteAllText(filePath, "");
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\SdkDirectoryWorkloadManifestProvider.cs (9)
110if (!File.Exists(knownManifestIdsFilePath)) 115if (File.Exists(knownManifestIdsFilePath)) 119foreach (var manifestId in File.ReadAllLines(knownManifestIdsFilePath).Where(l => !string.IsNullOrEmpty(l))) 352() => File.OpenRead(workloadManifestPath), 488.Where(dir => File.Exists(Path.Combine(dir, "WorkloadManifest.json"))) 500else if (File.Exists(Path.Combine(manifestDirectory, "WorkloadManifest.json"))) 505var manifestContents = WorkloadManifestReader.ReadWorkloadManifest(manifestId, File.OpenRead(manifestPath), manifestPath); 559if (File.Exists(Path.Combine(specifiedManifestDirectory, "WorkloadManifest.json"))) 669if (File.Exists(globalJsonPath))
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\TempDirectoryWorkloadManifestProvider.cs (1)
38() => File.OpenRead(workloadManifestPath),
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadInstallType.cs (1)
29dotnetDir is not null && File.Exists(Path.Combine(
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadManifestReader.Localization.cs (2)
18static readonly Func<string, bool> _fileExists = File.Exists; 43return File.OpenRead(localizationPath);
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadResolver.cs (3)
31string[] currentRuntimeIdentifiers = File.Exists(runtimeIdentifierChainPath) ? 32File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray() : 355_fileExistOverride?.Invoke(packPath) ?? File.Exists(packPath) :
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadSet.cs (2)
76var newWorkloadSet = WorkloadSet.FromJson(File.ReadAllText(jsonFile), defaultFeatureBand); 100if (File.Exists(Path.Combine(path, "baseline.workloadset.json")))
Microsoft.DotNet.VersionTools.Cli (1)
FileSystemProxy.cs (1)
25File.Move(sourceFileName, destFileName);
Microsoft.DotNet.XliffTasks (10)
Model\Document.cs (5)
31using FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); 72using (FileStream stream = File.Open(tempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) 79if (File.Exists(path)) 81File.Replace( 89File.Move(sourceFileName: tempPath, destFileName: path);
Tasks\TransformTemplates.cs (4)
80File.Copy(templatePath, cultureSpecificTemplateFile, overwrite: true); 86File.Copy(projectFileFullPath, Path.Combine(localizedTemplateDirectory, Path.GetFileName(projectNode.Attribute("File").Value)), overwrite: true); 114File.Copy(Path.Combine(TranslatedOutputDirectory, localizedFileName), templateItemDestinationPath, overwrite: true); 119File.Copy(templateItemFullPath, templateItemDestinationPath, overwrite: true);
Tasks\XlfTask.cs (1)
83if (File.Exists(path))
Microsoft.Extensions.AI.Abstractions (2)
parent\parent\parent\eng\MSBuild\parent\parent\src\LegacySupport\FilePolyfills\FilePolyfills.cs (2)
16/// Provides polyfill extension members for <see cref="File"/> for older frameworks. 21extension(File)
Microsoft.Extensions.AI.Abstractions.Tests (72)
Contents\DataContentTests.cs (60)
320await File.WriteAllBytesAsync(tempPath, testData); 332if (File.Exists(tempPath)) 334File.Delete(tempPath); 347await File.WriteAllBytesAsync(tempPath, testData); 359if (File.Exists(tempPath)) 361File.Delete(tempPath); 374await File.WriteAllBytesAsync(tempPath, testData); 385if (File.Exists(tempPath)) 387File.Delete(tempPath); 400await File.WriteAllBytesAsync(tempPath, testData); 413if (File.Exists(tempPath)) 415File.Delete(tempPath); 467Assert.True(File.Exists(actualPath)); 468Assert.Equal(testData, await File.ReadAllBytesAsync(actualPath)); 472if (File.Exists(tempPath)) 474File.Delete(tempPath); 494Assert.True(File.Exists(actualPath)); 495Assert.Equal(testData, await File.ReadAllBytesAsync(actualPath)); 499if (File.Exists(tempPath)) 501File.Delete(tempPath); 526Assert.True(File.Exists(actualPath)); 527Assert.Equal(testData, await File.ReadAllBytesAsync(actualPath)); 555Assert.True(File.Exists(actualPath)); 556Assert.Equal(testData, await File.ReadAllBytesAsync(actualPath)); 582Assert.True(File.Exists(actualPath)); 586if (File.Exists(tempPath)) 588File.Delete(tempPath); 611Assert.True(File.Exists(expectedAbsolute)); 612Assert.Equal(testData, await File.ReadAllBytesAsync(expectedAbsolute)); 616if (File.Exists(expectedAbsolute)) 618File.Delete(expectedAbsolute); 640Assert.True(File.Exists(savedPath)); 641Assert.Equal(testData, await File.ReadAllBytesAsync(savedPath)); 669Assert.True(File.Exists(expectedAbsolute)); 670Assert.Equal(testData, await File.ReadAllBytesAsync(expectedAbsolute)); 674if (File.Exists(expectedAbsolute)) 676File.Delete(expectedAbsolute); 718await File.WriteAllBytesAsync(filePath, testData); 753Assert.True(File.Exists(savedPath)); 754Assert.Equal(testData, await File.ReadAllBytesAsync(savedPath)); 774await File.WriteAllBytesAsync(tempPath, new byte[] { 1, 2, 3 }); 784if (File.Exists(tempPath)) 786File.Delete(tempPath); 810if (File.Exists(tempPath)) 812File.Delete(tempPath); 850Assert.True(File.Exists(expectedPath)); 851Assert.Equal(testData, await File.ReadAllBytesAsync(expectedPath)); 879Assert.True(File.Exists(filePath)); 880Assert.Equal(testData, await File.ReadAllBytesAsync(filePath)); 902await File.WriteAllBytesAsync(tempPath, testData); 911if (File.Exists(tempPath)) 913File.Delete(tempPath); 934Assert.Equal(testData, await File.ReadAllBytesAsync(savedPath)); 938if (File.Exists(tempPath)) 940File.Delete(tempPath); 954await File.WriteAllBytesAsync(tempPath, originalContent); 964Assert.True(File.Exists(tempPath)); 965byte[] actualContent = await File.ReadAllBytesAsync(tempPath); 970if (File.Exists(tempPath)) 972File.Delete(tempPath);
Files\HostedFileClientExtensionsTests.cs (11)
65await File.WriteAllBytesAsync(tempFile, fileContent); 94File.Delete(tempFile); 138Assert.Equal(data, await File.ReadAllBytesAsync(tempFile)); 142File.Delete(tempFile); 163Assert.Equal(data, await File.ReadAllBytesAsync(savedPath)); 188Assert.Equal(data, await File.ReadAllBytesAsync(savedPath)); 220Assert.True(File.Exists(expectedAbsolute)); 221Assert.Equal(data, await File.ReadAllBytesAsync(expectedAbsolute)); 225File.Delete(expectedAbsolute); 233await File.WriteAllBytesAsync(tempFile, new byte[] { 1, 2, 3 }); 247File.Delete(tempFile);
parent\parent\parent\eng\MSBuild\parent\parent\src\LegacySupport\FilePolyfills\FilePolyfills.cs (1)
21extension(File)
Microsoft.Extensions.AI.Evaluation.Console (5)
Telemetry\DeviceIdHelper.cs (3)
92if (File.Exists(cacheFilePath)) 94_deviceId = File.ReadAllText(cacheFilePath); 124File.WriteAllText(cacheFilePath, deviceId);
Telemetry\TelemetryConstants.cs (2)
112_firstUseSentinelFileExists = File.Exists(_firstUseSentinelFilePath); 167await File.WriteAllBytesAsync(_firstUseSentinelFilePath, []).ConfigureAwait(false);
Microsoft.Extensions.AI.Evaluation.Reporting (10)
Storage\DiskBasedResponseCache.CacheEntry.cs (4)
33using FileStream cacheEntryFile = File.OpenRead(cacheEntryFilePath); 49using FileStream cacheEntryFile = File.OpenRead(cacheEntryFilePath); 64using FileStream cacheEntryFile = File.Create(cacheEntryFilePath); 72using FileStream cacheEntryFile = File.Create(cacheEntryFilePath);
Storage\DiskBasedResponseCache.cs (6)
73return File.ReadAllBytes(contentsFilePath); 95return await File.ReadAllBytesAsync(contentsFilePath, cancellationToken).ConfigureAwait(false); 201File.WriteAllBytes(contentsFilePath, value); 218await File.WriteAllBytesAsync(contentsFilePath, value, cancellationToken).ConfigureAwait(false); 304bool contentsFileExists = File.Exists(contentsFilePath); 305bool entryFileExists = File.Exists(entryFilePath);
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (2)
DiskBased\PathValidationTests.cs (1)
396File.WriteAllText(Path.Combine(longRoot, "file.txt"), string.Empty);
ScenarioRunResultTests.cs (1)
322File.WriteAllText(witnessPath, testModule);
Microsoft.Extensions.AI.OpenAI.Tests (3)
OpenAIHostedFileClientIntegrationTests.cs (2)
246Assert.True(File.Exists(savedPath)); 247string savedContent = File.ReadAllText(savedPath);
OpenAIResponseClientIntegrationTests.cs (1)
183File.WriteAllBytes(tempPath, imageContent.Data.ToArray());
Microsoft.Extensions.AI.Templates.Tests (2)
WellKnownPaths.cs (2)
47if (Directory.Exists(gitPath) || File.Exists(gitPath)) 68if (!File.Exists(dotNetExePath))
Microsoft.Extensions.DataIngestion.Markdig (1)
MarkdownReader.cs (1)
23string fileContent = await File.ReadAllTextAsync(source.FullName, cancellationToken).ConfigureAwait(false);
Microsoft.Extensions.DataIngestion.MarkItDown (1)
MarkItDownReader.cs (1)
130File.Delete(inputFilePath);
Microsoft.Extensions.DataIngestion.Tests (5)
IngestionPipelineTests.cs (2)
53File.WriteAllText(_withTable.FullName, FirstFileContent); 69File.WriteAllText(_withImage.FullName, secondFileContent);
Readers\DocumentReaderConformanceTests.cs (2)
50await File.WriteAllTextAsync(filePath, "This is a test file for cancellation token."); 65File.Delete(filePath);
Writers\SqliteVectorStoreWriterTests.cs (1)
15public void Dispose() => File.Delete(_tempFile);
Microsoft.Extensions.DependencyModel (4)
FileWrapper.cs (4)
14return File.Exists(path); 19return File.ReadAllText(path); 24return File.OpenRead(path); 42File.Create(path).Dispose();
Microsoft.Extensions.DotNetDeltaApplier (1)
src\sdk\src\Dotnet.Watch\HotReloadAgent.Host\StartupHook.cs (1)
61return File.Exists(path) ? AssemblyLoadContext.Default.LoadFromAssemblyPath(path) : null;
Microsoft.Extensions.FileProviders.Embedded (2)
EmbeddedFileProvider.cs (1)
70_lastModified = File.GetLastWriteTimeUtc(assemblyLocation);
ManifestEmbeddedFileProvider.cs (1)
135result = File.GetLastWriteTimeUtc(assemblyLocation);
Microsoft.Extensions.FileProviders.Physical (1)
PollingWildCardChangeToken.cs (1)
172return FileSystemInfoHelper.GetFileLinkTargetLastWriteTimeUtc(filePath) ?? File.GetLastWriteTimeUtc(filePath);
Microsoft.Extensions.Hosting.Systemd (1)
SystemdHelpers.cs (1)
66byte[] comm = File.ReadAllBytes("/proc/" + ppidString + "/comm");
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (2)
NoRemoteCallHandler.cs (1)
30var fileContent = File.ReadAllBytes(responseFilePath);
NoRemoteCallNotSeekableHandler.cs (1)
33var fileContent = File.ReadAllBytes(responseFilePath);
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Logging\Internal\NoRemoteCallHandler.cs (1)
26_fileContent = File.ReadAllBytes(responseFilePath);
Microsoft.Extensions.Http.Resilience.Tests (3)
BuildTransitive\GrpcNetClientFactoryVersionTargetTests.cs (3)
243File.WriteAllText(projectPath, project); 410return File.Exists(repoDotnetPath) ? repoDotnetPath : dotnetFileName; 427if (File.Exists(targetPath))
Microsoft.Extensions.Logging.AzureAppServices (1)
FileLoggerProvider.cs (1)
52using (var streamWriter = File.AppendText(fullName))
Microsoft.Extensions.ML (1)
ModelLoaders\FileModelLoader.cs (1)
40if (!File.Exists(filePath))
Microsoft.Extensions.ML.Tests (3)
FileLoaderTests.cs (1)
74File.WriteAllText("testdata.txt", "test");
PredictionEnginePoolTests.cs (2)
85using var stream = File.OpenRead(Path.Combine("TestModels", "SentimentModel.zip")); 113using var stream = File.OpenRead(Path.Combine("TestModels", "SentimentModel.zip"));
Microsoft.Extensions.ServiceDiscovery.Dns (6)
DnsSrvServiceEndpointProviderFactory.cs (6)
87if (File.Exists(s_serviceAccountNamespacePath)) 89return File.ReadAllText(s_serviceAccountNamespacePath).Trim(); 97if (!File.Exists(s_resolveConfPath)) 104var lines = File.ReadAllLines(s_resolveConfPath); 134if (!File.Exists(tokenPath)) 140return File.Exists(certPath);
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (1)
Program.cs (1)
61fuzzer.FuzzTarget(File.ReadAllBytes(inputFile));
Microsoft.Gen.ComplianceReports (1)
ComplianceReportsGenerator.cs (1)
112File.WriteAllText(Path.Combine(_directory, _fileName), report, Encoding.UTF8);
Microsoft.Gen.ComplianceReports.Unit.Tests (9)
GeneratorTests.cs (9)
64if (File.Exists(goldenReportFile)) 67var d = await RunGenerator(File.ReadAllText(inputFile), tmp, options); 70var golden = File.ReadAllText(goldenReportFile); 71var generated = File.ReadAllText(tmp); 85File.Delete(tmp); 92_ = await RunGenerator(File.ReadAllText(inputFile), goldenReportFile, options); 130var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options: options); 153var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options: options); 155Assert.True(File.Exists(Path.Combine(fullReportPath, "ComplianceReport.json")));
Microsoft.Gen.ContextualOptions.Unit.Tests (21)
EmitterTests.cs (7)
27.ParseCompilationUnit(File.ReadAllText("TestClasses/Struct1.cs")) 46.ParseCompilationUnit(File.ReadAllText("TestClasses/Class2A.cs")) 50.ParseCompilationUnit(File.ReadAllText("TestClasses/Class2B.cs")) 78.ParseCompilationUnit(File.ReadAllText("TestClasses/Record1.cs")) 106.ParseCompilationUnit(File.ReadAllText("TestClasses/NamespacelessRecord.cs")) 133sources.Add(File.ReadAllText(file)); 149var golden = File.ReadAllText($"GoldenFiles/Microsoft.Gen.ContextualOptions/Microsoft.Gen.ContextualOptions.ContextualOptionsGenerator/ContextualOptions.g.cs");
ParserTests.cs (5)
24File.ReadAllText("TestClasses/ClassWithUnusableProperties.txt"), 41File.ReadAllText("TestClasses/NamespacelessRecord.cs"), 58File.ReadAllText("TestClasses/NonPartialClass.txt"), 73File.ReadAllText("TestClasses/StaticClass.txt"), 88File.ReadAllText("TestClasses/RefStruct.txt"),
SyntaxContextReceiverTests.cs (9)
24File.ReadAllText("TestClasses/Class1.cs"), 25File.ReadAllText("TestClasses/Struct1.cs"), 26File.ReadAllText("TestClasses/Record1.cs"), 47File.ReadAllText("TestClasses/Class1.cs"), 48File.ReadAllText("TestClasses/Struct1.cs"), 49File.ReadAllText("TestClasses/Record1.cs"), 63File.ReadAllText("TestClasses/Class2A.cs"), 64File.ReadAllText("TestClasses/Class2B.cs"), 83var sources = new[] { File.ReadAllText("TestClasses/ClassWithNoAttribute.cs"), };
Microsoft.Gen.Logging.Unit.Tests (1)
EmitterTests.cs (1)
28sources.Add(File.ReadAllText(file));
Microsoft.Gen.MetadataExtractor (3)
ComplianceReportsGenerator.cs (1)
112File.WriteAllText(Path.Combine(_directory, _fileName), report, Encoding.UTF8);
MetadataReportsGenerator.cs (1)
110File.WriteAllText(Path.Combine(path, _fileName), reportStringBuilder.ToString(), Encoding.UTF8);
MetricsReportsGenerator.cs (1)
86File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
Microsoft.Gen.MetadataExtractor.Unit.Tests (11)
GeneratorTests.cs (11)
84if (File.Exists(goldenReportPath)) 86var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 89var golden = await File.ReadAllTextAsync(goldenReportPath); 90var generated = await File.ReadAllTextAsync(generatedReportPath); 104File.Delete(generatedReportPath); 112_ = await RunGenerator(await File.ReadAllTextAsync(inputFile), options, reportFileName: goldenFileName); 131var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 133Assert.False(File.Exists(Path.Combine(Path.GetTempPath(), ReportFilename))); 155var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 181var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 183Assert.True(File.Exists(Path.Combine(fullReportPath, ReportFilename)));
Microsoft.Gen.Metrics.Unit.Tests (3)
EmitterTests.cs (3)
26sources.Add(File.ReadAllText(file)); 48var goldenCache = File.ReadAllText($"{generatedContentPath}/Factory.g.cs"); 49var goldenMetrics = File.ReadAllText($"{generatedContentPath}/Metrics.g.cs");
Microsoft.Gen.MetricsReports (1)
MetricsReportsGenerator.cs (1)
86File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
Microsoft.Gen.MetricsReports.Unit.Tests (11)
GeneratorTests.cs (11)
49if (File.Exists(goldenReportPath)) 51var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 54var golden = await File.ReadAllTextAsync(goldenReportPath); 55var generated = await File.ReadAllTextAsync(generatedReportPath); 69File.Delete(generatedReportPath); 76_ = await RunGenerator(await File.ReadAllTextAsync(inputFile), options, reportFileName: goldenFileName); 91var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 93Assert.False(File.Exists(Path.Combine(Path.GetTempPath(), ReportFilename))); 111var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 134var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 136Assert.True(File.Exists(Path.Combine(fullReportPath, ReportFilename)));
Microsoft.Maui (3)
Fonts\FileSystemEmbeddedFontLoader.cs (3)
57 if (File.Exists(filePath)) 68 using (var fileStream = File.Create(filePath)) 79 File.Delete(filePath);
Microsoft.Maui.Controls.Build.Tasks (1)
XamlCTask.cs (1)
164 if (!File.Exists(Assembly))
Microsoft.Maui.Resizetizer (22)
AndroidAdaptiveIconGenerator.cs (4)
148 if (File.Exists(adaptiveIconDestination) && File.Exists(adaptiveIconRoundDestination)) 159 File.WriteAllText(adaptiveIconDestination, adaptiveIconXmlStr); 160 File.WriteAllText(adaptiveIconRoundDestination, adaptiveIconXmlStr);
AppleIconAssetsGenerator.cs (1)
88 File.WriteAllText(appIconSetContentsFile, appIconContentsJson.Replace("\t", " "));
CreatePartialInfoPlistTask.cs (1)
36 using (var f = File.CreateText(plistFilename))
GenerateSplashStoryboard.cs (2)
92 using var writer = File.CreateText(storyboardFile); 103 using var writer = File.CreateText(storyboardFile);
Resizer.cs (1)
73 File.Copy(Info.Filename, destination, true);
ResizetizeImages.cs (1)
122 File.SetLastWriteTimeUtc(itemSpec, DateTime.UtcNow);
SkiaSharpAppIconTools.cs (3)
18 var hasBackground = !string.IsNullOrWhiteSpace(info.Filename) && File.Exists(info.Filename); 19 var hasForeground = !string.IsNullOrWhiteSpace(info.ForegroundFilename) && File.Exists(info.ForegroundFilename); 75 using var wrapper = File.Create(destination);
SkiaSharpTools.cs (1)
213 using var stream = File.Create(destination);
TizenSplashUpdater.cs (2)
44 if (File.Exists(destination)) 108 using var stream = File.Create(destFilePath);
Utils.cs (5)
56 var exists = File.Exists(path); 57 var modified = exists ? File.GetLastWriteTimeUtc(path) : System.DateTime.MinValue; 63 if (checkExists && !File.Exists(source)) 66 var attributes = File.GetAttributes(source); 68 File.SetAttributes(source, attributes & ~FileAttributes.ReadOnly);
WindowsIconGenerator.cs (1)
50 using BinaryWriter writer = new BinaryWriter(File.Create(destination));
Microsoft.ML.AutoML (2)
AutoMLExperiment\ITrialResultManager.cs (1)
130if (!File.Exists(filePath))
Experiment\ModelContainer.cs (1)
27using (var fs = File.Create(fileInfo.FullName))
Microsoft.ML.AutoML.Samples (3)
AutoFit\BinaryClassificationExperiment.cs (1)
44using (FileStream fs = File.Create(ModelPath))
AutoFit\MulticlassClassificationExperiment.cs (1)
45using (FileStream fs = File.Create(ModelPath))
AutoFit\RegressionExperiment.cs (1)
45using (FileStream fs = File.Create(ModelPath))
Microsoft.ML.AutoML.Tests (6)
DatasetUtil.cs (3)
205if (File.Exists(relativeFilePath)) 228if (File.Exists(Path.Combine(destFolder, flag))) 232File.Create(Path.Combine(destFolder, flag));
TrialResultManagerTest.cs (2)
80var fileContent = File.ReadAllText(tempFilePath); 85File.Delete(tempFilePath);
UserInputValidationTests.cs (1)
188File.Create(emptyFilePath).Dispose();
Microsoft.ML.CodeGenerator (1)
Utils.cs (1)
181File.WriteAllText($"{outPutBaseDir}/{fileName}", fileContent);
Microsoft.ML.Core (11)
ComponentModel\AssemblyLoadingUtils.cs (1)
34if (!File.Exists(path))
Data\IFileHandle.cs (1)
140File.Delete(_fullPath);
Data\Repository.cs (1)
409File.Delete(path);
Utilities\PathUtils.cs (2)
106if (File.Exists(candidate)) 115if (File.Exists(candidate))
Utilities\ResourceManagerUtils.cs (6)
111if (File.Exists(filePath) || !string.IsNullOrEmpty(error)) 169if (File.Exists(filePath)) 181File.Delete(filePath); 251if (File.Exists(path)) 256if (File.Exists(path)) 290File.Move(tempPath, path);
Microsoft.ML.Core.Tests (39)
UnitTests\FileSource.cs (6)
35File.WriteAllText(file1, "Unit Test"); 36File.WriteAllText(file2, "Unit Test"); 60File.WriteAllText(fileDataA, "Unit Test"); 61File.WriteAllText(fileDataB, "Unit Test"); 70File.WriteAllText(fileDataSA, "Unit Test"); 71File.WriteAllText(fileDataSB, "Unit Test");
UnitTests\TestEntryPoints.cs (26)
242File.WriteAllLines(epListPath, epListContents); 248using (var file = File.OpenWrite(manifestPath)) 269File.WriteAllLines(path, epListContents); 275using (var file = File.OpenWrite(jPath)) 610File.WriteAllLines(jsonPath, new[] { inputGraph }); 738File.WriteAllLines(jsonPath, new[] { inputGraph }); 886File.WriteAllLines(jsonPath, new[] { inputGraph }); 1047File.WriteAllLines(jsonPath, new[] { inputGraph }); 1190File.WriteAllLines(jsonPath, new[] { inputGraph }); 1337File.WriteAllLines(jsonPath, new[] { inputGraph }); 1434File.WriteAllLines(jsonPath, new[] { inputGraph }); 2231using (var file = File.OpenWrite(summaryPath)) 2241using (var file = File.OpenWrite(summaryKvpPath)) 2324File.WriteAllLines(jsonPath, new[] { inputGraph }); 2374File.WriteAllLines(jsonPath, new[] { inputGraph }); 2419File.WriteAllLines(jsonPath, new[] { inputGraph }); 2465File.WriteAllLines(jsonPath, new[] { inputGraph }); 2520File.WriteAllLines(jsonPath, new[] { inputGraph }); 2635File.WriteAllLines(jsonPath, new[] { inputGraph }); 2860File.WriteAllLines(dataFile, new[] { 3255File.WriteAllLines(jsonPath, new[] { inputGraph }); 3324File.WriteAllLines(jsonPath, new[] { inputGraph }); 4412File.WriteAllLines(jsonPath, new[] { inputGraph }); 4517File.WriteAllLines(dataFile, new[] { 6587using (var stream = File.OpenRead(modelPath)) 6663using (var f = File.Open(outputPath, FileMode.Create, FileAccess.Write, FileShare.None))
UnitTests\TestModelLoad.cs (2)
27using (var modelStream = File.OpenRead(Path.Combine("TestModels", "BinaryLoader-v3.11.0.0.zip"))) 45using (var modelStream = File.OpenRead(Path.Combine("TestModels", "ConcatTransform.zip")))
UnitTests\TestResourceDownload.cs (5)
67if (File.Exists(Path.Combine(saveToDir, fileName))) 96if (File.Exists(Path.Combine(saveToDir, fileName))) 124if (!File.Exists(GetOutputPath("copyto", "sentiment.emd"))) 140if (File.Exists(GetOutputPath("copyto", "sentiment.emd"))) 141File.Delete(GetOutputPath("copyto", "sentiment.emd"));
Microsoft.ML.Data (8)
DataLoadSave\Binary\BinaryLoaderSaverCatalog.cs (1)
50if (!File.Exists(path))
DataLoadSave\Text\TextLoaderSaverCatalog.cs (1)
313if (!File.Exists(path) && StreamUtils.ExpandWildCards(path).Length < 1)
Model\ModelOperationsCatalog.cs (4)
71using (var stream = File.Create(filePath)) 118using (var stream = File.Create(filePath)) 217using (var stream = File.OpenRead(filePath)) 294using (var stream = File.OpenRead(filePath))
Utilities\StreamUtils.cs (2)
65if (File.Exists(pattern)) 158if (!File.Exists(currentPattern))
Microsoft.ML.EntryPoints (4)
JsonUtils\ExecuteGraphCommand.cs (4)
45_host.CheckUserArg(args.GraphPath != null && File.Exists(args.GraphPath), nameof(args.GraphPath), "Graph path does not exist"); 54graph = JObject.Parse(File.ReadAllText(_path)); 118using (var fs = File.OpenRead(path)) 124using (var fs = File.OpenRead(path))
Microsoft.ML.GenAI.Core.Tests (1)
CausalLMDatasetTest.cs (1)
25using Stream remoteStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model"));
Microsoft.ML.GenAI.LLaMA (3)
LlamaForCausalLM.cs (2)
103var modelConfig = JsonSerializer.Deserialize<LlamaConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 136var modelConfig = JsonSerializer.Deserialize<LlamaConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
LlamaTokenizerHelper.cs (1)
53return TiktokenTokenizer.Create(File.OpenRead(modelFilePath), preTokenizer, normalizer: null, specialTokens: _specialTokens);
Microsoft.ML.GenAI.Mistral (3)
MistralForCausalLM.cs (2)
58var modelConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 86var modelConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
MistralTokenizerHelper.cs (1)
98var modelStream = File.OpenRead(modelPath);
Microsoft.ML.GenAI.Phi (6)
Phi2\Phi2ForCausalLM.cs (1)
59var modelConfig = JsonSerializer.Deserialize<Phi2Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Phi2\Phi2TokenizerHelper.cs (2)
25using var vocabStream = File.OpenRead(vocabPath); 26using var mergesStream = File.OpenRead(mergesPath);
Phi3\Phi3ForCausalLM.cs (2)
60var modelConfig = JsonSerializer.Deserialize<Phi3Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 88var modelConfig = JsonSerializer.Deserialize<Phi3Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Phi3\Phi3TokenizerHelper.cs (1)
35var modelStream = File.OpenRead(modelPath);
Microsoft.ML.GenAI.Samples (1)
Mistral\Mistral_7B_Instruct.cs (1)
76var mistralConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(Path.Combine(weightFolder, configName))) ?? throw new ArgumentNullException(nameof(configName));
Microsoft.ML.ImageAnalytics (2)
ImageLoader.cs (2)
251var bytes = File.ReadAllBytes(path); 312imageBuffer = File.ReadAllBytes(path);
Microsoft.ML.IntegrationTests (12)
DataIO.cs (2)
122using (var file = File.Create(filePath)) 131using (var file = File.Create(filePath))
ModelFiles.cs (7)
108using (var file = File.OpenRead(modelPath)) 165using (var fs = File.OpenRead(modelAndSchemaPath)) 167using (var fs = File.OpenRead(compositeLoaderModelPath)) 183using (var fs = File.OpenRead(loaderAndTransformerModelPath)) 285using (var fs = File.OpenRead(modelPath)) 340using (var fs = File.OpenRead(modelPath)) 479using (var fs = File.OpenRead(filename))
ONNX.cs (3)
52using (var file = File.Create(modelPath)) 102using (var file = File.Create(modelPath)) 154using (var file = File.Create(modelPath))
Microsoft.ML.Maml (1)
HelpCommand.cs (1)
490File.WriteAllText(_xmlFilename, content.ToString());
Microsoft.ML.OnnxTransformer (4)
OnnxTransform.cs (2)
263Host.CheckIO(File.Exists(options.ModelFile), "Model file {0} does not exists.", options.ModelFile); 424ctx.SaveBinaryStream("OnnxModel", w => { w.WriteByteArray(File.ReadAllBytes(Model.ModelStream.Name)); });
OnnxUtils.cs (2)
409File.WriteAllBytes(tempModelFile, modelBytes); 434using (var fileStream = File.Create(tempModelFile))
Microsoft.ML.OnnxTransformerTest (8)
OnnxTransformTests.cs (8)
241using FileStream fileStream = File.OpenRead(modelFile); 286File.Delete(tempPath); 337File.Delete(tempPath); 791var modelInBytes = File.ReadAllBytes(modelFile); 797Assert.True(File.Exists(onnxModel.ModelStream.Name)); 802Assert.False(File.Exists(onnxModel.ModelStream.Name)); 815Assert.True(File.Exists(onnxModel.ModelStream.Name)); 821Assert.True(File.Exists(onnxModel.ModelStream.Name));
Microsoft.ML.PerformanceTests (16)
BenchmarkBase.cs (1)
44if (File.Exists(filePath))
Harness\ProjectGenerator.cs (2)
38=> File.WriteAllText(artifactsPaths.ProjectFilePath, $@" 70return string.Join(Environment.NewLine, File.ReadAllLines(csproj.FullName).Where(line => line.Contains("<NativeAssemblyReference")));
ImageClassificationBench.cs (5)
161if (File.Exists(relativeFilePath)) 170File.Delete(relativeFilePath); 197if (File.Exists(Path.Combine(destFolder, flag))) return; 201File.Create(Path.Combine(destFolder, flag)); 233if (!overwrite && File.Exists(filename))
Numeric\Ranking.cs (5)
28if (!File.Exists(_mslrWeb10kValidate)) 31if (!File.Exists(_mslrWeb10kTrain)) 79if (!File.Exists(_mslrWeb10kTest)) 82if (!File.Exists(_mslrWeb10kValidate)) 85if (!File.Exists(_mslrWeb10kTrain))
RffTransform.cs (1)
24if (!File.Exists(_dataPathDigits))
Text\MultiClassClassification.cs (2)
25if (!File.Exists(_dataPathWiki)) 102if (!File.Exists(_dataPathWiki))
Microsoft.ML.Predictor.Tests (8)
CmdLine\CmdIndenterTest.cs (1)
48using (var writer = File.CreateText(outPath))
CmdLine\CmdLine.cs (1)
348using (var writer = File.CreateText(outPath))
ResultProcessor\TestResultProcessor.cs (1)
47File.WriteAllText(filePath, reader.ReadToEnd());
TestIniModels.cs (2)
540using (Stream iniStream = File.Create(modelIniPath)) 582using (Stream iniStream = File.Create(modelIniPath))
TestPredictors.cs (3)
1751File.WriteAllText(path, 1761File.WriteAllText(path, 1772File.WriteAllText(path,
Microsoft.ML.ResultProcessor (4)
ResultProcessor.cs (4)
717if (!File.Exists(filename)) 720rawLines = File.ReadAllLines(filename); 836var lines = File.ReadAllLines(filename); 1082? File.CreateText(cmd.OutputFile) : Console.Out);
Microsoft.ML.Samples (34)
Dynamic\DataOperations\LoadingSvmLight.cs (1)
19using (var fs = File.CreateText(fileName))
Dynamic\DataOperations\LoadingText.cs (1)
24using (var fs = File.CreateText(fileName))
Dynamic\ModelOperations\OnnxConversion.cs (2)
71using (var stream = File.Create("sample_onnx_conversion_1.onnx")) 79using (var stream = File.Create("sample_onnx_conversion_2.onnx"))
Dynamic\ModelOperations\SaveLoadModel.cs (1)
35using (var file = File.OpenRead("model.zip"))
Dynamic\TensorFlow\ImageClassification.cs (3)
26if (!File.Exists(modelLocation)) 120if (File.Exists(dataFile)) 141Stream inStream = File.OpenRead(path);
Dynamic\Trainers\MulticlassClassification\ImageClassification\ImageClassificationDefault.cs (5)
97using (var file = File.OpenRead("model.zip")) 232Image = File.ReadAllBytes(file), 264if (File.Exists(relativeFilePath)) 296if (File.Exists(Path.Combine(destFolder, flag))) return; 301File.Create(Path.Combine(destFolder, flag));
Dynamic\Trainers\MulticlassClassification\ImageClassification\LearningRateSchedulingCifarResnetTransferLearning.cs (5)
132using (var file = File.OpenRead("model.zip")) 262Image = File.ReadAllBytes(file), 296if (File.Exists(relativeFilePath)) 328if (File.Exists(Path.Combine(destFolder, flag))) return; 342File.Create(Path.Combine(destFolder, flag));
Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningEarlyStopping.cs (4)
122using (var file = File.OpenRead("model.zip")) 252if (File.Exists(relativeFilePath)) 284if (File.Exists(Path.Combine(destFolder, flag))) return; 298File.Create(Path.Combine(destFolder, flag));
Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningTrainTestSplit.cs (5)
114using (var file = File.OpenRead("model.zip")) 241Image = File.ReadAllBytes(file), 273if (File.Exists(relativeFilePath)) 305if (File.Exists(Path.Combine(destFolder, flag))) return; 319File.Create(Path.Combine(destFolder, flag));
Dynamic\Transforms\TimeSeries\DetectAnomalyBySrCnn.cs (1)
95using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectChangePointBySsa.cs (1)
104using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectIidChangePoint.cs (1)
102using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectIidSpike.cs (1)
87using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectSpikeBySsa.cs (1)
98using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\Forecasting.cs (1)
78using (var file = File.OpenRead("model.zip"))
Dynamic\Transforms\TimeSeries\ForecastingWithConfidenceInterval.cs (1)
83using (var file = File.OpenRead("model.zip"))
Microsoft.ML.Samples.GPU (22)
docs\e4e90a0f3c9b109a\LearningRateSchedulingCifarResnetTransferLearning.cs (5)
132using (var file = File.OpenRead("model.zip")) 262Image = File.ReadAllBytes(file), 296if (File.Exists(relativeFilePath)) 328if (File.Exists(Path.Combine(destFolder, flag))) return; 342File.Create(Path.Combine(destFolder, flag));
docs\samples\Microsoft.ML.Samples\Dynamic\TensorFlow\ImageClassification.cs (3)
26if (!File.Exists(modelLocation)) 120if (File.Exists(dataFile)) 141Stream inStream = File.OpenRead(path);
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ImageClassificationDefault.cs (5)
97using (var file = File.OpenRead("model.zip")) 232Image = File.ReadAllBytes(file), 264if (File.Exists(relativeFilePath)) 296if (File.Exists(Path.Combine(destFolder, flag))) return; 301File.Create(Path.Combine(destFolder, flag));
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningEarlyStopping.cs (4)
122using (var file = File.OpenRead("model.zip")) 252if (File.Exists(relativeFilePath)) 284if (File.Exists(Path.Combine(destFolder, flag))) return; 298File.Create(Path.Combine(destFolder, flag));
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningTrainTestSplit.cs (5)
114using (var file = File.OpenRead("model.zip")) 241Image = File.ReadAllBytes(file), 273if (File.Exists(relativeFilePath)) 305if (File.Exists(Path.Combine(destFolder, flag))) return; 319File.Create(Path.Combine(destFolder, flag));
Microsoft.ML.SamplesUtils (1)
SamplesDatasetUtils.cs (1)
193if (File.Exists(dataFile))
Microsoft.ML.Sweeper (4)
ConfigRunner.cs (4)
84if (!File.Exists(Exe) && !File.Exists(Exe + ".exe")) 211if (File.Exists(errorFile) && new FileInfo(errorFile).Length == 0) 213File.Delete(errorFile);
Microsoft.ML.TensorFlow (2)
TensorflowUtils.cs (2)
275FileAttributes attr = File.GetAttributes(modelPath); 408env.CheckUserArg(File.Exists(modelPath), nameof(modelPath));
Microsoft.ML.TensorFlow.Tests (13)
TensorflowTests.cs (13)
1416using (var file = File.OpenRead("model.zip")) 1433if (Directory.Exists(workspacePath) && File.Exists(Path.Combine(workspacePath, trainSetBottleneckCachedValuesFileName)) 1434&& File.Exists(Path.Combine(workspacePath, validationSetBottleneckCachedValuesFileName))) 1519using (var file = File.OpenRead("model.zip")) 1678using (var file = File.OpenRead("model.zip")) 1734Assert.True(File.Exists(Path.Combine(options.WorkspacePath, options.TrainSetBottleneckCachedValuesFileName))); 1735Assert.True(File.Exists(Path.Combine(options.WorkspacePath, options.ValidationSetBottleneckCachedValuesFileName))); 1736Assert.True(File.Exists(Path.Combine(Path.GetTempPath(), "MLNET", ImageClassificationTrainer.ModelFileName[options.Arch]))); 1809using (var file = File.OpenRead("model.zip")) 1880using (var file = File.OpenRead("model.zip")) 1969if (File.Exists(relativeFilePath)) 1983if (File.Exists(Path.Combine(destFolder, flag))) 1987File.Create(Path.Combine(destFolder, flag));
Microsoft.ML.TestFramework (43)
BaseTestBaseline.cs (10)
289if (File.Exists(baselinePath)) 336File.Delete(rawPath); 337File.Move(path, rawPath); 340using (TextWriter dst = File.CreateText(path)) 433File.Delete(outPath + RawSuffix); 940if (!File.Exists(outPath)) 954if (!File.Exists(basePath)) 1002return Utils.OpenWriter(File.Open(path, append ? FileMode.Append : FileMode.OpenOrCreate), encoding, bufferSize, false); 1014return new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)); 1045File.WriteAllText(path,
BaseTestPredictorsMaml.cs (2)
264File.Delete(consOutPath2.Path); 288File.Delete(outPath);
DataPipe\TestDataPipe.cs (19)
53File.WriteAllLines(mappingPathData, 73File.WriteAllLines(mappingPathData, 93File.WriteAllLines(mappingPathData, 113File.WriteAllLines(mappingPathData, 143File.WriteAllLines(mappingPathData, 169File.WriteAllLines(pathTerms, new string[] { 192File.WriteAllLines(pathTerms, new string[] { 250File.WriteAllLines(pathData, new string[] { 296File.WriteAllLines(pathData, 344File.WriteAllLines(dataFile, _small20NewsGroupSample); 347File.WriteAllLines(dictFile, _small20NewsGroupDict); 429File.WriteAllLines(pathData, 654File.WriteAllLines(pathData, 736File.WriteAllLines(pathData, 889File.WriteAllLines(dataFile, new[] { 908File.WriteAllLines(stopwordsFile, stopwordsList); 960File.WriteAllLines(dataFile, new[] { 984File.WriteAllLines(pathData, 1042File.WriteAllLines(pathData, new string[] {
DataPipe\TestDataPipeBase.cs (4)
87using (var fs = File.OpenRead(modelPath)) 395using (var stream = File.Create(pathData)) 541using (var stream = File.Create(pathData)) 592using (var stream = File.Create(pathData))
TestCommandBase.cs (8)
353File.Delete(testOutPath + RawSuffix); 756File.WriteAllLines(path.Path, new string[] { 772File.WriteAllLines(path2.Path, new string[] { 1305File.WriteAllLines(dataPath.Path, new string[] { 2238File.WriteAllLines(path.Path, new string[] { 2260File.WriteAllLines(path.Path, new string[] { 2270File.WriteAllLines(path.Path, new string[] { 2278File.WriteAllLines(path.Path, new string[] { "1 aurora:2 :3" });
Microsoft.ML.TestFrameworkCommon (8)
TestCommon.cs (2)
47File.Delete(path); 54File.Delete(path);
TestDownloadUtils.cs (5)
27if (File.Exists(filePath)) 46File.Move(temporaryFilePath, filePath); 48catch (IOException) when (File.Exists(filePath)) 55if (File.Exists(temporaryFilePath)) 56File.Delete(temporaryFilePath);
Utility\LibraryLoader.cs (1)
99if (!Path.IsPathRooted(loadTarget) || File.Exists(loadTarget))
Microsoft.ML.Tests (81)
BinaryLoaderSaverTests.cs (1)
29using (var fs = File.Create(outputPath))
DatabaseLoaderTests.cs (4)
364File.Copy(Path.Combine(sourceDirectory, $"{databaseName}.mdf"), databaseFile); 365File.SetAttributes(databaseFile, FileAttributes.Normal); 368File.Copy(Path.Combine(sourceDirectory, $"{databaseName}_log.ldf"), logFile); 369File.SetAttributes(logFile, FileAttributes.Normal);
FeatureContributionTests.cs (1)
244using (var fs = File.Create(outputPath))
OnnxConversionTest.cs (13)
450var fileText = File.ReadAllText(onnxTextPath); 452File.WriteAllText(onnxTextPath, fileText); 703File.WriteAllLines(jsonPath, new[] { inputGraph }); 735File.WriteAllLines(jsonPath, new[] { inputGraph }); 747using (var modelStream = File.OpenRead(onnxPath)) 756File.Delete(modelPath); 757File.Delete(onnxPath); 758File.Delete(onnxJsonPath); 1026File.WriteAllLines(dataFile, 1729using (var stream = File.Create(onnxModelPath)) 1735using (var modelStream = File.OpenRead(onnxModelPath)) 2288var fileText = File.ReadAllText(textFormatPath); 2291File.WriteAllText(textFormatPath, fileText);
Scenarios\Api\TestApi.cs (2)
166using (var fs = File.Create(GetOutputPath(OutputRelativePath, "lambda-output.tsv"))) 271var data = File.ReadAllLines(dataFile)
SvmLightTests.cs (5)
37File.WriteAllLines(path, data); 49using (var stream = File.Create(savingPath)) 174using (var stream = File.Create(outputPath)) 197using (var stream = File.Create(outputPath)) 220using (var stream = File.Create(outputPath))
TermEstimatorTests.cs (1)
86using (var fs = File.Create(outputPath))
TextLoaderTests.cs (7)
34File.WriteAllLines(pathData, new string[] { 94File.WriteAllLines(pathData, new string[] { 119File.WriteAllLines(pathData, new string[] { 817using (FileStream modelfs = File.OpenRead(textLoaderModelPath)) 837using (FileStream modelfs = File.OpenRead(textLoaderModelPath)) 1306using (var fs = File.Create(savedPath)) 1384File.WriteAllText(filePath, badInputCsv);
TrainerEstimators\CalibratorEstimators.cs (1)
258using (var fs = File.OpenRead(modelPath))
TrainerEstimators\LbfgsTests.cs (4)
125using (var fs = File.OpenRead(modelAndSchemaPath)) 146using (FileStream fs = File.OpenRead(dropModelPath)) 220using (var fs = File.OpenRead(modelAndSchemaPath)) 237using (FileStream fs = File.OpenRead(dropModelPath))
TrainerEstimators\MatrixFactorizationTests.cs (1)
541using (var fs = File.OpenRead(modelPath))
Transformers\CategoricalHashTests.cs (2)
71using (var fs = File.Create(outputPath)) 104using (var fs = File.Create(outputPath))
Transformers\CategoricalTests.cs (2)
90using (var fs = File.Create(outputPath)) 176using (var fs = File.Create(outputPath))
Transformers\ConcatTests.cs (2)
90using (var fs = File.Create(outputPath)) 154using (var fs = File.Create(outputPath))
Transformers\ConvertTests.cs (1)
395using (var fs = File.OpenRead(modelPath))
Transformers\FeatureSelectionTests.cs (4)
53using (var fs = File.Create(outputPath)) 88using (var fs = File.Create(outputPath)) 130using (var fs = File.Create(outputPath)) 190using (var fs = File.Create(outputPath))
Transformers\HashTests.cs (1)
344using (var fs = File.Create(outputPath))
Transformers\KeyToValueTests.cs (1)
56using (var fs = File.Create(outputPath))
Transformers\NAIndicatorTests.cs (1)
118using (var fs = File.Create(outputPath))
Transformers\NAReplaceTests.cs (1)
145using (var fs = File.Create(outputPath))
Transformers\NormalizerTests.cs (7)
88using (var fs = File.Create(outputPath)) 678using (var fs = File.Create(outputPath)) 712using (var fs = File.Create(outputPath)) 775using (var fs = File.Create(outputPath)) 835using (var fs = File.Create(outputPath)) 876using (FileStream fs = File.OpenRead(chooseModelPath)) 1012using (var fs = File.Create(outputPath))
Transformers\PcaTests.cs (1)
63using (var fs = File.Create(outputPath))
Transformers\RffTests.cs (1)
78using (var fs = File.Create(outputPath))
Transformers\SelectColumnsTests.cs (4)
221using (FileStream fs = File.OpenRead(dropModelPath)) 249using (FileStream fs = File.OpenRead(dropModelPath)) 277using (FileStream fs = File.OpenRead(dropModelPath)) 305using (FileStream fs = File.OpenRead(chooseModelPath))
Transformers\TextFeaturizerTests.cs (8)
447using (var fs = File.Create(outputPath)) 478using (var fs = File.Create(outputPath)) 502using (var fs = File.Create(outputPath)) 546using (var fs = File.Create(outputPath)) 608using (var fs = File.Create(outputPath)) 643using (var fs = File.Create(outputPath)) 660using (FileStream fs = File.OpenRead(dropModelPath)) 702using (var fs = File.Create(outputPath))
Transformers\TextNormalizer.cs (1)
64using (var fs = File.Create(outputPath))
Transformers\ValueMappingTests.cs (2)
717using (FileStream fs = File.OpenRead(termLookupModelPath)) 734using (FileStream fs = File.OpenRead(termLookupModelPath))
Transformers\WordEmbeddingsTests.cs (2)
54using (var fs = File.Create(outputPath)) 97using (var fs = File.Create(outputPath))
Microsoft.ML.TimeSeries (1)
PredictionEngine.cs (1)
90using (var file = File.Create(modelPath))
Microsoft.ML.TimeSeries.Tests (5)
TimeSeries.cs (1)
81File.WriteAllLines(pathData, Enumerable.Repeat("0", 50));
TimeSeriesDirectApi.cs (4)
251using (var file = File.OpenRead(modelPath)) 271using (var file = File.OpenRead(modelPath + 1)) 339using (var file = File.OpenRead(modelPath)) 494using (var file = File.OpenRead("model.zip"))
Microsoft.ML.Tokenizers (17)
Model\BertTokenizer.cs (2)
665string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath), 722Stream stream = string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath);
Model\BpeOptions.cs (4)
44if (!File.Exists(vocabFile)) 49using Stream vocabStream = File.OpenRead(vocabFile); 61if (!File.Exists(mergesFile)) 66using Stream mergesStream = File.OpenRead(mergesFile);
Model\BPETokenizer.cs (2)
127using Stream vocabStream = File.OpenRead(vocabFile); 128using Stream? mergesStream = mergesFile is null ? null : File.OpenRead(mergesFile);
Model\CodeGenTokenizer.cs (2)
67this(vocabularyPath is null ? throw new ArgumentNullException(nameof(vocabularyPath)) : File.OpenRead(vocabularyPath), 68mergePath is null ? throw new ArgumentNullException(nameof(mergePath)) : File.OpenRead(mergePath),
Model\EnglishRobertaTokenizer.cs (3)
119this(vocabularyPath is null ? throw new ArgumentNullException(nameof(vocabularyPath)) : File.OpenRead(vocabularyPath), 120mergePath is null ? throw new ArgumentNullException(nameof(mergePath)) : File.OpenRead(mergePath), 121highestOccurrenceMappingPath is null ? throw new ArgumentNullException(nameof(highestOccurrenceMappingPath)) : File.OpenRead(highestOccurrenceMappingPath),
Model\TiktokenTokenizer.cs (2)
47this(string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath), preTokenizer, specialTokens, normalizer, cacheSize, disposeStream: true) 1438using Stream vocabStream = File.OpenRead(vocabFilePath);
Model\WordPieceTokenizer.cs (2)
134Create(string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath), options, disposeStream: true); 192string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath),
Microsoft.ML.Tokenizers.Data.Tests (3)
test\Microsoft.ML.Tokenizers.Tests\Utils.cs (3)
41if (File.Exists(file)) 45File.Delete(file); 58using Stream fileStream = File.Create(fileName);
Microsoft.ML.Tokenizers.Tests (69)
BertTokenizerTests.cs (16)
41using Stream vocabStream = File.OpenRead(vocabFile); 98File.Delete(vocabFile); 112using Stream vocabStream = File.OpenRead(vocabFile); 169File.Delete(vocabFile); 183using Stream vocabStream = File.OpenRead(vocabFile); 219File.Delete(vocabFile); 234using Stream vocabStream = File.OpenRead(vocabFile); 296File.Delete(vocabFile); 309using Stream vocabStream = File.OpenRead(vocabFile); 348File.Delete(vocabFile); 362using Stream vocabStream = File.OpenRead(vocabFile); 448File.Delete(vocabFile); 462using Stream vocabStream = File.OpenRead(vocabFile); 541File.Delete(vocabFile); 555using Stream vocabStream = File.OpenRead(vocabFile); 599File.Delete(vocabFile);
BpeTests.cs (10)
366using Stream vocabStream = File.OpenRead(Path.Combine(@"Gpt-2", "vocab.json")); 367using Stream mergesStream = File.OpenRead(Path.Combine(@"Gpt-2", "merges.txt")); 386using Stream vocabStream = File.OpenRead(vocabFile); 387using Stream mergesStream = File.OpenRead(mergesFile); 399string jsonString = File.ReadAllText(vocabFile); 405Merges = File.ReadAllLines(mergesFile).Skip(1).ToArray() // Skip the first line which is the header "#version". 546using Stream vocabStream = File.OpenRead(Path.Combine(@"Gpt-2", "vocab.json")); 547using Stream mergesStream = File.OpenRead(Path.Combine(@"Gpt-2", "merges.txt")); 592File.WriteAllText(fileName, JsonSerializer.Serialize<Dictionary<string, int>>(dic), Encoding.UTF8); 951using Stream jsonModelStream = File.OpenRead(Path.Combine(@"DeepSeek", "tokenizer-DeepSeek-R1.json"));
CodeGenTests.cs (4)
28using Stream vocabStream = File.OpenRead(Path.Combine(@"Codegen-350M-mono", "vocab.json")); 29using Stream mergesStream = File.OpenRead(Path.Combine(@"Codegen-350M-mono", "merges.txt")); 39using Stream vocabStream = File.OpenRead(Path.Combine(@"Phi-2", "vocab.json")); 40using Stream mergesStream = File.OpenRead(Path.Combine(@"Phi-2", "merges.txt"));
EnglishRobertaTests.cs (3)
122using Stream vocabStream = File.OpenRead(vocabFile); 123using Stream mergeStream = File.OpenRead(mergeFile); 124using Stream translationStream = File.OpenRead(translationFile);
LlamaTests.cs (3)
32using Stream remoteStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model")); 39using Stream remoteStream = File.OpenRead(Path.Combine(@"Mistral", "tokenizer.model")); 46using Stream remoteStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model"));
SentencePieceTests.cs (7)
44using Stream stream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model")); 57byte[] modelBytes = File.ReadAllBytes(Path.Combine(@"Llama", "tokenizer.model")); 71using Stream stream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model")); 92using Stream stream = File.OpenRead(Path.Combine( 108using Stream stream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model")); 142using Stream bpeStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model")); 146using Stream unigramStream = File.OpenRead(Path.Combine(
TiktokenTests.cs (12)
63using (Stream fileStream = File.OpenWrite(tokenizerDataFileName)) 73using (Stream stream = File.OpenRead(tokenizerDataFileName)) 82using (Stream stream = File.OpenRead(tokenizerDataFileName)) 88using (Stream stream = File.OpenRead(tokenizerDataFileName)) 94using (Stream stream = File.OpenRead(tokenizerDataFileName)) 229using (Stream stream = File.OpenRead("./Data/tokens.json")) 304using (Stream stream = File.OpenRead("./Data/tokens_gpt4o.json")) 341using (Stream stream = File.OpenRead("./Data/tokens_gpt2.json")) 360using (Stream stream = File.OpenRead("./Data/tokens_p50k_base.json")) 379using (Stream stream = File.OpenRead("./Data/tokens_p50k_edit.json")) 398using (Stream stream = File.OpenRead("./Data/tokens_r50k_base.json")) 689string text = File.ReadAllText(path);
UnigramTests.cs (5)
26using Stream remoteStream = File.OpenRead(Path.Combine(@"Paraphrase-multilingual-MiniLM-L12-v2", "sentencepiece.bpe.model")); 58using Stream remoteStream = File.OpenRead(Path.Combine(@"Paraphrase-multilingual-MiniLM-L12-v2", "sentencepiece.bpe.model")); 616using Stream jsonStream = File.OpenRead(Path.Combine("Paraphrase-multilingual-MiniLM-L12-v2", "tokenizer.json")); 654using Stream jsonStream = File.OpenRead(Path.Combine("Paraphrase-multilingual-MiniLM-L12-v2", "tokenizer.json")); 1191using JsonDocument bundled = JsonDocument.Parse(File.ReadAllText(Path.Combine("Paraphrase-multilingual-MiniLM-L12-v2", "tokenizer.json")));
Utils.cs (3)
41if (File.Exists(file)) 45File.Delete(file); 58using Stream fileStream = File.Create(fileName);
WordPieceTests.cs (6)
21File.WriteAllLines(vocabFile, vocabTokens); 32using Stream vocabStream = File.OpenRead(vocabFile); 47File.Delete(vocabFile); 141File.Delete(vocabFile); 173File.Delete(vocabFile); 217File.Delete(vocabFile);
Microsoft.ML.Transforms (6)
LoadTransform.cs (1)
71h.CheckUserArg(File.Exists(args.ModelFile), nameof(args.ModelFile), "File does not exist");
SvmLight\SvmLightLoaderSaverCatalog.cs (2)
72if (!File.Exists(path)) 94if (!File.Exists(path))
Text\WordEmbeddingsExtractor.cs (3)
653if (!File.Exists(_modelFileNameWithPath)) 682Parallel.ForEach(File.ReadLines(_modelFileNameWithPath).Skip(skippedLinesCount), GetParallelOptions(hostEnvironment), 706var firstLine = File.ReadLines(_modelFileNameWithPath).First();
Microsoft.ML.Vision (21)
DnnRetrainTransform.cs (5)
420File.Copy(f, Path.Combine(archivePath, Path.GetFileName(f))); 440if (File.Exists(destination)) 441File.Delete(destination); 447if (File.Exists(destination)) 448File.Delete(destination);
ImageClassificationTrainer.cs (16)
676File.Exists(validationSetBottleneckCachedValuesFilePath + "_features.bin") && 677File.Exists(validationSetBottleneckCachedValuesFilePath + "_labels.bin"); 693!(File.Exists(trainSetBottleneckCachedValuesFilePath + "_features.bin") && 694File.Exists(trainSetBottleneckCachedValuesFilePath + "_labels.bin"))) 871using Stream featuresWriter = File.Open(cacheFilePath + "_features.bin", FileMode.Create); 872using Stream labelWriter = File.Open(cacheFilePath + "_labels.bin", FileMode.Create); 873using TextWriter writer = File.CreateText(cacheFilePath); 902(File.Exists(validationSetBottleneckFilePath + "_labels.bin") && 903File.Exists(validationSetBottleneckFilePath + "_features.bin"))); 906File.Exists(trainBottleneckFilePath + "_labels.bin") && 907File.Exists(trainBottleneckFilePath + "_features.bin")); 913using (Stream trainSetLabelReader = File.Open(trainBottleneckFilePath + "_labels.bin", FileMode.Open)) 914using (Stream trainSetFeatureReader = File.Open(trainBottleneckFilePath + "_features.bin", FileMode.Open)) 917File.Open(validationSetBottleneckFilePath + "_labels.bin", FileMode.Open) : null; 920File.Open(validationSetBottleneckFilePath + "_features.bin", FileMode.Open) : null; 1196File.WriteAllBytes(_checkpointPath + ".pb", outputGraphDef.ToByteArray());
Microsoft.NET.Build.Containers (10)
Layer.cs (4)
102using (FileStream fs = File.Create(tempTarballPath)) 184var fileStream = File.OpenRead(file.FullName); 247File.Move(tempTarballPath, storedContent, overwrite: true); 252internal virtual Stream OpenBackingFile() => File.OpenRead(BackingFile);
LocalDaemons\ArchiveFileRegistry.cs (1)
48await using var fileStream = File.Create(fullPath);
LocalDaemons\ContainerRuntimeOperations.cs (1)
164if (File.Exists(fullPath))
LocalDaemons\DockerCli.cs (1)
59if (File.Exists(fullPath))
Registry\Registry.cs (3)
417var fileStream = File.OpenRead(localPath); 451using (FileStream fs = File.Create(tempTarballPath)) 476File.Move(tempTarballPath, localPath, overwrite: true);
Microsoft.NET.Build.Extensions.Tasks (7)
GetDependsOnNETStandard.cs (1)
52if (File.Exists(absoluteRefPath))
src\sdk\src\Tasks\Common\ConflictResolution\ConflictItem.cs (1)
111_exists = ItemType == ConflictItemType.Platform || File.Exists(SourcePathForFileAccess);
src\sdk\src\Tasks\Common\ConflictResolution\FrameworkListReader.cs (1)
57if (!File.Exists(frameworkListPath))
src\sdk\src\Tasks\Common\ConflictResolution\PlatformManifestReader.cs (2)
19if (!File.Exists(path)) 27using (var manifestStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))
src\sdk\src\Tasks\Common\FileUtilities.cs (1)
19DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(sourcePath);
src\sdk\src\Tasks\Common\FileUtilities.MetadataReader.cs (1)
27DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(sourcePath);
Microsoft.NET.Build.Tasks (67)
CheckSdkVulnerabilities.cs (2)
46if (!File.Exists(summaryPath)) 54string json = File.ReadAllText(summaryPath);
DependencyContextBuilder.cs (2)
657var runtimeFile = !string.IsNullOrWhiteSpace(assembly.Path) && File.Exists(assembly.Path) ? CreateRuntimeFile(referenceProjectInfo.OutputName, assembly.Path, assembly.DestinationSubPath) : 658libraryPath != null && File.Exists(libraryPath) ? CreateRuntimeFile(referenceProjectInfo.OutputName, libraryPath) :
FrameworkPackages\FrameworkPackages.cs (2)
138.Where(d => File.Exists(d.Overrides)) 146var packageOverrideLines = File.ReadAllLines(packageOverrides.Overrides);
GenerateDepsFile.cs (1)
276using (var fileStream = File.Create(depsFilePath))
GenerateRuntimeConfigurationFiles.cs (3)
290if (!File.Exists(userConfigPath)) 296File.ReadAllText(userConfigPath), 428using (FileStream stream = File.Create(fileName))
GetPackagesToPrune.cs (2)
268if (File.Exists(packageOverridesPath)) 270var packageOverrideLines = File.ReadAllLines(packageOverridesPath);
NugetContentAssetPreprocessor.cs (3)
33if (!File.Exists(pathToFinalAsset)) 37using (FileStream input = File.OpenRead(originalAssetPath)) 48File.WriteAllText(pathToFinalAsset, result);
PickBestRid.cs (1)
49if (!File.Exists(runtimeGraphPath))
PrepareForReadyToRunCompilation.cs (1)
122!string.IsNullOrEmpty(diaSymReaderPath) && File.Exists(diaSymReaderPath);
ResolvePackageAssets.cs (5)
599bool IsCacheFileUpToDate() => File.GetLastWriteTimeUtc(task.TaskEnvironment.GetAbsolutePath(task.ProjectAssetsCacheFile)) > File.GetLastWriteTimeUtc(task.TaskEnvironment.GetAbsolutePath(task.ProjectAssetsFile)); 621var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); 778var stream = File.Open(_task.TaskEnvironment.GetAbsolutePath(_task.ProjectAssetsCacheFile), FileMode.Create, FileAccess.ReadWrite, FileShare.None); 1208if (File.Exists(xmlFilePath))
ResolveReadyToRunCompilers.cs (4)
411return File.Exists(_crossgenTool.ToolPath) && File.Exists(_crossgenTool.ClrJitPath); 439if (!File.Exists(_crossgen2Tool.ClrJitPath)) 446return File.Exists(_crossgen2Tool.ToolPath);
ResolveRuntimePackAssets.cs (1)
154if (File.Exists(absoluteRuntimeListPath))
ResolveTargetingPackAssets.cs (4)
246if (File.Exists(platformManifestPath)) 251if (File.Exists(packageOverridesPath)) 301packageOverride.SetMetadata("OverriddenPackages", File.ReadAllText(packageOverridesPath)); 469usePathElementsInFrameworkListPathAsFallBack = !File.Exists(dllPath);
RunReadyToRunCompiler.cs (8)
108if (!File.Exists(Crossgen2Tool.ItemSpec)) 114if (!string.IsNullOrEmpty(hostPath) && !File.Exists(hostPath)) 122if (!File.Exists(jitPath)) 156if (!File.Exists(CrossgenTool.ItemSpec)) 161if (!File.Exists(CrossgenTool.GetMetadata(MetadataKeys.JitPath))) 174if (!string.IsNullOrEmpty(DiaSymReader) && !File.Exists(DiaSymReader)) 186if (!File.Exists(_outputR2RImage)) 199if (!File.Exists(_inputAssembly))
src\sdk\src\Cli\dotnet\Commands\Workload\InstallStateContents.cs (2)
31return File.Exists(path) ? FromString(File.ReadAllText(path)) : new InstallStateContents();
src\sdk\src\Common\WorkloadFileBasedInstall.cs (2)
16=> dotnetDir is not null && File.Exists(GetUserInstallFilePath(dotnetDir, sdkFeatureBand)); 23File.WriteAllText(filePath, "");
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\SdkDirectoryWorkloadManifestProvider.cs (9)
110if (!File.Exists(knownManifestIdsFilePath)) 115if (File.Exists(knownManifestIdsFilePath)) 119foreach (var manifestId in File.ReadAllLines(knownManifestIdsFilePath).Where(l => !string.IsNullOrEmpty(l))) 352() => File.OpenRead(workloadManifestPath), 488.Where(dir => File.Exists(Path.Combine(dir, "WorkloadManifest.json"))) 500else if (File.Exists(Path.Combine(manifestDirectory, "WorkloadManifest.json"))) 505var manifestContents = WorkloadManifestReader.ReadWorkloadManifest(manifestId, File.OpenRead(manifestPath), manifestPath); 559if (File.Exists(Path.Combine(specifiedManifestDirectory, "WorkloadManifest.json"))) 669if (File.Exists(globalJsonPath))
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\TempDirectoryWorkloadManifestProvider.cs (1)
38() => File.OpenRead(workloadManifestPath),
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadInstallType.cs (1)
29dotnetDir is not null && File.Exists(Path.Combine(
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadManifestReader.Localization.cs (2)
18static readonly Func<string, bool> _fileExists = File.Exists; 43return File.OpenRead(localizationPath);
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadResolver.cs (3)
31string[] currentRuntimeIdentifiers = File.Exists(runtimeIdentifierChainPath) ? 32File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray() : 355_fileExistOverride?.Invoke(packPath) ?? File.Exists(packPath) :
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadSet.cs (2)
76var newWorkloadSet = WorkloadSet.FromJson(File.ReadAllText(jsonFile), defaultFeatureBand); 100if (File.Exists(Path.Combine(path, "baseline.workloadset.json")))
src\sdk\src\Tasks\Common\ConflictResolution\ConflictItem.cs (1)
111_exists = ItemType == ConflictItemType.Platform || File.Exists(SourcePathForFileAccess);
src\sdk\src\Tasks\Common\ConflictResolution\FrameworkListReader.cs (1)
57if (!File.Exists(frameworkListPath))
src\sdk\src\Tasks\Common\ConflictResolution\PlatformManifestReader.cs (2)
19if (!File.Exists(path)) 27using (var manifestStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))
src\sdk\src\Tasks\Common\FileUtilities.cs (1)
19DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(sourcePath);
src\sdk\src\Tasks\Common\FileUtilities.MetadataReader.cs (1)
27DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(sourcePath);
Microsoft.NET.HostModel (23)
AppHost\BinaryUtils.cs (1)
174File.Copy(sourcePath, destinationPath, overwrite: true);
AppHost\ElfUtils.cs (1)
17using FileStream fileStream = File.OpenRead(filePath);
AppHost\HostWriter.cs (3)
122if (File.Exists(appHostDestinationFilePath)) 123File.Delete(appHostDestinationFilePath); 188File.Delete(appHostDestinationFilePath);
AppHost\PEUtils.cs (1)
32using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath)))
Bundle\Bundler.cs (6)
186using (FileStream file = File.OpenRead(path)) 316if (File.Exists(bundlePath)) 339using (FileStream hostSourceStream = File.OpenRead(hostSource)) 365using (FileStream file = File.OpenRead(fileSpec.SourcePath)) 408if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && File.Exists(bundlePath)) 411File.Delete(bundlePath);
ComHost\ClsidMap.cs (1)
68using (StreamWriter writer = File.CreateText(clsidMapPath))
ComHost\ComHost.cs (3)
37File.Copy(comHostSourceFilePath, comHostDestinationFilePath, overwrite: true); 39string clsidMap = File.ReadAllText(clsidmapFilePath); 56byte[] tlbFileBytes = File.ReadAllBytes(typeLibrary.Value);
ComHost\RegFreeComManifest.cs (2)
58using (FileStream clsidMapStream = File.OpenRead(clsidMapPath)) 84byte[] tlbFileBytes = File.ReadAllBytes(typeLibrary.Value);
HostModelUtils.cs (3)
69if ((File.GetUnixFileMode(filePath) & AppHostFileMode) == AppHostFileMode) 72File.SetUnixFileMode(filePath, AppHostFileMode); 78public static bool IsCodesignAvailable() => File.Exists(CodesignPath);
ResourceUpdater.cs (1)
76using var module = new PEReader(File.OpenRead(peFile));
src\runtime\src\coreclr\tools\Common\MachO\MachObjectFile.cs (1)
22using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath)))
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (21)
BlazorWriteSatelliteAssemblyFile.cs (1)
21using var fileStream = File.Create(WriteFile.ItemSpec);
BrotliCompress.cs (3)
95if (!File.Exists(outputRelativePath)) 99else if (File.GetLastWriteTimeUtc(inputFullPath) < File.GetLastWriteTimeUtc(outputRelativePath))
CreateBlazorTrimmerRootDescriptorFile.cs (3)
23if (File.Exists(TrimmerFile.ItemSpec)) 25var existing = File.ReadAllText(TrimmerFile.ItemSpec); 35File.WriteAllText(TrimmerFile.ItemSpec, rootDescriptor);
GenerateBlazorBootExtensionJson.cs (1)
18using var fileStream = File.Create(OutputPath);
GenerateBlazorWebAssemblyBootJson50.cs (1)
43using var fileStream = File.Create(OutputPath);
GenerateServiceWorkerAssetsManifest.cs (2)
28using var fileStream = File.Create(OutputPath); 48using var file = File.OpenRead(item.ItemSpec);
GZipCompress.cs (5)
58if (!File.Exists(outputFullPath)) 62else if (File.GetLastWriteTimeUtc(inputFullPath) < File.GetLastWriteTimeUtc(outputFullPath)) 79using var sourceStream = File.OpenRead(inputFullPath); 80using var fileStream = File.Create(outputFullPath);
src\sdk\src\StaticWebAssetsSdk\Tasks\Data\StaticWebAsset.cs (5)
1247if (!File.Exists(sourceFile)) 1256if (!File.Exists(destPath) || File.GetLastWriteTimeUtc(sourceFile) > File.GetLastWriteTimeUtc(destPath)) 1258File.Copy(sourceFile, destPath, overwrite: true);
Microsoft.NET.Sdk.BlazorWebAssembly.Tool (1)
Program.cs (1)
52using var sourceStream = File.OpenRead(source);
Microsoft.NET.Sdk.Publish.Tasks (41)
AppSettingsTransform.cs (4)
23File.WriteAllText(tempFileFullPath, defaultAppSettingsJsonString); 30if (!File.Exists(destinationAppSettingsFilePath)) 40string appSettingsJsonContent = File.ReadAllText(destinationAppSettingsFilePath); 57File.WriteAllText(destinationAppSettingsFilePath, ToJson(appSettingsModel));
Kudu\KuduVfsDeploy.cs (1)
61using (var content = new StreamContent(File.OpenRead(file)))
Kudu\KuduZipDeploy.cs (2)
32if (!File.Exists(zipFileFullPath)) 52using (var content = new StreamContent(File.OpenRead(zipFilePath)))
Tasks\GenerateEnvTransform.cs (2)
35if (File.Exists(envTransformTemplatePath)) 37string templateContent = File.ReadAllText(envTransformTemplatePath);
Tasks\Kudu\KuduDeploy.cs (2)
192if (File.Exists(tempFilePath)) 196File.Delete(tempFilePath);
Tasks\MsDeploy\CreateManifestFile.cs (2)
106if (!File.Exists(ManifestFile)) 108File.Create(ManifestFile).Close();
Tasks\MsDeploy\CreateMSDeployScript.cs (6)
24if (!File.Exists(ScriptFullPath)) 26File.Create(ScriptFullPath).Close(); 28File.WriteAllLines(ScriptFullPath, GetReplacedFileContents(Resources.MsDeployBatchFile)); 33if (!File.Exists(ReadMeFullPath)) 35File.Create(ReadMeFullPath).Close(); 37File.WriteAllLines(ReadMeFullPath, GetReplacedFileContents(Resources.MsDeployReadMe));
Tasks\MsDeploy\CreateParameterFile.cs (3)
161|| File.Exists(metadataValue))) 284if (DeclareSetParameterFile is not null && !File.Exists(DeclareSetParameterFile)) 286File.Create(DeclareSetParameterFile).Close();
Tasks\MsDeploy\ImportParameterFile.cs (1)
168if (!File.Exists(filePath))
Tasks\MsDeploy\MSDeploy.cs (1)
268if (!File.Exists(Path.Combine(m_exePath, ToolName)))
Tasks\OneDeploy\OneDeploy.cs (2)
95if (!File.Exists(fileToPublishPath)) 112var fileToPublishStream = File.OpenRead(fileToPublishPath);
Tasks\TransformAppSettings.cs (3)
78if (!File.Exists(sourceAppSettingsFilePath)) 83if (!File.Exists(destinationAppSettingsFilePath)) 85File.Copy(sourceAppSettingsFilePath, destinationAppSettingsFilePath);
Tasks\TransformWebConfig.cs (4)
95if (File.Exists(publishWebConfigPath)) 97if (File.Exists(projectWebConfigPath)) 99File.Copy(projectWebConfigPath, publishWebConfigPath, true); 103File.WriteAllText(publishWebConfigPath, WebConfigTemplate.Template);
Tasks\WebJobs\GenerateRunCommandFile.cs (2)
27bool isRunCommandFilePresent = ProjectDirectory is not null && File.Exists(Path.Combine(ProjectDirectory, runCmdFileName)); 33File.WriteAllText(Path.Combine(WebJobsDirectory, runCmdFileName), command);
Tasks\ZipDeploy\ZipDeploy.cs (2)
55if (!File.Exists(zipToPublishPath) || client == null) 93FileStream stream = File.OpenRead(zipToPublishPath);
WebConfigTelemetry.cs (3)
54if (!string.IsNullOrEmpty(solutionFileFullPath) && File.Exists(solutionFileFullPath)) 95if (!string.IsNullOrEmpty(solutionFileFullPath) && File.Exists(solutionFileFullPath)) 97string[] solutionFileLines = File.ReadAllLines(solutionFileFullPath);
WebConfigTransform.cs (1)
156if (File.Exists(projectWebConfigPath))
Microsoft.NET.Sdk.Razor.Tasks (5)
ReferenceResolver.cs (2)
106if (!File.Exists(file)) 111using var peReader = new PEReader(File.OpenRead(file));
SdkRazorTagHelper.cs (1)
44File.WriteAllText(TagHelperManifest, "{ }");
src\sdk\src\RazorSdk\Tool\ServerProtocol\ServerConnection.cs (2)
305if (File.Exists(dotnetPath)) 334if (!File.Exists(expectedCompilerPath))
Microsoft.NET.Sdk.StaticWebAssets.Tasks (106)
CollectStaticWebAssetsToCopy.cs (1)
58else if (File.Exists(asset.Identity))
Compression\BrotliCompress.cs (3)
96if (!File.Exists(outputRelativePath)) 100else if (File.GetLastWriteTimeUtc(inputFullPath) < File.GetLastWriteTimeUtc(outputRelativePath))
Compression\GZipCompress.cs (5)
40if (!File.Exists(outputRelativePath)) 44else if (File.GetLastWriteTimeUtc(inputFullPath) < File.GetLastWriteTimeUtc(outputRelativePath)) 57using var sourceStream = File.OpenRead(inputFullPath); 58using var fileStream = File.Create(outputRelativePath);
Data\StaticWebAsset.cs (5)
1247if (!File.Exists(sourceFile)) 1256if (!File.Exists(destPath) || File.GetLastWriteTimeUtc(sourceFile) > File.GetLastWriteTimeUtc(destPath)) 1258File.Copy(sourceFile, destPath, overwrite: true);
DefineStaticWebAssets.Cache.cs (3)
135if (manifestPath != null && File.Exists(manifestPath)) 137using var existingManifestFile = File.OpenRead(manifestPath); 156using var manifestFile = File.OpenWrite(_manifestPath);
GenerateStaticWebAssetEndpointsManifest.cs (11)
44var existingPatternString = !string.IsNullOrEmpty(ExclusionPatternsCacheFilePath) && File.Exists(exclusionCacheAbsolutePath) 45? File.ReadAllText(exclusionCacheAbsolutePath) 48if (!string.IsNullOrEmpty(CacheFilePath) && File.Exists(manifestAbsolutePath) && File.GetLastWriteTimeUtc(manifestAbsolutePath) > File.GetLastWriteTimeUtc(cacheAbsolutePath)) 106if (!updatedManifest && File.Exists(manifestAbsolutePath)) 114File.SetLastWriteTime(manifestAbsolutePath, DateTime.UtcNow); 212if (!File.Exists(exclusionCacheAbsolutePath) || 220File.WriteAllText(exclusionCacheAbsolutePath, patternString); 223if (File.Exists(manifestAbsolutePath)) 225File.SetLastWriteTime(manifestAbsolutePath, DateTime.UtcNow);
GenerateStaticWebAssetEndpointsPropsFile.cs (4)
96var fileExists = File.Exists(targetPropsFilePath); 97var existingFileHash = fileExists ? ComputeHash(File.ReadAllBytes(targetPropsFilePath)) : ""; 102File.WriteAllBytes(targetPropsFilePath, data); 107File.WriteAllBytes(targetPropsFilePath, data);
GenerateStaticWebAssetsDevelopmentManifest.cs (8)
42if (File.Exists(manifestPath) && File.GetLastWriteTimeUtc(manifestPath) > File.GetLastWriteTimeUtc(TaskEnvironment.GetAbsolutePath(CacheFilePath))) 142var fileExists = File.Exists(manifestPath); 147SHA256.HashData(File.ReadAllBytes(manifestPath)) : 154File.WriteAllBytes(manifestPath, data); 163File.WriteAllBytes(manifestPath, data); 316if (File.Exists(asset.Identity))
GenerateStaticWebAssetsManifest.cs (6)
135var cacheFileExists = isManifestCacheFileConfigured && File.Exists(absolutizedManifestCacheFilePath); 136var manifestFileExists = File.Exists(absolutizedManifestPath); 138File.ReadAllText(absolutizedManifestCacheFilePath) : 139manifestFileExists ? StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(absolutizedManifestPath)).Hash : ""; 152File.WriteAllBytes(absolutizedManifestPath, data); 155File.WriteAllText(absolutizedManifestCacheFilePath, manifest.Hash);
GenerateStaticWebAssetsPropsFile.cs (4)
165var fileExists = File.Exists(targetPropsAbsoluteFilePath); 166var existingFileHash = fileExists ? ComputeHash(File.ReadAllBytes(targetPropsAbsoluteFilePath)) : ""; 171File.WriteAllBytes(targetPropsAbsoluteFilePath, data); 176File.WriteAllBytes(targetPropsAbsoluteFilePath, data);
JSModules\GenerateJSModuleManifest.cs (4)
47var fileExists = File.Exists(OutputFile); 52SHA256.HashData(File.ReadAllBytes(OutputFile)) : 59File.WriteAllBytes(OutputFile, data); 64File.WriteAllBytes(OutputFile, data);
Legacy\GenerateStaticWebAssetsPropsFile50.cs (4)
112var fileExists = File.Exists(TargetPropsFilePath); 113var existingFileHash = fileExists ? ComputeHash(File.ReadAllBytes(TargetPropsFilePath)) : ""; 118File.WriteAllBytes(TargetPropsFilePath, data); 123File.WriteAllBytes(TargetPropsFilePath, data);
Legacy\GenerateV1StaticWebAssetsManifest.cs (4)
75var fileExists = File.Exists(TargetManifestPath); 80SHA256.HashData(File.ReadAllBytes(TargetManifestPath)) : 87File.WriteAllBytes(TargetManifestPath, data); 92File.WriteAllBytes(TargetManifestPath, data);
OverrideHtmlAssetPlaceholders.cs (2)
64if (File.Exists(item.ItemSpec)) 66string content = File.ReadAllText(item.ItemSpec);
ReadPackageAssetsManifest.cs (2)
52if (!File.Exists(manifestPath)) 161var json = File.ReadAllBytes(manifestPath);
ReadStaticWebAssetsManifestFile.cs (2)
34if (!File.Exists(manifestPath)) 42var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(manifestPath));
ScopedCss\ConcatenateCssFiles.cs (4)
90foreach (var line in File.ReadLines(TaskEnvironment.GetAbsolutePath(current.ItemSpec))) 99if (!File.Exists(outputFile) || !SameContent(content, outputFile)) 102File.WriteAllText(outputFile, content); 112var outputContent = File.ReadAllText(outputFilePath);
ScopedCss\ConcatenateCssFiles50.cs (4)
90foreach (var line in File.ReadLines(current.GetMetadata("FullPath"))) 98if (!File.Exists(OutputFile) || !SameContent(content, OutputFile)) 101File.WriteAllText(OutputFile, content); 111var outputContent = File.ReadAllText(outputFilePath);
ScopedCss\RewriteCss.cs (5)
45if (SkipIfOutputIsNewer && File.Exists(outputFile) && File.GetLastWriteTimeUtc(inputFile) < File.GetLastWriteTimeUtc(outputFile)) 55var inputText = File.ReadAllText(inputFile); 68File.WriteAllText(outputFile, rewrittenCss);
ServiceWorker\GenerateServiceWorkerAssetsManifest.cs (4)
102var fileExists = File.Exists(OutputPath); 103var existingManifestHash = fileExists ? ComputeFileHash(File.ReadAllText(OutputPath)) : ""; 108File.WriteAllText(OutputPath, content); 113File.WriteAllText(OutputPath, content);
ServiceWorker\UpdateServiceWorkerFileWithVersion.cs (5)
23if (!File.Exists(ServiceWorkerSource)) 30var sourceContent = File.ReadAllText(ServiceWorkerSource); 35var destinationContent = File.Exists(ServiceWorkerDestination) ? File.ReadAllText(ServiceWorkerDestination) : null; 40File.WriteAllText(ServiceWorkerDestination, versionedContent);
StaticWebAssetsGeneratePackagePropsFile.cs (4)
65var fileExists = File.Exists(buildTargetPath); 66var existingFileHash = fileExists ? ComputeHash(File.ReadAllBytes(buildTargetPath)) : ""; 71File.WriteAllBytes(buildTargetPath, data); 76File.WriteAllBytes(buildTargetPath, data);
StaticWebAssetsGeneratePackManifest.cs (4)
85var fileExists = File.Exists(manifestPath); 86var existingManifestHash = fileExists ? ComputeHash(File.ReadAllBytes(manifestPath)) : ""; 91File.WriteAllBytes(manifestPath, data); 96File.WriteAllBytes(manifestPath, data);
StaticWebAssetsReadPackManifest.cs (2)
23if (!File.Exists(ManifestPath)) 31var manifest = JsonSerializer.Deserialize<StaticWebAssetsPackManifest>(File.ReadAllBytes(ManifestPath));
Utils\ArtifactWriter.cs (4)
22var fileExists = File.Exists(artifactPath); 28File.WriteAllBytes(artifactPath, data); 34File.WriteAllBytes(artifactPath, data); 44private static string ComputeHash(string artifactPath) => ComputeHash(File.ReadAllBytes(artifactPath));
Utils\AssetToCompress.cs (2)
18if (File.Exists(relatedAsset)) 28if (File.Exists(relatedAssetOriginalItemSpec))
Microsoft.NET.Sdk.StaticWebAssets.Tool (1)
Program.cs (1)
52using var sourceStream = File.OpenRead(source);
Microsoft.NET.Sdk.WorkloadManifestReader (22)
SdkDirectoryWorkloadManifestProvider.cs (9)
110if (!File.Exists(knownManifestIdsFilePath)) 115if (File.Exists(knownManifestIdsFilePath)) 119foreach (var manifestId in File.ReadAllLines(knownManifestIdsFilePath).Where(l => !string.IsNullOrEmpty(l))) 352() => File.OpenRead(workloadManifestPath), 488.Where(dir => File.Exists(Path.Combine(dir, "WorkloadManifest.json"))) 500else if (File.Exists(Path.Combine(manifestDirectory, "WorkloadManifest.json"))) 505var manifestContents = WorkloadManifestReader.ReadWorkloadManifest(manifestId, File.OpenRead(manifestPath), manifestPath); 559if (File.Exists(Path.Combine(specifiedManifestDirectory, "WorkloadManifest.json"))) 669if (File.Exists(globalJsonPath))
src\sdk\src\Cli\dotnet\Commands\Workload\InstallStateContents.cs (2)
31return File.Exists(path) ? FromString(File.ReadAllText(path)) : new InstallStateContents();
src\sdk\src\Common\WorkloadFileBasedInstall.cs (2)
16=> dotnetDir is not null && File.Exists(GetUserInstallFilePath(dotnetDir, sdkFeatureBand)); 23File.WriteAllText(filePath, "");
TempDirectoryWorkloadManifestProvider.cs (1)
38() => File.OpenRead(workloadManifestPath),
WorkloadInstallType.cs (1)
29dotnetDir is not null && File.Exists(Path.Combine(
WorkloadManifestReader.Localization.cs (2)
18static readonly Func<string, bool> _fileExists = File.Exists; 43return File.OpenRead(localizationPath);
WorkloadResolver.cs (3)
31string[] currentRuntimeIdentifiers = File.Exists(runtimeIdentifierChainPath) ? 32File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray() : 355_fileExistOverride?.Invoke(packPath) ?? File.Exists(packPath) :
WorkloadSet.cs (2)
76var newWorkloadSet = WorkloadSet.FromJson(File.ReadAllText(jsonFile), defaultFeatureBand); 100if (File.Exists(Path.Combine(path, "baseline.workloadset.json")))
Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver (9)
CachingWorkloadResolver.cs (3)
68if (File.Exists(sentinelPath)) 121if (File.Exists(autoImportPath)) 138if (File.Exists(workloadManifestTargetPath))
src\sdk\src\Cli\dotnet\Commands\Workload\Install\WorkloadInstallRecords\FileBasedInstallationRecordInstaller.cs (4)
47if (!File.Exists(path)) 54File.Create(path).Close(); 61if (File.Exists(path)) 63File.Delete(path);
src\sdk\src\Common\WorkloadFileBasedInstall.cs (2)
16=> dotnetDir is not null && File.Exists(GetUserInstallFilePath(dotnetDir, sdkFeatureBand)); 23File.WriteAllText(filePath, "");
Microsoft.NETCore.Platforms (2)
UpdateRuntimeIdentifierGraph.cs (2)
27using (FileStream stream = File.OpenRead(InputFile!)) 45using FileStream streamWriter = File.Create(OutputFile!);
Microsoft.SourceLink.Common (4)
GenerateSourceLinkFile.cs (4)
126if (File.Exists(OutputFile)) 132File.Delete(OutputFile); 136var originalContent = File.ReadAllText(OutputFile); 155File.WriteAllText(OutputFile, content);
Microsoft.TemplateEngine.Abstractions (12)
PhysicalFileSystem\IPhysicalFileSystem.cs (12)
19/// Same behavior as <see cref="File.Exists(string)"/>. 24/// Same behavior as <see cref="File.Create(string)"/>. 44/// Same behavior as <see cref="File.Copy(string, string, bool)"/>. 54/// Same behavior as <see cref="File.ReadAllText(string)"/>. 60/// Same behavior as <see cref="File.ReadAllBytes(string)"/>. 65/// Same behavior as <see cref="File.WriteAllText(string, string)"/>. 80/// Same behavior as <see cref="File.OpenRead(string)"/>. 85/// Same behavior as <see cref="File.Delete(string)"/>. 90/// Same behavior as <see cref="File.GetAttributes(string)"/>. 95/// Same behavior as <see cref="File.SetAttributes(string, FileAttributes)"/>. 110/// Same behavior as <see cref="File.GetLastWriteTimeUtc(string)"/>. 118/// Same behavior as <see cref="File.SetLastWriteTimeUtc(string, DateTime)"/>.
Microsoft.TemplateEngine.Cli (1)
TemplatePackageCoordinator.cs (1)
212bool isPath = File.Exists(installArg) || Directory.Exists(installArg);
Microsoft.TemplateEngine.Edge (1)
ReflectionLoadProbingPath.cs (1)
231else if (File.Exists(Path.Combine(selector._path, stringName + ".dll")))
Microsoft.TemplateEngine.Utils (12)
PhysicalFileSystem.cs (12)
21return File.Exists(file); 26return File.Create(path); 46File.Copy(source, target, overwrite); 56return File.ReadAllText(path); 61return File.ReadAllBytes(path); 66File.WriteAllText(path, value); 81return File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); 86File.Delete(path); 91return File.GetAttributes(file); 96File.SetAttributes(file, attributes); 101return File.GetLastWriteTimeUtc(file); 106File.SetLastWriteTimeUtc(file, lastWriteTimeUtc);
Microsoft.TestPlatform.Build (1)
Tasks\TestTaskUtils.cs (1)
268if (!File.Exists(settingsFile))
Microsoft.TestPlatform.CoreUtilities (5)
Helpers\FileHelper.cs (5)
31=> File.Exists(path); 75=> File.Copy(sourcePath, destinationPath); 79=> File.Move(sourcePath, destinationPath); 83=> File.WriteAllText(filePath, content); 112=> File.Delete(path);
Microsoft.TestPlatform.CrossPlatEngine (2)
Discovery\DiscoveryManager.cs (2)
259if (!File.Exists(src) && !Directory.Exists(src)) 277if (!File.Exists(src))
Microsoft.TestPlatform.Extensions.BlameDataCollector (5)
ProcDumpDumper.cs (1)
276File.Delete(dumpToRemove.FullName);
ProcessCodeMethods.cs (1)
121var stat = File.ReadAllText(path);
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
WindowsHangDumper.cs (1)
147if (!File.Exists(dumpMinitoolPath))
Microsoft.TestPlatform.PlatformAbstractions (7)
common\System\ProcessHelper.cs (1)
51if (!File.Exists(processPath))
common\Tracing\RollingFileTraceListener.cs (6)
84File.Open(fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite), 285if (File.Exists(archiveFileName)) 287File.Delete(archiveFileName); 291File.SetCreationTime(actualFileName, currentDateTime); 292File.Move(actualFileName, archiveFileName); 306File.Move(actualFileName, archiveFileName);
Microsoft.TestPlatform.TestHostRuntimeProvider (2)
Hosting\AppxManifestFile.cs (1)
19if (File.Exists(filePath))
Hosting\DefaultTestHostManager.cs (1)
223&& !File.Exists(testhostProcessPath))
Microsoft.TestPlatform.Utilities (1)
CodeCoverageDataAttachmentsHandler.cs (1)
158File.Delete(file);
Microsoft.TestPlatform.VsTestConsole.TranslationLayer (1)
VsTestConsoleProcessManager.cs (1)
123if (!File.Exists(consoleRunnerPath.Trim('"')))
Microsoft.VisualBasic.Core (27)
Microsoft\VisualBasic\CompilerServices\VB6File.vb (1)
404If File.Exists(m_sFullPath) Then
Microsoft\VisualBasic\CompilerServices\VB6OutputFile.vb (1)
42If File.Exists(m_sFullPath) Then
Microsoft\VisualBasic\CompilerServices\VB6RandomFile.vb (1)
62If File.Exists(m_sFullPath) Then
Microsoft\VisualBasic\FileIO\FileSystem.vb (18)
97Return IO.File.Exists(file) 347Return IO.File.ReadAllBytes(file) 357Return IO.File.ReadAllText(file) 368Return IO.File.ReadAllText(file, encoding) 478If IO.File.Exists(directory) Then 710If Not IO.File.Exists(file) Then 728IO.File.Move(file, FullNewPath) 795If append AndAlso IO.File.Exists(file) Then 920If IO.File.Exists(TargetDirectoryFullPath) Then 1110If Not IO.File.Exists(sourceFileFullPath) Then 1136IO.File.Copy(sourceFileFullPath, destinationFileFullPath, overwrite) 1159IO.File.Delete(destinationFileFullPath) 1161IO.File.Move(sourceFileFullPath, destinationFileFullPath) 1164IO.File.Move(sourceFileFullPath, destinationFileFullPath) 1230If Not IO.File.Exists(fileFullPath) Then 1240IO.File.Delete(fileFullPath) 1249If IO.File.Exists(Path) Then 1496If IO.File.Exists(FullPath) Then
Microsoft\VisualBasic\FileIO\TextFieldParser.vb (1)
600If Not File.Exists(fullPath) Then
Microsoft\VisualBasic\FileSystem.vb (5)
284File.Copy(Source, Destination, True) 287File.SetAttributes(Destination, FileAttributes.Archive) 307If File.Exists(PathName) Then 318If File.Exists(PathName) Then 415IO.File.Delete(FileName)
Microsoft.VisualBasic.Forms (1)
Microsoft\VisualBasic\Logging\FileLogTraceListener.vb (1)
613If File.Exists(fileName) Then
Microsoft.VisualStudio.TestPlatform.Common (4)
DataCollection\DataCollectionAttachmentManager.cs (3)
201if (!File.Exists(fileTransferInfo.FileName)) 216else if (File.Exists(localFilePath)) 218File.Delete(localFilePath);
Utilities\AssemblyResolver.cs (1)
162if (!File.Exists(assemblyPath))
Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger (5)
TrxLogger.cs (3)
490using (var fs = File.Open(trxFileName, FileMode.Truncate)) 537if (shouldOverwrite && File.Exists(filePath)) 550using var fs = File.Open(filePath, FileMode.CreateNew);
Utility\TrxFileHelper.cs (2)
152if (!File.Exists(tryMePath)) 391if (File.Exists(path) || Directory.Exists(path))
Microsoft.VisualStudio.TestPlatform.ObjectModel (3)
Navigation\DiaSession.cs (2)
118pdbFilePath = !File.Exists(pdbFilePath) 122if (File.Exists(pdbFilePath))
Navigation\PortableSymbolReader.cs (1)
88using PortablePdbReader pdbReader = File.Exists(pdbFilePath)
Microsoft.Web.XmlTransform (2)
XmlAttributePreservationProvider.cs (1)
19streamReader = new StreamReader(File.OpenRead(fileName));
XmlFileInfoDocument.cs (1)
223using (Stream file = File.Create(filename))
Mono.Cecil (6)
Mono.Cecil.Cil\PortablePdb.cs (2)
29 var file = File.OpenRead (Mixin.GetPdbFileName (fileName)); 249 var file = File.Open (Mixin.GetPdbFileName (fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite);
Mono.Cecil.Cil\Symbols.cs (2)
931 if (File.Exists (pdb_file_name)) { 943 if (File.Exists (mdb_file_name)) {
Mono.Cecil\BaseAssemblyResolver.cs (1)
216 if (!File.Exists (file))
Mono.Security.Cryptography\CryptoService.cs (1)
125 if (!File.Exists (file))
Mono.Cecil.Mdb (1)
Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs (1)
229 File.Delete (filename);
Mono.Cecil.Pdb (3)
Mono.Cecil.Pdb\PdbHelper.cs (3)
25 return new NativePdbReader (Disposable.Owned (File.OpenRead (Mixin.GetPdbFileName (fileName)) as Stream)); 83 if (File.Exists (pdb)) 84 File.Delete (pdb);
MSBuild (6)
OutOfProcTaskHostNode.cs (1)
1361? File.CreateText(string.Format(CultureInfo.CurrentCulture, Path.Combine(FileUtilities.TempFileDirectory, @"MSBuild_NodeShutdown_{0}.txt"), EnvironmentUtilities.CurrentProcessId))
src\msbuild\src\Shared\Debugging\PrintLineDebuggerWriters.cs (2)
28File.AppendAllText(file, CsvFormat(string.Empty, callsite, args)); 33File.AppendAllText(errorFile, $"{SimpleFormat(id, callsite, args)}\n{e.Message}\n{e.StackTrace}");
src\msbuild\src\Shared\TypeLoader.cs (1)
267if (string.IsNullOrEmpty(assemblyFilePath) || !File.Exists(assemblyFilePath))
XMake.cs (2)
581using StreamWriter sw = File.CreateText(path); 586using StreamWriter sw = File.AppendText(path);
mscorlib (1)
src\runtime\src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
319[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
netstandard (1)
netstandard.cs (1)
914[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
NuGet.Build.Tasks (3)
BuildTasksUtility.cs (2)
735if (File.Exists(packagesConfigPath)) 742if (File.Exists(packagesConfigPath))
src\nuget-client\build\Shared\XmlUtility.cs (1)
30using FileStream fileStream = File.OpenRead(path);
NuGet.Build.Tasks.Pack (7)
GetPackOutputItemsTask.cs (2)
79if (string.IsNullOrWhiteSpace(NuspecFile) || !File.Exists(NuspecFile)) 93using Stream fileStream = File.OpenRead(NuspecFile);
GetProjectReferencesFromAssetsFileTask.cs (2)
37if (!string.IsNullOrEmpty(ProjectAssetsFileAbsolutePath) && File.Exists(ProjectAssetsFileAbsolutePath)) 46if (!File.Exists(assetsFilePath))
PackTaskLogic.cs (3)
109if (!File.Exists(assetsFilePath)) 346if (!File.Exists(assetsFilePath)) 528if (!File.Exists(finalOutputPath))
NuGet.CommandLine.XPlat (14)
Commands\Package\Update\PackageUpdateIO.cs (1)
92File.Delete(tempFile);
Commands\PackageReferenceCommands\AddPackageReferenceCommand.cs (1)
165if (!File.Exists(projectPath)
Commands\PackageReferenceCommands\AddPackageReferenceCommandRunner.cs (1)
447if (File.Exists(packageReferenceArgs.DgFilePath))
Commands\PackageReferenceCommands\ListPackage\ListPackageCommandRunner.cs (3)
58if (!File.Exists(listPackageArgs.Path)) 76? MSBuildAPIUtility.GetProjectsFromSolution(listPackageArgs.Path).Where(File.Exists) 245if (!File.Exists(assetsPath))
Commands\PackageReferenceCommands\RemovePackageReferenceCommand.cs (1)
80if (!File.Exists(projectPath)
Commands\Why\WhyCommand.cs (1)
82return File.Exists(value) || Directory.Exists(value);
Commands\Why\WhyCommandRunner.cs (3)
128if (string.IsNullOrEmpty(assetsFilePath) || !File.Exists(assetsFilePath)) 189|| (File.Exists(fullPath) 250if (!File.Exists(assetsFilePath))
Utility\MSBuildAPIUtility.cs (1)
154? GetProjectsFromSolution(projectOrSolutionFile).Where(File.Exists)
Utility\XPlatUtility.cs (2)
129if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) 146if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
NuGet.Commands (28)
CommandRunners\PackCommandRunner.cs (7)
132bool isExistingPackage = File.Exists(outputPath); 135using (Stream stream = File.Create(outputPath)) 142if (!isExistingPackage && File.Exists(outputPath)) 144File.Delete(outputPath); 164if (!isExistingPackage && File.Exists(outputPath)) 166File.Delete(outputPath); 277File.WriteAllText(tempOutputPath, Convert.ToBase64String(sha512hash));
RestoreCommand\Diagnostics\UnresolvedMessages.cs (1)
95if (unresolved.Name.IndexOf(Path.DirectorySeparatorChar, StringComparison.Ordinal) > -1 && File.Exists(unresolved.Name))
RestoreCommand\OriginalCaseGlobalPackageFolder.cs (2)
85if (!converted.Add(identity) || File.Exists(hashPath)) 184if (localPackage != null && File.Exists(localPackage.Package.ZipPath))
RestoreCommand\ProjectRestoreCommand.cs (2)
182if (File.Exists(runtimeGraphPath)) 186using (var stream = File.OpenRead(runtimeGraphPath))
RestoreCommand\RequestFactory\DependencyGraphFileRequestProvider.cs (1)
41var result = (File.Exists(path) && path.EndsWith(".dg", StringComparison.OrdinalIgnoreCase));
RestoreCommand\RestoreCommand.cs (2)
1584if (!MSBuildStringUtility.IsTrueOrEmpty(restorePackagesWithLockFile) && File.Exists(packagesLockFilePath)) 1614if (!_request.RestoreForceEvaluate && File.Exists(packagesLockFilePath))
RestoreCommand\RestoreResult.cs (1)
324if (!toolCommit && !DoNotWriteDependencyGraphSpec && _dependencyGraphSpecFilePath != null && _dependencyGraphSpec != null && (DidDGHashChange || !File.Exists(_dependencyGraphSpecFilePath)))
RestoreCommand\RestoreRunner.cs (3)
382if (File.Exists(input) || Directory.Exists(input)) 393Debug.Assert(File.Exists(input) || Directory.Exists(input)); 394if (File.Exists(input))
RestoreCommand\Utility\BuildAssetsUtils.cs (2)
391return File.Exists(path); 410if (File.Exists(path))
RestoreCommand\Utility\NoOpRestoreUtilities.cs (4)
104if (!string.IsNullOrWhiteSpace(request.LockFilePath) && !File.Exists(request.LockFilePath)) 113if (!File.Exists(targetsFilePath)) 119if (!File.Exists(propsFilePath)) 127if (!File.Exists(packageLockFilePath))
RestoreCommand\Utility\PackageSpecFactory.cs (2)
441if (File.Exists(packagesConfigPath)) 448if (File.Exists(packagesConfigPath))
src\nuget-client\build\Shared\XmlUtility.cs (1)
30using FileStream fileStream = File.OpenRead(path);
NuGet.Common (15)
LocalResourceUtils.cs (3)
108var attributes = File.GetAttributes(filePath); 113File.SetAttributes(filePath, attributes); 116File.Delete(filePath);
Migrations\MigrationRunner.cs (3)
35if (!File.Exists(expectedMigrationFilename)) 48if (!File.Exists(expectedMigrationFilename)) 54File.WriteAllText(expectedMigrationFilename, string.Empty);
PathUtil\FileUtility.cs (3)
194File.Move(sourceFileName, destFileName); 221if (File.Exists(path)) 223File.Delete(path);
PathUtil\NuGetEnvironment.cs (4)
364if (File.Exists(fullPath)) 376if (File.Exists(fullPath)) 386if (File.Exists(fullPath)) 398if (File.Exists(fullPath))
PathUtil\ProjectJsonPathUtilities.cs (1)
41if (!File.Exists(configPath))
src\nuget-client\build\Shared\XmlUtility.cs (1)
30using FileStream fileStream = File.OpenRead(path);
NuGet.Configuration (8)
Settings\ConfigurationDefaults.cs (1)
38if (File.Exists(Path.Combine(directory, configFile)))
Settings\Items\FileClientCertItem.cs (2)
204if (File.Exists(originalValue)) 214if (File.Exists(relativeToConfigFilePath))
Settings\Settings.cs (1)
866if (File.Exists(file))
src\nuget-client\build\Shared\XmlUtility.cs (1)
30using FileStream fileStream = File.OpenRead(path);
Utility\FileSystemUtility.cs (3)
18if (File.Exists(fullPath)) 34using (Stream outputStream = File.Create(fullPath)) 62return File.Exists(Path.Combine(root, file));
NuGet.PackageManagement (41)
BuildIntegration\DependencyGraphRestoreUtility.cs (1)
290if (File.Exists(persistedDGSpecPath))
FileModifiers\XdtTransformer.cs (1)
118using (FileStream fileStream = File.OpenRead(path))
FileModifiers\XmlTransformer.cs (1)
158using var packageStream = File.OpenRead(packageFileInfo.ZipArchivePath);
NuGetPackageManager.cs (4)
2993if (File.Exists(lockFilePath)) 3547if (File.Exists(packagePath)) 3549using (var downloadResourceResult = new DownloadResourceResult(File.OpenRead(packagePath), nuGetProjectAction.SourceRepository?.PackageSource?.Source)) 3597File.Exists(readmeFilePath))
PackagePreFetcher.cs (1)
88if (!File.Exists(installPath))
PackagePreFetcherResult.cs (1)
205File.OpenRead(nupkgPath),
Projects\FolderNuGetProject.cs (5)
206if (File.Exists(packageFilePath)) 435if (File.Exists(installPath)) 491if (File.Exists(installPath)) 520if (File.Exists(filePath)) 581if (File.Exists(packageFilePath))
Projects\MSBuildNuGetProject.cs (1)
462using var packageStream = File.OpenRead(packagePath);
Projects\PackagesConfigNuGetProject.cs (6)
251return File.Exists(FullPath); 274if (File.Exists(FullPath)) 312&& !File.Exists(PackagesProjectNameConfigPath) 313&& File.Exists(PackagesConfigPath)) 317else if (!File.Exists(PackagesConfigPath) 318&& File.Exists(PackagesProjectNameConfigPath))
src\nuget-client\build\Shared\XmlUtility.cs (1)
30using FileStream fileStream = File.OpenRead(path);
Utility\BuildIntegratedProjectUtility.cs (1)
64if (File.Exists(lockFilePath))
Utility\FileSystemUtility.cs (11)
23if (File.Exists(fullPath)) 25var attributes = File.GetAttributes(fullPath); 28File.SetAttributes(fullPath, attributes & ~FileAttributes.ReadOnly); 36return File.Exists(path); 149return File.Create(fullPath); 209if (!File.Exists(fullPath)) 223File.Delete(fullPath); 266File.Delete(fileToDelete); 295File.Delete(path); 332fileStream = File.OpenRead(path)) 363fileStream = File.OpenRead(path))
Utility\MSBuildNuGetProjectSystemUtility.cs (1)
27if (File.Exists(Path.Combine(msBuildNuGetProjectSystem.ProjectFullPath, path)))
Utility\PackagesConfigContentHashProvider.cs (1)
50if (File.Exists(metadataPath))
Utility\PackagesConfigLockFileUtility.cs (4)
39var lockFileExists = File.Exists(lockFileName); 96var lockFileExists = File.Exists(lockFilePath); 291if (!File.Exists(pcFile)) 313using (var stream = File.OpenRead(pcFile))
Utility\XmlUtility.cs (1)
15if (File.Exists(Path.Combine(root, path)))
NuGet.Packaging (47)
Core\NuspecCoreReaderBase.cs (1)
40_xml = LoadXml(File.OpenRead(path), leaveStreamOpen: false);
FallbackPackagePathResolver.cs (2)
125if (File.Exists(hashPath)) 135if (File.Exists(nupkgMetadataFilePath))
NuGetExtractionFileIO.cs (4)
35return File.Create; 67using (File.Create(path)) 71File.Delete(path); 90var fileStream = File.Create(path);
PackageArchiveReader.cs (2)
137stream = File.OpenRead(filePath); 195using (var destination = File.OpenWrite(nupkgFilePath))
PackageCreation\Authoring\PackageBuilder.cs (2)
88if (!File.Exists(path)) 97using (Stream stream = File.OpenRead(path))
PackageCreation\Authoring\PhysicalPackageFile.cs (2)
84_lastWriteTime = File.GetLastWriteTimeUtc(SourcePath); 85return File.OpenRead(SourcePath);
PackageExtraction\PackageHelper.cs (1)
148if (File.Exists(runtimePackageFilePath))
PackageExtraction\PackagePathHelper.cs (1)
168File.Exists(packageLookupPath))
PackageExtraction\StreamExtensions.cs (1)
87if (File.Exists(fileFullPath))
PackageExtraction\ZipArchiveExtensions.cs (2)
101FileAttributes attr = File.GetAttributes(fileFullPath); 135File.SetLastWriteTimeUtc(fileFullPath, dateTime);
PackageExtraction\ZipFilePair.cs (1)
25return FileFullPath != null && PackageEntry != null && File.Exists(FileFullPath);
PackageExtractor.cs (19)
419if (!File.Exists(nupkgMetadataFilePath)) 512File.WriteAllText(tempHashPath, packageHash); 550File.Move(targetTempNupkg, targetNupkg); 556File.Delete(targetTempNupkg); 571File.Move(tempHashPath, hashPath); 573File.Move(tempNupkgMetadataPath, nupkgMetadataFilePath); 614if (File.Exists(targetTempNupkg)) 616File.Delete(targetTempNupkg); 695if (!File.Exists(nupkgMetadataFilePath)) 801File.Move(extractedNuspecFilePath, tempNuspecFilePath); 802File.Move(tempNuspecFilePath, targetNuspec); 805else if (!File.Exists(targetNuspec)) 807File.Move(extractedNuspecFilePath, targetNuspec); 831File.WriteAllText(tempHashPath, packageHash); 853File.Move(targetTempNupkg, targetNupkg); 860File.Delete(targetTempNupkg); 875File.Move(tempHashPath, hashPath); 877File.Move(tempNupkgMetadataFilePath, nupkgMetadataFilePath); 965if (File.Exists(nupkgFilePath))
PackageFileExtractor.cs (1)
126File.Copy(source, target, overwrite: true);
PackagesConfigWriter.cs (4)
533if (File.Exists(fullPath)) 537var attributes = File.GetAttributes(fullPath); 541File.SetAttributes(fullPath, attributes & ~FileAttributes.ReadOnly); 557using (var tempConfigStream = File.Create(configFileNewPath))
RuntimeModel\JsonRuntimeFormat.cs (1)
19using (var fileStream = File.OpenRead(filePath))
Signing\Authoring\SigningOptions.cs (2)
148new Lazy<Stream>(() => File.OpenRead(inputPackageFilePath)), 149new Lazy<Stream>(() => File.Open(outputPackageFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)),
src\nuget-client\build\Shared\XmlUtility.cs (1)
30using FileStream fileStream = File.OpenRead(path);
NuGet.ProjectModel (5)
LockFile\LockFileFormat.cs (1)
89using (var stream = File.OpenRead(filePath))
LockFile\LockFileUtilities.cs (1)
22if (File.Exists(lockFilePath))
ProjectLockFile\PackagesLockFileFormat.cs (1)
57using (var stream = File.OpenRead(filePath))
ProjectLockFile\PackagesLockFileUtilities.cs (2)
28return MSBuildStringUtility.IsTrue(restorePackagesWithLockFile) || File.Exists(GetNuGetLockFilePath(project)); 56if (File.Exists(path))
NuGet.Protocol (55)
HttpSource\HttpCacheUtility.cs (4)
92if (File.Exists(result.CacheFile)) 99File.Delete(result.CacheFile); 111if (!File.Exists(result.CacheFile)) 113File.Move(
LocalPackageArchiveDownloader.cs (1)
180using (var source = File.OpenRead(_packageFilePath))
LocalRepositories\FindLocalPackagesResourceUnzipped.cs (1)
140if (File.Exists(nuspecPath))
LocalRepositories\LocalDownloadResource.cs (1)
71var stream = File.OpenRead(packageInfo.Path);
LocalRepositories\LocalV2FindPackageByIdResource.cs (1)
175using (var fileStream = File.OpenRead(info.Path))
LocalRepositories\LocalV3FindPackageByIdResource.cs (4)
209using (var fileStream = File.OpenRead(packagePath)) 479return (_isFallbackFolder && File.Exists(nupkgMetadataPath)) || 480(!_isFallbackFolder && (File.Exists(hashPath) || File.Exists(nupkgMetadataPath)));
PackagesFolder\LocalPackageFileCache.cs (6)
115if (!exists && File.Exists(sha512Path)) 145File.SetLastAccessTimeUtc(nupkgMetadataPath, DateTime.UtcNow); 213if (File.Exists(manifestPath)) 215return new NuspecReader(File.OpenRead(manifestPath)); 232if (File.Exists(runtimeGraphFile)) 234using (var stream = File.OpenRead(runtimeGraphFile))
Plugins\Logging\PluginLogger.cs (1)
165var stream = File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.Read);
Plugins\PluginCacheEntry.cs (4)
83if (File.Exists(CacheFileName)) 90File.Delete(CacheFileName); 96if (!File.Exists(CacheFileName)) 98File.Move(
Plugins\PluginDiscoverer.cs (3)
170return File.Exists(filePath) ? PluginFileState.Valid : PluginFileState.NotFound; 197if (File.Exists(path)) 313var fileMode = File.GetUnixFileMode(fileInfo.FullName);
Plugins\PluginDiscoveryUtility.cs (1)
93if (File.Exists(expectedPluginName))
Plugins\PluginPackageReader.cs (2)
1111File.WriteAllText(filePath, string.Empty); 1174File.Delete(_filePath);
Resources\PackageUpdateResource.cs (6)
313if (!File.Exists(symbolPackagePath)) 697File.Copy(pathToPackage, fullPath, overwrite: true); 807if (!File.Exists(nupkgFilePath)) 827var attributes = File.GetAttributes(fullPath); 830File.SetAttributes(fullPath, attributes & ~FileAttributes.ReadOnly); 832File.Delete(fullPath);
Utility\GetDownloadResultUtility.cs (1)
148File.Delete(file);
Utility\GlobalPackagesFolderUtility.cs (3)
45if (File.Exists(nupkgMetadataPath)) 49else if (File.Exists(hashPath)) 64stream = File.Open(nupkgPath, FileMode.Open, FileAccess.Read, FileShare.Read);
Utility\LocalFolderUtility.cs (9)
670if (!File.Exists(nupkgPath)) 676if (!File.Exists(nuspecPath)) 682if (!File.Exists(hashPath)) 693File.GetLastWriteTimeUtc(nupkgPath), 1289if (!File.Exists(nupkgMetadataPath)) 1292using (var stream = File.Open(nupkgPath, FileMode.Open, FileAccess.Read, FileShare.Read)) 1301if (!string.IsNullOrEmpty(hashPath) && File.Exists(hashPath)) 1303return File.ReadAllText(hashPath); 1318File.Move(tempNupkgMetadataFilePath, nupkgMetadataPath);
Utility\OfflineFeedUtility.cs (7)
40var nupkgFileExists = File.Exists(nupkgFilePath); 42var hashFileExists = File.Exists(hashFilePath); 44var nuspecFileExists = File.Exists(nuspecFilePath); 58var existingHash = File.ReadAllText(hashFilePath); 126(!isDirectory && !File.Exists(path))) 149using var packageStream = File.OpenRead(packagePath); 251using var nupkgStream = File.Open(nupkgFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
Pipelines.AppHost (1)
AppHost.cs (1)
312using var fileStream = File.OpenRead(filePath);
Pipelines.Library (3)
DistributedApplicationPipelineExtensions.cs (3)
152await using var zipStream = File.OpenRead(zipPath); 175if (File.Exists(zipPath)) 177File.Delete(zipPath);
PresentationBuildTasks (20)
Microsoft\Build\Tasks\Windows\GenerateTemporaryTargetAssembly.cs (4)
117using(FileStream fs = File.OpenRead(CurrentProject)) 195File.Delete(tempProj); 246using(FileStream fs = File.OpenRead(CurrentProject)) 310File.Delete(TemporaryTargetAssemblyProjectName);
Microsoft\Build\Tasks\Windows\ResourcesGenerator.cs (1)
293if (!File.Exists(TaskHelper.CreateFullFilePath(strFileName, SourceDir))) // CodeQL [SM00414] Trusted build-time input, not attacker-controlled
Microsoft\Build\Tasks\Windows\UidManager.cs (6)
246using (Stream source = File.OpenRead(inputFile.ItemSpec)) // CodeQL [SM00414] Trusted build-time input, not attacker-controlled 300using (Stream source = File.OpenRead(inputFile.ItemSpec)) // CodeQL [SM00414] Trusted build-time input, not attacker-controlled 369File.Move(src, dest); 374if (File.Exists(fileName)) // CodeQL [SM00414] Trusted build-time path, not attacker-controlled 376File.Delete(fileName); // CodeQL [SM00414] Trusted build-time path, not attacker-controlled 479using (Stream xamlStream = File.OpenRead(fileName)) // CodeQL [SM00414] Trusted build-time input, not attacker-controlled
MS\Internal\Shared\SourceFileInfo.cs (1)
120_stream = File.OpenRead(_filePath);
MS\Internal\Tasks\CompilerState.cs (1)
163stream = File.OpenRead(_stateFilePath);
MS\Internal\Tasks\TaskFileService.cs (6)
151fileStream = File.OpenRead(srcFile); 199using (Stream fileStream = File.OpenRead(fileName)) 227lastChangeDT = File.GetLastWriteTime(srcFile); 252fileExists = File.Exists(fileName); 274File.Delete(fileName); 356File.Copy(buildFile, intelFile, /*overwrite*/ true);
src\wpf\src\Microsoft.DotNet.Wpf\src\PresentationFramework\System\Windows\Markup\XmlnsCache.cs (1)
110if (!String.IsNullOrEmpty(assemblyFullPath) && File.Exists(assemblyFullPath))
PresentationCore (4)
MS\Internal\AppModel\SiteOfOriginPart.cs (1)
170return File.OpenRead(_absoluteLocation.LocalPath);
MS\Internal\IO\Packaging\ByteRangeDownloader.cs (1)
60_tempFileStream = File.Open(tempFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
src\wpf\src\Microsoft.DotNet.Wpf\src\Shared\System\IO\FileHelper.cs (1)
154File.Delete(filePath);
System\Windows\Input\Cursor.cs (1)
256File.Delete(filePath);
PresentationFramework (9)
Microsoft\Win32\FileDialog.cs (2)
459fileExists = File.Exists(tempPath); 600if (!GetOption(FOS.FILEMUSTEXIST) || File.Exists(newFilename))
Microsoft\Win32\SaveFileDialog.cs (1)
187bool fExist = File.Exists(fileName);
MS\Internal\AppModel\ContentFilePart.cs (1)
123return System.IO.File.Open(filename, FileMode.Open, FileAccess.Read, ResourceContainer.FileShare);
System\Windows\Controls\VirtualizingStackPanel.cs (1)
12572_writer = new BinaryWriter(File.Open(filename, FileMode.Create));
System\Windows\Documents\Speller.cs (1)
1581System.IO.File.Delete(tempLocationUri.LocalPath);
System\Windows\Documents\TextStore.cs (1)
5047_writer = new BinaryWriter(File.Open(filename, FileMode.Create));
System\Windows\Documents\WinRTSpellerInterop.cs (1)
428if (!File.Exists(lexiconFilePath))
System\Windows\Standard\Verify.cs (1)
265if (!File.Exists(filePath))
PresentationUI (23)
InstallationError.xaml.cs (1)
175if (File.Exists(LogFilePath) && ErrorFlag)
MS\Internal\Documents\Application\DocumentStream.cs (19)
118File.Copy(sourcePath, copiesPath, true); 123FileAttributes attrib = File.GetAttributes(copiesPath); 126File.SetAttributes(copiesPath, attrib ^ FileAttributes.ReadOnly); 264File.Copy(sourcePath, tempPath, true); 315if (File.Exists(path)) 317attributes = File.GetAttributes(path); 689File.Delete(path); 750File.SetAttributes( 854if (File.Exists(targetFile)) 865if( File.Exists( backupFile ) ) 868File.SetAttributes(backupFile, FileAttributes.Normal); 869File.Delete(backupFile); 874targetAttributes = File.GetAttributes(targetFile); 875File.Move(targetFile, backupFile); 889File.SetAttributes(backupFile, FileAttributes.Normal); 892File.Move(sourceFile, targetFile); 907File.Move(backupFile, targetFile); 914File.SetAttributes(targetFile, targetAttributes); 925File.Delete(backupFile);
MS\Internal\Documents\RightsManagementManager.cs (2)
862foundRMClient = File.Exists(msdrmdllPath); 1436template = File.ReadAllText(templateLocalPath, Encoding.Unicode);
TenFeetInstallationError.xaml.cs (1)
179if (File.Exists(LogFilePath) && ErrorFlag)
RepoTasks (35)
BatchHelixWorkItems.cs (4)
78File.WriteAllText(Path.Combine(payloadDirectory, "targets.txt"), testAssembly); 118if (!File.Exists(destPath)) 120File.Copy(file, destPath); 147File.WriteAllLines(Path.Combine(batchDirectory, "targets.txt"), targets);
GenerateTestDevCert.cs (2)
38if (File.Exists(CertificatePath)) 53using var file = File.OpenWrite(devCertJsonFile);
ResolveDotnetToolPackagePaths.cs (1)
31using var stream = File.OpenRead(ToolManifestPath);
src\aspnetcore\src\Shared\CertificateGeneration\CertificateManager.cs (5)
540if (!File.Exists(certificatePath)) 748File.Move(tempFilename, path, overwrite: true); 751File.WriteAllBytes(path, bytes); 776File.Move(tempFilename, keyPath, overwrite: true); 779File.WriteAllBytes(keyPath, pemEnvelope);
src\aspnetcore\src\Shared\CertificateGeneration\MacOSCertificateManager.cs (10)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 159using SafeFileHandle nullHandle = File.OpenNullHandle(); 175File.Delete(tmpFile); 207File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 319File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 339File.WriteAllBytes(certificatePath, certBytes); 457if (File.Exists(certificatePath)) 459File.Delete(certificatePath);
src\aspnetcore\src\Shared\CertificateGeneration\UnixCertificateManager.cs (13)
115if (File.Exists(certPath)) 247if (File.Exists(certPath)) 473if (File.Exists(certPath)) 610if (File.Exists(Path.Combine(searchFolder, command))) 646if (File.Exists(WslInteropPath) || File.Exists(WslInteropLatePath)) 689using SafeFileHandle nullHandle = File.OpenNullHandle(); 709using SafeFileHandle nullHandle = File.OpenNullHandle(); 737using SafeFileHandle nullHandle = File.OpenNullHandle(); 760using SafeFileHandle nullHandle = File.OpenNullHandle(); 820File.Delete(certPath); 1051if (!File.Exists(linkPath)) 1054File.CreateSymbolicLink(linkPath, cert.Name);
Roslyn.Diagnostics.Analyzers (5)
src\roslyn\src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
402return File.GetLastWriteTimeUtc(fullPath);
src\roslyn\src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
rzc (18)
Application.cs (1)
105expandedArgs.AddRange(File.ReadLines(fileName));
DiscoverCommand.cs (3)
275using (var output = File.Open(outputFilePath, FileMode.Create)) 285if (!File.Exists(path)) 290using (var stream = File.OpenRead(path))
GenerateCommand.cs (6)
281if (File.Exists(outputFilePath) && 282string.Equals(File.ReadAllText(outputFilePath), generatedCode, StringComparison.Ordinal)) 288File.WriteAllText(outputFilePath, generatedCode); 356File.WriteAllText(outputPath, generated.SourceText.ToString()); 395if (!File.Exists(tagHelperManifest)) 400using (var stream = File.OpenRead(tagHelperManifest))
MetadataCache.cs (2)
42using (var fileStream = File.OpenRead(fullPath)) 58return File.GetLastWriteTimeUtc(fullPath);
RazorSourceGeneratorHost.cs (1)
174using var stream = File.OpenRead(Path);
ServerProtocol\ServerConnection.cs (2)
305if (File.Exists(dotnetPath)) 334if (!File.Exists(expectedCompilerPath))
ShadowCopyManager.cs (3)
54if (File.Exists(resourcesPath)) 61if (File.Exists(resourcesPath)) 95File.Copy(originalPath, shadowCopyPath);
sdk-tasks (41)
AddMetadataIsPE.cs (2)
27var isPe = File.Exists(resultItem.GetMetadata("FullPath")) && HasMetadata(resultItem.GetMetadata("FullPath")); 42using (var inStream = File.OpenRead(pathToFile))
CopyPreservingRelativeSymlinks.cs (4)
100if (File.Exists(destPath)) 102File.Delete(destPath); 119File.CreateSymbolicLink(destPath, sourceInfo.LinkTarget); 124File.Copy(sourcePath, destPath);
Crossgen.cs (5)
34if (!File.Exists(SourceAssembly)) 59File.Copy(file, Path.Combine(destination, Path.GetFileName(file)), overwrite: true); 61File.Delete(file); 65if (File.Exists(TempOutputPath)) 67File.Delete(TempOutputPath);
DeduplicateAssembliesWithLinks.cs (3)
137File.Delete(duplicateFilePath); 141File.CreateHardLink(duplicateFilePath, primaryFilePath); 148File.CreateSymbolicLink(duplicateFilePath, relativePath);
ExtractArchiveToDirectory.cs (3)
52if (!File.Exists(SourceArchive)) 86using var zip = new ZipArchive(File.OpenRead(SourceArchive)); 111using FileStream compressedFileStream = File.OpenRead(SourceArchive);
GenerateMSBuildExtensionsSWR.cs (1)
35File.WriteAllText(outputFileInfo.FullName, sb.ToString());
GenerateRuntimeAnalyzersSWR.cs (2)
52File.WriteAllText(OutputFile, sb.ToString()); 67if (!File.Exists(path))
GenerateSdkRuntimeIdentifierChain.cs (1)
26File.WriteAllText(RuntimeIdentifierChainOutputPath, chainContents);
GetRuntimePackRids.cs (1)
21string runtimeJsonContents = File.ReadAllText(runtimeJsonPath);
ProcessRuntimeAnalyzerVersions.cs (1)
62File.WriteAllText(path: MetadataFilePath!, JsonSerializer.Serialize(metadata, SdkTasksJsonSerializerContext.Default.DictionaryStringMetadataEntry));
PublishMutationUtilities.cs (2)
17var deps = JsonNode.Parse(File.ReadAllText(depsFile)); 46File.WriteAllText(depsFile, deps.ToJsonString(s_writeOptions));
RemoveAssetFromDepsPackages.cs (2)
34var deps = JsonNode.Parse(File.ReadAllText(depsFile)); 61File.WriteAllText(depsFile, deps.ToJsonString(s_writeOptions));
ReplaceFileContents.cs (3)
66var filesNotFound = InputFiles.Where(i => !File.Exists(i.ItemSpec)).Select(i => i.ItemSpec); 85string inputFileText = File.ReadAllText(inputFile); 132File.WriteAllText(destinationFile, outputFileText);
ReplaceFilesWithSymbolicLinks.cs (5)
84if (File.Exists(targetFile) && FilesHaveSameContent(file, targetFile)) 132File.Move(path, backupFile); 137File.CreateSymbolicLink(path, relativePath); 139File.Delete(backupFile); 147File.Move(backupFile, path);
TarGzFileCreateFromDirectory.cs (1)
57if (File.Exists(DestinationArchive))
UpdateRuntimeConfig.cs (2)
36var text = File.ReadAllText(file); 52File.WriteAllText(file, config.ToJsonString(s_writeOptions));
Utils\FileHasher.cs (1)
22using var stream = File.OpenRead(filePath);
ZipFileCreateFromDirectory.cs (2)
44if (File.Exists(DestinationArchive)) 49File.Delete(DestinationArchive);
Security.TransportSecurity.IntegrationTests (1)
Tcp\ClientCredentialTypeTests.OSX.cs (1)
133if (!File.Exists(ServiceUtilHelper.OSXCustomKeychainFilePath))
SelectTests (16)
ChangedFileFilter.cs (2)
48if (!File.Exists(patternsPath)) 54var regexes = File.ReadAllLines(patternsPath)
GraphAffectedProjects.cs (2)
128if (!File.Exists(solutionPath)) 459relativePaths = File.ReadAllLines(changedFilesPath)
Program.cs (11)
278if (!File.Exists(slnxPath)) 283var slnx = File.ReadAllText(slnxPath); 335File.WriteAllText(path, sb.ToString()); 346File.AppendAllLines(githubOutput, new[] { line }); 398return File.ReadAllLines(options.ChangedFilesPath) 440if (!File.Exists(slnxPath)) 445var slnx = File.ReadAllText(slnxPath); 543File.AppendAllText(summaryPath, markdown); 640File.WriteAllText(jsonPath, root.ToJsonString(new System.Text.Json.JsonSerializerOptions { WriteIndented = true })); 973File.WriteAllText(commentPath, content); 1179File.AppendAllText(summaryPath, markdown);
TriggerMap.cs (1)
109var yaml = File.ReadAllText(mapPath);
Stress.ApiService (2)
Program.cs (2)
338var xmlLarge = File.ReadAllText(Path.Combine("content", "books.xml")); 345var jsonLarge = File.ReadAllText(Path.Combine("content", "example.json"));
SuperFileCheck (3)
Program.cs (3)
265var syntaxTree = CSharpSyntaxTree.ParseText(SourceText.From(File.ReadAllText(filePath))); 420File.WriteAllText(tmpFilePath, PreProcessMethod(methodDeclInfo, checkPrefixes)); 429try { File.Delete(tmpFilePath); } catch { }
System.CodeDom (5)
Microsoft\CSharp\CSharpCodeGenerator.cs (2)
2953File.OpenRead(fileName).Dispose(); 2993File.OpenRead(fileName).Dispose();
src\runtime\src\libraries\Common\src\System\IO\TempFileCollection.cs (1)
186File.Delete(fileName);
System\CodeDom\Compiler\CodeCompiler.cs (2)
77File.OpenRead(fileName).Dispose(); 119File.OpenRead(fileName).Dispose();
System.CommandLine (2)
ArgumentValidation.cs (1)
202else if (checkFile && !Directory.Exists(token.Value) && !File.Exists(token.Value))
Parsing\StringExtensions.cs (1)
357var lines = File.ReadAllLines(filePath);
System.ComponentModel.TypeConverter (1)
System\ComponentModel\LicFileLicenseProvider.cs (1)
85if (File.Exists(licenseFile))
System.Configuration.ConfigurationManager (21)
src\runtime\src\libraries\Common\src\System\IO\TempFileCollection.cs (1)
186File.Delete(fileName);
System\Configuration\AppSettingsSection.cs (1)
104if (!IO.File.Exists(sourceFileFullPath)) return;
System\Configuration\ClientConfigPaths.cs (1)
47if (!File.Exists(ApplicationUri))
System\Configuration\ConfigurationFileMap.cs (1)
30if (!File.Exists(machineConfigFilename))
System\Configuration\Internal\InternalConfigHost.cs (3)
227return !File.Exists(streamName) 253if (File.Exists(streamName)) 293File.Delete(streamName);
System\Configuration\Internal\WriteFileContext.cs (12)
65if (File.Exists(filename)) 101FileAttributes attributes = File.GetAttributes(source); 102File.SetAttributes(destination, attributes); 105creationTime = File.GetCreationTimeUtc(source); 106File.SetCreationTimeUtc(destination, creationTime); 116FileAttributes fileAttributes = File.GetAttributes(source); 117File.SetAttributes(destination, fileAttributes); 169File.Exists(target) && 188if (File.Exists(target)) 190File.Replace(source, target, null); 194File.Move(source, target); 208if (!File.Exists(fileName))
System\Configuration\LocalFileSettingsProvider.cs (1)
330if (File.Exists(file))
System\Configuration\NameValueFileSectionHandler.cs (1)
43if (File.Exists(sourceFileFullPath))
System.Diagnostics.EventLog (2)
System\Diagnostics\EventLog.cs (2)
413File.Delete(filename); 701if (machineName == "." && !File.Exists(dllPath))
System.Diagnostics.FileVersionInfo (2)
System\Diagnostics\FileVersionInfo.cs (1)
306if (!File.Exists(fileName))
System\Diagnostics\FileVersionInfo.Unix.cs (1)
49using (FileStream assemblyStream = File.OpenRead(_fileName))
System.Diagnostics.PerformanceCounter (2)
System\Diagnostics\PerformanceCounterLib.cs (2)
634File.Delete(IniFilePath); 642File.Delete(SymbolFilePath);
System.Diagnostics.Process (19)
Microsoft\Win32\SafeHandles\SafeProcessHandle.cs (1)
193? File.OpenNullHandle()
src\runtime\src\libraries\Common\src\Interop\Linux\cgroups\Interop.cgroups.cs (5)
72foreach (string line in File.ReadLines(path + "/memory.stat")) 154if (File.Exists(path)) 158byte[] bytes = File.ReadAllBytes(path); 314if (File.Exists(mountInfoFilePath)) 384if (File.Exists(procCGroupFilePath))
src\runtime\src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcFsStat.ParseMapModules.cs (1)
26return ParseMapsModulesCore(File.ReadLines(GetMapsFilePathForProcess(pid)));
src\runtime\src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (1)
18if (File.Exists(ProcMountInfoFilePath))
System\Diagnostics\Process.cs (1)
1393SafeFileHandle nullDeviceHandle = File.OpenNullHandle();
System\Diagnostics\Process.Scenarios.cs (2)
144using SafeFileHandle? nullHandle = silent ? File.OpenNullHandle() : null; 206using SafeFileHandle? nullHandle = silent ? File.OpenNullHandle() : null;
System\Diagnostics\ProcessStartInfo.cs (6)
181/// <see cref="System.IO.File.OpenHandle"/> to open a file handle, 182/// <see cref="System.IO.File.OpenNullHandle"/> to provide an empty input, 207/// <see cref="System.IO.File.OpenHandle"/> to open a file handle, 208/// <see cref="System.IO.File.OpenNullHandle"/> to discard output, 233/// <see cref="System.IO.File.OpenHandle"/> to open a file handle, 234/// <see cref="System.IO.File.OpenNullHandle"/> to discard error output,
System\Diagnostics\ProcessUtils.Unix.cs (2)
155if (File.Exists(filename)) 163if (uri.IsFile && uri.Host == "" && File.Exists(uri.LocalPath))
System.Diagnostics.StackTrace (1)
System\Diagnostics\StackTraceSymbols.cs (1)
225if (!File.Exists(path))
System.Diagnostics.TraceSource (1)
System\Diagnostics\DefaultTraceListener.cs (1)
165File.AppendAllText(LogFileName!, message);
System.Drawing.Common (6)
System\Drawing\Icon.cs (1)
158if (!File.Exists(filePath))
System\Drawing\Image.cs (3)
88if (!File.Exists(filename)) 268using var fs = File.OpenWrite(filename); 922created = dataStream = File.OpenRead(filename ?? throw new InvalidOperationException());
System\Drawing\Text\PrivateFontCollection.cs (1)
53if (!File.Exists(filename))
System\Drawing\ToolboxBitmapAttribute.cs (1)
157using FileStream reader = File.OpenRead(imageFile!);
System.Formats.Tar (12)
src\runtime\src\libraries\Common\src\System\IO\Archiving.Utils.cs (1)
39File.SetLastWriteTime(destinationFileName, lastWriteTime.DateTime);
System\Formats\Tar\TarEntry.cs (4)
200/// <para>Symbolic links can be recreated using <see cref="File.CreateSymbolicLink(string, string)"/>, <see cref="Directory.CreateSymbolicLink(string, string)"/> or <see cref="FileSystemInfo.CreateAsSymbolicLink(string)"/>.</para> 600File.Copy(linkTargetPath, filePath); 662File.Delete(filePath); 723File.SetLastWriteTime(destinationFileName, lastWriteTime.UtcDateTime);
System\Formats\Tar\TarEntry.Unix.cs (1)
40File.CreateHardLink(hardLinkFilePath, targetFilePath);
System\Formats\Tar\TarFile.cs (3)
436if (!File.Exists(sourceFileName)) 446using FileStream archive = File.OpenRead(sourceFileName); 505if (!File.Exists(sourceFileName))
System\Formats\Tar\TarHelpers.Unix.cs (3)
35UnixFileMode actual = File.GetUnixFileMode(fs.SafeFileHandle); 74File.SetUnixFileMode(fullPath, mode.Value & ~umask); 114File.SetUnixFileMode(dir.Key, dir.Value & ~umask);
System.IO.Compression.ZipFile (8)
src\runtime\src\libraries\Common\src\System\IO\Archiving.Utils.cs (1)
39File.SetLastWriteTime(destinationFileName, lastWriteTime.DateTime);
System\IO\Compression\ZipFileExtensions.ZipArchive.Create.cs (1)
180DateTime lastWrite = File.GetLastWriteTime(sourceFileName);
System\IO\Compression\ZipFileExtensions.ZipArchiveEntry.Extract.Async.cs (3)
104if (overwrite && File.Exists(destinationFileName)) 129File.Move(tempPath, destinationFileName, overwrite: true); 140try { File.Delete(tempPath); } catch { }
System\IO\Compression\ZipFileExtensions.ZipArchiveEntry.Extract.cs (3)
97if (overwrite && File.Exists(destinationFileName)) 116File.Move(tempPath, destinationFileName, overwrite: true); 127try { File.Delete(tempPath); } catch { }
System.IO.FileSystem (1)
System.IO.FileSystem.cs (1)
10[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
System.IO.FileSystem.DriveInfo (2)
src\runtime\src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (1)
18if (File.Exists(ProcMountInfoFilePath))
src\runtime\src\libraries\Common\src\Interop\Unix\System.Native\Interop.MountPoints.cs (1)
44if (File.Exists(Interop.procfs.ProcMountInfoFilePath))
System.IO.FileSystem.Watcher (1)
System\IO\FileSystemWatcher.Linux.cs (1)
110try { return File.ReadAllText(path).Trim(); }
System.IO.IsolatedStorage (7)
System\IO\IsolatedStorage\IsolatedStorageFile.cs (7)
83File.Delete(fullPath); 97return File.Exists(GetFullPath(path)); 243return new DateTimeOffset(File.GetCreationTime(GetFullPath(path))); 259return new DateTimeOffset(File.GetLastAccessTime(GetFullPath(path))); 275return new DateTimeOffset(File.GetLastWriteTime(GetFullPath(path))); 303File.Copy(sourceFileNameFullPath, destinationFileNameFullPath, overwrite); 331File.Move(sourceFileNameFullPath, destinationFileNameFullPath);
System.IO.MemoryMappedFiles (4)
System\IO\MemoryMappedFiles\MemoryMappedFile.cs (3)
125_ => File.Exists(path) 127SafeFileHandle fileHandle = File.OpenHandle(path, mode, GetFileAccess(access), FileShare.Read, FileOptions.None); 511File.Delete(path);
System\IO\MemoryMappedFiles\MemoryMappedFile.Unix.cs (1)
318SafeFileHandle fileHandle = File.OpenHandle(path, FileMode.CreateNew, TranslateProtectionsToFileAccess(protections), share);
System.IO.Pipes (2)
System\IO\Pipes\NamedPipeServerStream.Unix.cs (2)
281File.SetUnixFileMode(path, UnixFileMode.UserRead | UnixFileMode.UserWrite); 344File.SetUnixFileMode(path, UnixFileMode.UserRead | UnixFileMode.UserWrite);
System.IO.Ports (3)
System\IO\Ports\SerialPort.Unix.cs (3)
56(File.Exists(entry.FullName + "/device/id") || 60(isTtyGS && (File.Exists(entry.FullName + "/dev")))) 63if (File.Exists(deviceName))
System.Memory.Data (2)
System\BinaryData.cs (2)
328return new BinaryData(File.ReadAllBytes(path), mediaType); 360await File.ReadAllBytesAsync(path, cancellationToken).ConfigureAwait(false),
System.Net.Mail (1)
System\Net\Mail\SmtpClient.cs (1)
372if (!File.Exists(pathAndFilename))
System.Net.NameResolution (1)
System\Net\ResolvConf.cs (1)
50return File.GetLastWriteTimeUtc(ResolvConfPath);
System.Net.NetworkInformation (11)
System\Net\NetworkInformation\LinuxNetworkInterface.cs (5)
33if (File.Exists(NetworkFiles.Ipv4RouteFile)) 37IPv4Routes = File.ReadAllLines(NetworkFiles.Ipv4RouteFile); 44if (File.Exists(NetworkFiles.Ipv6RouteFile)) 48IPv6Routes = File.ReadAllLines(NetworkFiles.Ipv6RouteFile); 57string resolverConfig = File.ReadAllText(NetworkFiles.EtcResolvConfFile);
System\Net\NetworkInformation\StringParsingHelpers.Addresses.cs (2)
87if (File.Exists(filePath)) // avoid an exception in most cases if path doesn't already exist 129if (File.Exists(smbConfFilePath)) // avoid an exception in most cases if path doesn't already exist
System\Net\NetworkInformation\StringParsingHelpers.Misc.cs (2)
19return File.ReadAllLines(filePath); 31return File.ReadAllText(filePath);
System\Net\NetworkInformation\UnixIPInterfaceProperties.cs (2)
91return StringParsingHelpers.ParseDnsSuffixFromResolvConfFile(File.ReadAllText(NetworkFiles.EtcResolvConfFile)); 103List<IPAddress> internalAddresses = StringParsingHelpers.ParseDnsAddressesFromResolvConfFile(File.ReadAllText(NetworkFiles.EtcResolvConfFile));
System.Net.Ping (3)
src\runtime\src\libraries\Common\src\System\Net\NetworkInformation\UnixCommandLinePing.cs (3)
32if (File.Exists(path)) 36if (File.Exists(pathv4v6)) 50System.IO.FileSystemInfo? linkInfo = File.ResolveLinkTarget(pingBinary, returnFinalTarget: true);
System.Net.Quic (1)
src\runtime\src\libraries\Common\src\System\Net\Security\SslKeyLogger.cs (1)
25s_fileStream = File.Open(s_keyLogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
System.Net.Security (1)
src\runtime\src\libraries\Common\src\System\Net\Security\SslKeyLogger.cs (1)
25s_fileStream = File.Open(s_keyLogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
System.Net.Sockets (3)
System\Net\Sockets\Socket.cs (2)
3535File.Delete(unixEndPoint.BoundFileName); 4006private static SafeFileHandle? OpenFileHandle(string? name) => string.IsNullOrEmpty(name) ? null : File.OpenHandle(name, FileMode.Open, FileAccess.Read);
System\Net\Sockets\SocketAsyncEventArgs.Unix.cs (1)
259fileHandles[i] = File.OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, FileOptions.Asynchronous);
System.Net.WebClient (1)
System\Net\WebClient.cs (1)
351File.Delete(fileName);
System.Private.CoreLib (35)
Internal\Runtime\CompilerHelpers\ReachabilityInstrumentationSupport.cs (3)
26if (File.Exists(ReachabilityFileName) 27&& File.ReadAllBytes(ReachabilityFileName) is byte[] bytes 61File.WriteAllBytes(ReachabilityFileName, new ReadOnlySpan<byte>(s_region, s_size));
src\runtime\src\libraries\Common\src\Interop\Linux\os-release\Interop.OSReleaseFile.cs (2)
19if (File.Exists(filename)) 24lines = File.ReadAllLines(filename);
src\runtime\src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (1)
18if (File.Exists(ProcMountInfoFilePath))
src\runtime\src\libraries\Common\src\Interop\Unix\System.Native\Interop.MountPoints.cs (1)
44if (File.Exists(Interop.procfs.ProcMountInfoFilePath))
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\Directory.cs (9)
109FileSystem.SetCreationTime(fullPath, File.GetUtcDateTimeOffset(creationTimeUtc), asDirectory: true); 114return File.GetCreationTime(path); 119return File.GetCreationTimeUtc(path); 131FileSystem.SetLastWriteTime(fullPath, File.GetUtcDateTimeOffset(lastWriteTimeUtc), asDirectory: true); 136return File.GetLastWriteTime(path); 141return File.GetLastWriteTimeUtc(path); 153FileSystem.SetLastAccessTime(fullPath, File.GetUtcDateTimeOffset(lastAccessTimeUtc), asDirectory: true); 158return File.GetLastAccessTime(path); 163return File.GetLastAccessTimeUtc(path);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\File.cs (1)
589/// It is not possible to change the compression status of a <see cref="File"/> object
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\FileInfo.cs (5)
80FileStream fileStream = File.Open(NormalizedPath, options); 111FileStream fileStream = File.Create(NormalizedPath); 152FileStream fileStream = new FileStream(NormalizedPath, FileMode.Open, FileAccess.Read, FileShare.Read, File.DefaultBufferSize, false); 221File.Decrypt(FullPath); 228File.Encrypt(FullPath);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\FileSystemInfo.cs (3)
81set => CreationTimeCore = File.GetUtcDateTimeOffset(value); 93set => LastAccessTimeCore = File.GetUtcDateTimeOffset(value); 105set => LastWriteTimeCore = File.GetUtcDateTimeOffset(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\Path.cs (1)
82/// Unlike <see cref="File.Exists(string?)"/> it returns true for existing, non-regular files like pipes.
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\SharedMemoryManager.Unix.cs (1)
406if (File.Exists(sharedFilesPath))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\Assembly.cs (2)
291if (!File.Exists(normalizedPath)) 357if (!File.Exists(requestedAssemblyPath))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Resources\FileBasedResourceGroveler.cs (2)
72if (File.Exists(path)) 79if (File.Exists(fileName))
src\runtime\src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.NonAndroid.cs (4)
37using FileStream fs = File.OpenRead(path); 268using (SafeFileHandle sfh = File.OpenHandle(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) 353if (File.Exists(tzFilePath)) 357rawData = File.ReadAllBytes(tzFilePath);
System.Private.Windows.Core.TestUtilities (5)
TempFile.cs (5)
35File.WriteAllBytes(path, data); 43File.WriteAllText(path, text); 66public void AssertExists() => Assert.True(File.Exists(Path)); 68public string ReadAllText() => File.ReadAllText(Path); 79{ File.Delete(Path); }
System.Private.Xml (3)
System\Xml\Serialization\Compilation.cs (2)
240if ((string.IsNullOrEmpty(path) || !File.Exists(path)) && !string.IsNullOrEmpty(Assembly.GetEntryAssembly()?.Location)) 245if ((string.IsNullOrEmpty(path) || !File.Exists(path)) && !string.IsNullOrEmpty(AppContext.BaseDirectory))
System\Xml\Xsl\IlGen\XmlILTrace.cs (1)
67File.Delete(s_dirName + "\\" + fileName);
System.Reflection.MetadataLoadContext (3)
System\Reflection\MetadataLoadContext.Apis.cs (1)
128return LoadFromStreamCore(File.OpenRead(assemblyPath));
System\Reflection\TypeLoading\Assemblies\Ecma\EcmaAssembly.Modules.cs (2)
46if (File.Exists(modulePath)) 47return File.OpenRead(modulePath);
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
302[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
System.Runtime.Caching (1)
System\Runtime\Caching\FileChangeNotificationSystem.cs (1)
133lastWriteTime = File.GetLastWriteTime(filePath);
System.Security.Cryptography (9)
src\runtime\src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.cs (1)
593using (FileStream stream = File.OpenRead(path))
System\Security\Cryptography\X509Certificates\X509Certificate2.cs (6)
1219/// See <see cref="System.IO.File.ReadAllText(string)" /> for additional documentation about 1245ReadOnlySpan<char> certContents = File.ReadAllText(certPemFilePath); 1246ReadOnlySpan<char> keyContents = keyPemFilePath is null ? certContents : File.ReadAllText(keyPemFilePath); 1288/// See <see cref="System.IO.File.ReadAllText(string)" /> for additional documentation about 1311ReadOnlySpan<char> certContents = File.ReadAllText(certPemFilePath); 1312ReadOnlySpan<char> keyContents = keyPemFilePath is null ? certContents : File.ReadAllText(keyPemFilePath);
System\Security\Cryptography\X509Certificates\X509Certificate2Collection.cs (2)
392/// See <see cref="System.IO.File.ReadAllText(string)" /> for additional documentation about 415ReadOnlySpan<char> contents = System.IO.File.ReadAllText(certPemFilePath);
System.Speech (1)
Internal\SrgsCompiler\SRGSCompiler.cs (1)
121if (!File.Exists(cg._codebehind[i]))
System.Windows.Forms (6)
System\Windows\Forms\Controls\PictureBox\PictureBox.cs (1)
572_fileStream = File.OpenRead(_imageLocation!);
System\Windows\Forms\Controls\RichTextBox\RichTextBox.cs (1)
2725FileStream file = File.Create(path);
System\Windows\Forms\Dialogs\CommonDialogs\FileDialog.cs (1)
445return File.Exists(fileName);
System\Windows\Forms\Help\Help.cs (2)
259if (!File.Exists(localPath)) 282if (!File.Exists(localPath))
System\Windows\Forms\Input\Cursor.cs (1)
73_cursorData = File.ReadAllBytes(fileName);
System.Windows.Forms.Design (2)
System\ComponentModel\Design\ByteViewer.cs (1)
672SetBytes(File.ReadAllBytes(path));
System\Drawing\BitmapSelector.cs (1)
50return File.Exists(newPath) ? newPath : originalPath;
System.Windows.Forms.Primitives (1)
System\Windows\Forms\Internals\ThemingScope.cs (1)
114File.Delete(tempFilePath);
testhost (2)
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
testhost.arm64 (2)
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
testhost.x86 (2)
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
TypeScriptApiCompat (5)
ApiCompatSuppression.cs (1)
58foreach (var rawLine in File.ReadLines(filePath))
AtsSurface.cs (1)
59surfaces.Add(packageName, AtsSurfaceParser.Parse(packageName, File.ReadAllText(file), packageNames));
ExcludedPackageLoader.cs (2)
15if (!File.Exists(filePath)) 21foreach (var rawLine in File.ReadLines(filePath))
TypeScriptApiCompatRunner.cs (1)
31File.WriteAllText(options.ReportPath, report);
vbc (6)
src\roslyn\src\Compilers\Shared\BuildServerConnection.cs (4)
455if (!File.Exists(processFilePath)) 556if (!File.Exists(serverInfo.processFilePath)) 848if (!File.Exists(FilePath)) 878File.Delete(FilePath);
src\roslyn\src\Compilers\Shared\RuntimeHostInfo.cs (2)
54var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 102if (File.Exists(filePath))
VBCSCompiler (25)
src\roslyn\src\Compilers\Server\VBCSCompiler\AnalyzerConsistencyChecker.cs (1)
88string? resolvedPath = FileUtilities.ResolveRelativePath(analyzerReference.FilePath, basePath: null, baseDirectory: baseDirectory, searchPaths: SpecializedCollections.EmptyEnumerable<string>(), fileExists: File.Exists);
src\roslyn\src\Compilers\Server\VBCSCompiler\CompilationCache.cs (18)
157if (!File.Exists(cachedAssemblyPath)) 160if (entryMutex is null && !File.Exists(cachedAssemblyPath)) 166if (!File.Exists(cachedAssemblyPath)) 205return !File.Exists(Path.Combine(entryDir, cachedFileName)); 220File.Copy(sourcePath, targetPath, overwrite: true); 221File.SetLastWriteTimeUtc(targetPath, outputTimestampUtc); 269if (!File.Exists(keyPath)) 276var oldKey = File.ReadAllText(keyPath, Encoding.UTF8); 325File.Copy(outputFiles.AssemblyPath, Path.Combine(stagingDir, AssemblyFileName), overwrite: false); 331File.WriteAllText(Path.Combine(stagingDir, dllName + ".key"), deterministicKey, Encoding.UTF8); 332File.WriteAllText(Path.Combine(stagingDir, CreatedFileName), DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture)); 369if (sourcePath is not null && File.Exists(sourcePath)) 371File.Copy(sourcePath, destPath, overwrite: false); 460File.WriteAllText(path, DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture)); 558if (File.Exists(lastUsedPath)) 560var text = File.ReadAllText(lastUsedPath).Trim(); 586if (File.Exists(createdPath)) 588var text = File.ReadAllText(createdPath).Trim();
src\roslyn\src\Compilers\Shared\BuildServerConnection.cs (4)
455if (!File.Exists(processFilePath)) 556if (!File.Exists(serverInfo.processFilePath)) 848if (!File.Exists(FilePath)) 878File.Delete(FilePath);
src\roslyn\src\Compilers\Shared\RuntimeHostInfo.cs (2)
54var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 102if (File.Exists(filePath))
vstest.console (5)
CommandLine\Executor.cs (1)
568contents = File.ReadAllText(fileName);
Processors\ListFullyQualifiedTestsArgumentProcessor.cs (1)
199File.WriteAllLines(_commandLineOptions.ListTestsTargetPath, _discoveredTests);
Processors\RunSettingsArgumentProcessor.cs (1)
166return XmlReader.Create(new StringReader(File.ReadAllText(runSettingsFile, Encoding.UTF8)), XmlRunSettingsUtilities.ReaderSettings);
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
vstest.console.arm64 (5)
src\vstest\src\Microsoft.TestPlatform.Execution.Shared\DebuggerBreakpoint.cs (2)
86if (!File.Exists(vsAttachPath)) 108if (File.Exists(path))
src\vstest\src\vstest.console\CommandLine\Executor.cs (1)
568contents = File.ReadAllText(fileName);
src\vstest\src\vstest.console\Processors\ListFullyQualifiedTestsArgumentProcessor.cs (1)
199File.WriteAllLines(_commandLineOptions.ListTestsTargetPath, _discoveredTests);
src\vstest\src\vstest.console\Processors\RunSettingsArgumentProcessor.cs (1)
166return XmlReader.Create(new StringReader(File.ReadAllText(runSettingsFile, Encoding.UTF8)), XmlRunSettingsUtilities.ReaderSettings);