这个问题似乎很普遍,但我尚未找到一致的解决方案。
我正在使用VS2017和TFS2017构建一整套的4.6.1类库-有些将是nuget,有些将是插件-尽管使用与所有先前的项目。
我们使用平台“ Any CPU”和“ dev”,“ test”,“ train”或“ prod”进行配置来构建所有项目-使用TFS2013多年来运行良好,并且至少用于30个项目,因此远迁移到了2017年构建系统。
但是,在一个非常简单的项目中,我不断收到错误信息...
Error MSB4126: The specified solution configuration "dev|any cpu" is invalid.
尽管已将配置和平台从构建正确地传递为“ dev”和“ any cpu”,并且解决方案和项目文件都已设置了正确的配置...
sln:
Microsoft Visual Studio Solution File, Format Version 12.00
Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MailMessageSerialisation", "MailMessageSerialisation\MailMessageSerialisation.csproj", "{9D787499-7DBB-4760-8923-C86FD13C4394}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
dev|Any CPU = dev|Any CPU
prod|Any CPU = prod|Any CPU
test|Any CPU = test|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9D787499-7DBB-4760-8923-C86FD13C4394}.dev|Any CPU.ActiveCfg = dev|Any CPU
{9D787499-7DBB-4760-8923-C86FD13C4394}.dev|Any CPU.Build.0 = dev|Any CPU
{9D787499-7DBB-4760-8923-C86FD13C4394}.prod|Any CPU.ActiveCfg = prod|Any CPU
{9D787499-7DBB-4760-8923-C86FD13C4394}.prod|Any CPU.Build.0 = prod|Any CPU
{9D787499-7DBB-4760-8923-C86FD13C4394}.test|Any CPU.ActiveCfg = test|Any CPU
{9D787499-7DBB-4760-8923-C86FD13C4394}.test|Any CPU.Build.0 = test|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2C7FB0D0-7327-4D21-9A11-0B34AC019E68}
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://XXXXXXXXX:8080/tfs/infrastructure
SccLocalPath0 = .
SccProjectUniqueName1 = MailMessageSerialisation\\MailMessageSerialisation.csproj
SccProjectName1 = MailMessageSerialisation
SccLocalPath1 = MailMessageSerialisation
EndGlobalSection
EndGlobal
csproj:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">dev</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9D787499-7DBB-4760-8923-C86FD13C4394}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MailMessageSerialisation</RootNamespace>
<AssemblyName>MailMessageSerialisation</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'dev|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\dev\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'test|AnyCPU'">
<OutputPath>bin\test\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'prod|AnyCPU'">
<OutputPath>bin\prod\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<!--
snip
-->
</Project>
构建输出的构建解决方案步骤:
******************************************************************************
Starting: Build solution **\*.sln
******************************************************************************
==============================================================================
Task : Visual Studio Build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.119.0
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613727)
==============================================================================
"E:\ci\builds\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation.sln" /nologo /nr:false /dl:CentralLogger,"E:\ci\builds\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=8659b024-ac52-47a4-a6ab-1be44fd5e1f8|SolutionDir=e:\ci\builds\61\s\MailMessageSerialisation\dev"*ForwardingLogger,"E:\ci\builds\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:platform="any cpu" /p:configuration="dev" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="TFS_620f346c-98e2-4693-ab12-3a966e56835f_build_66_333"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 30/07/2018 3:34:36 PM.
Project "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "dev|any cpu".
Project "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation.sln" (1) is building "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.csproj" (2) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\dev\".
Creating directory "obj\dev\".
CoreCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:AnyCPU /errorreport:prompt /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" /reference:e:\ci\builds\61\s\MailMessageSerialisation\dev\packages\S22.SerializableMailMessage.1.0.5742.24665\lib\net46\S22.Mail.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Net.dll" /debug+ /debug:full /filealign:512 /out:obj\dev\MailMessageSerialisation.dll /ruleset:"C:\Program Files (x86)\Micros...
Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn
_CopyFilesMarkedCopyLocal:
Copying file from "e:\ci\builds\61\s\MailMessageSerialisation\dev\packages\S22.SerializableMailMessage.1.0.5742.24665\lib\net46\S22.Mail.dll" to "bin\dev\S22.Mail.dll".
Creating "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\obj\dev\MailMessageSerialisation.csproj.CopyComplete" because "AlwaysCreate" was specified.
CopyFilesToOutputDirectory:
Copying file from "obj\dev\MailMessageSerialisation.dll" to "bin\dev\MailMessageSerialisation.dll".
MailMessageSerialisation -> e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\bin\dev\MailMessageSerialisation.dll
Copying file from "obj\dev\MailMessageSerialisation.pdb" to "bin\dev\MailMessageSerialisation.pdb".
Done Building Project "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.csproj" (default targets).
Done Building Project "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.28
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln" /nologo /nr:false /dl:CentralLogger,"E:\ci\builds\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=52be2739-dbca-4b96-a2a2-1bbd66410e14|SolutionDir=e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation"*ForwardingLogger,"E:\ci\builds\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:platform="any cpu" /p:configuration="dev" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="TFS_620f346c-98e2-4693-ab12-3a966e56835f_build_66_333"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 30/07/2018 3:34:38 PM.
e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln.metaproj(0,0): Error MSB4126: The specified solution configuration "dev|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.
Project "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln" on node 1 (default targets).
e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln.metaproj : error MSB4126: The specified solution configuration "dev|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln]
Done Building Project "e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln" (default targets) -- FAILED.
Build FAILED.
"e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln" (default target) (1) ->
(ValidateSolutionConfiguration target) ->
e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln.metaproj : error MSB4126: The specified solution configuration "dev|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [e:\ci\builds\61\s\MailMessageSerialisation\dev\MailMessageSerialisation\MailMessageSerialisation.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.15
Process 'msbuild.exe' exited with code '1'.
******************************************************************************
Finishing: Build solution **\*.sln
******************************************************************************
如您所见,在项目和解决方案中都存在一个“ dev | any cpu”配置,并且告知构建使用这些设置...
... /p:platform="any cpu" /p:configuration="dev" ...
我尝试重新创建解决方案文件,使用不同大小写的参数,跳过一个(不起作用),跳过两个(起作用,但不允许根据目标环境更改配置),已经尝试在构建定义步骤中直接输入参数,也尝试通过构建变量输入参数,但无济于事。
大约在一周前,我在另一个项目上发生过这种情况,当时只能通过从TFS完全删除项目并完全重建项目和解决方案(仅保留来自原始版本),最后重建了版本-问题就消失了!我以为某个地方有腐败,但现在又发生了……
我无法在此处发布完整的构建步骤日志,它太大了,但是我已经做了数十次,无法理解为什么这个项目应该与性质相似的其他项目有所不同。在构建定义中使用相同的解决方案/项目结构以及相同的步骤和参数,并且所有这些都起作用。
我不想每次遇到此问题时都需要重新构建整个项目,解决方案和构建定义-我还有很多其他项目要在2013年过渡,其中有些要复杂得多。
有什么想法吗?有什么建议吗? (请!)
编辑: 为简单起见,我从解决方案中排除了单元测试项目。只是将其重新添加以进行进一步的测试,我发现它的构建还算不错,尽管与原始库项目相比,其配置完全相同!嗯...
Edit2: 简单地添加另一个构建定义(从头开始构建,而不是克隆)并不能解决问题,它似乎是集合中项目的一个属性。已提出MS的高级支持案例。
Edit3: 我已经确认这不是代码问题。我复制了一个“损坏的”项目的文件结构,在集合中创建了一个新项目并导入了代码,然后再次手工构建(与损坏的相同),然后构建了项目!
我相信,我也可以排除我添加到TFS中的“导出/导入构建定义”扩展。我导出了一个损坏的构建定义,仅更改了JSON中的名称,然后将其导入了新项目-可以了!
答案 0 :(得分:0)
问题在于,2017年的构建系统与XAML的构建发生了变化,并且开发人员(应该保持匿名)有些懒惰/单调。
在TFS的正常情况下,我们有...
<project name>
\dev
\project 0
\project 1
\etc.
创建第一个项目时,VS会在与项目相同的文件夹中自动创建解决方案文件。如果在首次签入之前将其移动/保存到dev文件夹,那么所有人都会对世界感到满意。
不幸的是,这种情况只有在将项目保存到TFS中之后才会发生,所以我们得到...
<project name>
\dev
\project0
project.sln
project0.csproj
\project1
project1.csproj
\etc.
一旦发现错误,开发人员会将.sln文件重新保存到dev文件夹并检入-项目中现在有两个解决方案文件,但是第二个解决方案文件很少见并且被遗忘了。
<project name>
\dev
project.sln
\project0
project.sln <- Problem!
project0.csproj
\project1
project1.csproj
\etc.
如果从源代码管理中打开了项目,则不会下载第二个.sln,这就是将代码复制到新位置的原因-通过打开解决方案并仅下载有效内容已清除了代码。 / p>
新的构建系统将下载整个dev分支,并且(默认情况下)告诉构建步骤构建** \ *。sln-可以找到两个解决方案文件。顺便说一句,旧的XAML构建系统指定了一个正确的.sln文件的路径,因此该问题不会自行显现。
如果在移动.sln文件之前设置了dev,test,train和prod的配置管理器设置,则第二个解决方案将包含正确的值并愉快地进行构建,只是稍微减慢了构建步骤。但是,如果它仍然仅包含“调试”和“发布”,则说明该参数不匹配,并且构建失败。
我感谢Microsoft Premium Support的Martin仔细研究了一些严重的尺寸日志并在大海捞针中找到了这根小针。