尽管插入插入

发布于 2025-02-01 10:03:14 字数 661 浏览 5 评论 0原文

这是我工作的简化版本的Jenkinsfile。

pipeline {
    agent any
    
    tools {
        msbuild 'MSBuild 17'
    }
    
    stages {
        stage('Build') {
            steps {
                pwsh ('''
                    nuget restore "${env:workspace}/Sandbox.sln"
                    msbuild "${env:workspace}/Sandbox.sln" /clp:ErrorsOnly -t:build -verbosity:diag -property:Configuration=Release -property:RestorePackages=true
                ''')
            }
        }
    }
}

我在“全局配置工具”中定义了多个版本的MSBuild。我不断收到未被视为内部或外部命令,可操作程序或批处理文件

我尝试了withenv('msbuild 17'){...} 任何一个。

有人有提示如何解决这个问题吗?

This is a simplified version of Jenkinsfile that I work on;

pipeline {
    agent any
    
    tools {
        msbuild 'MSBuild 17'
    }
    
    stages {
        stage('Build') {
            steps {
                pwsh ('''
                    nuget restore "${env:workspace}/Sandbox.sln"
                    msbuild "${env:workspace}/Sandbox.sln" /clp:ErrorsOnly -t:build -verbosity:diag -property:Configuration=Release -property:RestorePackages=true
                ''')
            }
        }
    }
}

I have defined multiple versions of MSBuild in "Global Configuration Tool". I keep receiving not recognized as an internal or external command, operable program or batch file

I tried withEnv('MSBuild 17') { ... } which didn't work either.

Does anyone have a hint how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

强辩 2025-02-08 10:03:14

这是如何使用MSBUILD工具的一个示例:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                script {
                    def msbuild_tool = tool name: 'MSBuildTools16', type: 'hudson.plugins.msbuild.MsBuildInstallation'
                    pwsh label: 'Compilation', script: '& "' + msbuild_tool + '" project.sln'
                }
            }
        }
    }
}

就我而言,MSBuildTools16 => “ C:\ Program Files(X86)\ Microsoft Visual Studio \ 2019 \ BuildTools \ MSBUILD \ MSBUILD \ Current \ bin \ msbuild.exe”

另一个解决方案:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                bat "\"${tool 'MSBuildTools16'}\" project.sln"
            }
        }
    }
}

Here is an example of how to use the MSBuild tool:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                script {
                    def msbuild_tool = tool name: 'MSBuildTools16', type: 'hudson.plugins.msbuild.MsBuildInstallation'
                    pwsh label: 'Compilation', script: '& "' + msbuild_tool + '" project.sln'
                }
            }
        }
    }
}

And in my case, MSBuildTools16 => "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MsBuild.exe"

Another solution:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                bat "\"${tool 'MSBuildTools16'}\" project.sln"
            }
        }
    }
}
你的呼吸 2025-02-08 10:03:14

我在“全局配置工具”中定义了多个版本的msbuild。

假设安装了 jenkins msbuild插件,只有父母 bin 其中指定的文件夹路径:

”

://issues.jenkins.io/browse/jenkins-56389“ rel =“ nofollow noreferrer”>问题56389 用于插图:

        stage('Build') {
            steps {
                echo 'Building..'
                bat "\"${tool 'MSBuild'}\\msbuild.exe\" ${SQLPROJ} /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
            }
        }

I have defined multiple versions of MSBuild in "Global Configuration Tool".

That supposed having installed the Jenkins MSBuild plugin, with only the parent Bin folder path specified in it:

https://raw.githubusercontent.com/jenkins-infra/plugins-wiki-docs/master/msbuild/docs/images/jenkins-msbuild.png

See issue 56389 for illustration:

        stage('Build') {
            steps {
                echo 'Building..'
                bat "\"${tool 'MSBuild'}\\msbuild.exe\" ${SQLPROJ} /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
            }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文