Пример #1
0
        private static string ReferenceForCsproj(Dll referenceDll)
        {
            if (referenceDll == null)
            {
                return(null);
            }

            return($@"<Reference Include=""{referenceDll.AssemblyName}, Version={referenceDll.Version}, Culture=neutral, PublicKeyToken=7f465a1c156d4d57"">
      <HintPath>{referenceDll.FilePath}</HintPath>
    </Reference>");
        }
Пример #2
0
        internal Dll CompileAndCopyLocal(string assemblySuffix, string cs, Dll reference = null, Version version = null)
        {
            version = version ?? new Version(0, 0, 0, 0);
            var assemblyName = $"{m_TestName}_{assemblySuffix}";

            using (var tempDir = new TempDir())
            {
                var copyOfReferenceDll = reference?.CopyTo(tempDir);
                tempDir[assemblyName + ".csproj"] = Csproj(
                    IncludeSourceFile("class.cs"),
                    IncludeSourceFile("assemblyInfo.cs"),
                    ReferenceForCsproj(copyOfReferenceDll));

                tempDir["assemblyinfo.cs"] = $"using System.Reflection;\r\n[assembly: AssemblyVersion(\"{version}\")]";
                tempDir["class.cs"]        = cs;
                RunMsbuild(tempDir, assemblyName + ".csproj");

                var dll = tempDir.PathTo($@"bin\Debug\{assemblyName}.dll");
                FileAssert.Exists(dll);
                File.Copy(dll, $"{assemblyName}.dll", true);
                return(new Dll(Path.Combine(Directory.GetCurrentDirectory(), assemblyName + ".dll"), version));
            }
        }