コード例 #1
0
        public void ItShallCreateAssemblyAttributes(TestAsset asset)
        {
            var(assets, projectFile) = TestAssetsManager.CloneAssetsForTest(asset);
            try
            {
                RemoveSdkVersionFromProjectFile(projectFile).Should().BeTrue();

                var startInfo = CreateMsBuildInvocation(assets, $"-p:Version=1.2.3-beta.005 -p:FileVersion=1.2.3.4 -p:AssemblyVersion=1.2.3.0 -bl:..\\{nameof(ItShallCreateAssemblyAttributes)}_{asset}.binlog");
                var process   = Process.Start(startInfo);
                Assert.NotNull(process);
                process.WaitForExit(30_000).Should().BeTrue();

                var builtOutput = new FileInfo(Path.Combine(assets.FullName, asset.GetExpectedOutputAssembly()));
                builtOutput.Exists.Should().BeTrue();

                var versionInfo = FileVersionInfo.GetVersionInfo(builtOutput.FullName);
                versionInfo.Should().NotBeNull();
                versionInfo.ProductVersion.Should().Be("1.2.3-beta.005");
                versionInfo.FileVersion.Should().Be("1.2.3.4");

                Assembly.ReflectionOnlyLoadFrom(builtOutput.FullName).GetName().Version.Should().BeEquivalentTo(new Version("1.2.3.0"));
            }
            finally
            {
                assets.Delete(true);
            }
        }