View As Code does not provide proper imports

When viewing a project as code in TeamCity, the generated code is not 100% valid as it will be missing the imports for VCS roots and possibly others.

If I were to take the code as supplied by “View As Code” and commit it to my versioned configurations, TeamCity would error with various entity not found issues.

 

 

View As Code:

package Acr.buildTypes

import jetbrains.buildServer.configs.kotlin.*

object Acr_Acr215Install : BuildType({
   name = "ACR 2.15 Install"
   description = "Builds the release version of the application and installs"

   buildNumberPattern = "${Acr_Acr215_Acr215Version.depParamRefs.buildNumber}"

   vcs {
       root(Acr_215_Acr215,
        (Truncated)

 

As committed to VCS and working:

package Acr.buildTypes

import Acr.vcsRoots.Acr_215_Acr215
import Acr_215.buildTypes.Acr_Acr215_Acr215Version
import jetbrains.buildServer.configs.kotlin.*
import jetbrains.buildServer.configs.kotlin.buildSteps.DotnetMsBuildStep
import jetbrains.buildServer.configs.kotlin.buildSteps.NUnitStep
import jetbrains.buildServer.configs.kotlin.buildSteps.NuGetInstallerStep
import jetbrains.buildServer.configs.kotlin.buildSteps.dotnetMsBuild
import jetbrains.buildServer.configs.kotlin.buildSteps.nuGetInstaller
import jetbrains.buildServer.configs.kotlin.buildSteps.nunit
import jetbrains.buildServer.configs.kotlin.triggers.vcs
import jetbrains.buildServer.configs.kotlin.buildFeatures.perfmon

object Acr_Acr215Install : BuildType({
   name = "ACR 2.15 Install"
   description = "Builds the release version of the application and installs"

   buildNumberPattern = "${Acr_Acr215_Acr215Version.depParamRefs.buildNumber}"

   vcs {
       root(Acr.vcsRoots.Acr_215_Acr215,

 

 

0
1 comment
Hi Keith,

The “View as code” functionality is not expected to include all imports or to provide full settings.kts with all imports: it only shows the DSL for the specific setting you’re currently viewing.
When you open build configuration settings and click View as code, the DSL representation of the current configuration will be displayed, and the setting being viewed (for example, a build step, a trigger, or dependencies) will be highlighted. This feature is primarily intended as a helper when you’re not sure what the DSL code should look like for a given feature/setting, not as a full export of the project’s Kotlin DSL files.

Best regards,
Anton
0

Please sign in to leave a comment.