@@ -714,6 +714,41 @@ public async Task NativeVersionInfo_CreateNativeResourceDll()
714714 }
715715#endif
716716
717+ [ Theory ]
718+ [ Trait ( "TestCategory" , "FailsInCloudTest" ) ]
719+ [ MemberData ( nameof ( CloudBuildVariablesData ) ) ]
720+ public async Task SetCloudBuildVersionVars_CanBeDisabled ( IReadOnlyDictionary < string , string > properties , string expectedMessage , bool setAllVariables )
721+ {
722+ using ( ApplyEnvironmentVariables ( properties ) )
723+ {
724+ // Disable SetCloudBuildVersionVars target
725+ this . testProject . AddProperty ( "NBGV_SetCloudBuildVersionVars" , "false" ) ;
726+
727+ var versionOptions = new VersionOptions
728+ {
729+ Version = SemanticVersion . Parse ( "1.0" ) ,
730+ CloudBuild = new VersionOptions . CloudBuildOptions { SetAllVariables = setAllVariables , SetVersionVariables = true } ,
731+ } ;
732+ this . WriteVersionFile ( versionOptions ) ;
733+ this . InitializeSourceControl ( ) ;
734+
735+ BuildResults buildResult = await this . BuildAsync ( ) ;
736+ this . AssertStandardProperties ( versionOptions , buildResult ) ;
737+
738+ // Assert GitBuildVersion was NOT set because we disabled the target
739+ string notExpectedMessage = UnitTestCloudBuildPrefix + expectedMessage
740+ . Replace ( "{NAME}" , "GitBuildVersion" )
741+ . Replace ( "{VALUE}" , buildResult . BuildVersion ) ;
742+ Assert . DoesNotContain ( notExpectedMessage , buildResult . LoggedEvents . Select ( e => e . Message . TrimEnd ( ) ) ) ;
743+
744+ // Assert GitBuildVersionSimple was NOT set
745+ notExpectedMessage = UnitTestCloudBuildPrefix + expectedMessage
746+ . Replace ( "{NAME}" , "GitBuildVersionSimple" )
747+ . Replace ( "{VALUE}" , buildResult . BuildVersionSimple ) ;
748+ Assert . DoesNotContain ( notExpectedMessage , buildResult . LoggedEvents . Select ( e => e . Message . TrimEnd ( ) ) ) ;
749+ }
750+ }
751+
717752 /// <inheritdoc/>
718753 protected override GitContext CreateGitContext ( string path , string committish = null ) => throw new NotImplementedException ( ) ;
719754}
0 commit comments