public void RespectDefaultTempPath() { var provider = new DesktopStrongNameProvider(tempPath: null); using (var stream = (DesktopStrongNameProvider.TempFileStream)provider.CreateInputStream()) { Assert.Equal(Path.GetTempPath(), Path.GetDirectoryName(stream.Path) + @"\"); } }
public void RespectCustomTempPath() { var tempDir = Temp.CreateDirectory(); var provider = new DesktopStrongNameProvider(tempPath: tempDir.Path); using (var stream = (DesktopStrongNameProvider.TempFileStream)provider.CreateInputStream()) { Assert.Equal(tempDir.Path, Path.GetDirectoryName(stream.Path)); } }
internal static void FixResources(CommandLineArguments args, Compilation compilation) { if (!string.IsNullOrEmpty(args.Win32ResourceFile) || !string.IsNullOrEmpty(args.Win32Icon) || !string.IsNullOrEmpty(args.Win32Manifest)) { var file = System.IO.Path.Combine(args.OutputDirectory, args.OutputFileName); if (System.IO.File.Exists(file)) { var hRes = BeginUpdateResource(file, false); if (hRes != IntPtr.Zero) { var res = EndUpdateResource(hRes, false); } if (compilation.HasStrongName) { // We have to resign the assembly because updating the resources // may have invalidated the signature. var provider = new DesktopStrongNameProvider(); using (var inputstream = provider.CreateInputStream()) { using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { fs.CopyTo(inputstream); } using (var outputstream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Write)) { provider.SignStream(compilation.StrongNameKeys, inputstream, outputstream); outputstream.Flush(); } } } } } }