Problems adding solution to TFS source control through solution explorer

Ive also added this thread onto the Visual Studio MSBuild forum

I have read the link about VS integration with MSBuildhttp://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=64816&SiteID=1 which was very useful but I have a slightly different scenario I think.

I am using WiX to generate setups in my organisation (which basically uses XML source code to generate msi's via a command line tool). I want to integrate this into VS2005 so that when my devs do an IDE solution build, aswell as building all the c# projects' code to produce dll's, there is also a project that builds all the WiX source code into an msi. To achieve this I added a basic c# class library project to my solution called 'Setup', then I stripped out all text in Setup.csproj and replaced it with the following:

<?xml version="1.0" encoding="utf-8"?>

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">

<PropertyGroup>

<!--Insert Name of the Product/msi below-->


<OutputName>BureauController</OutputName>

<OutputType>Package</OutputType>

<ToolPath>$(wixroot)</ToolPath>

<BuildType Condition="'$(OfficialBuild)'!='true'">Dev</BuildType>

<MsiNumber Condition="'$(IsDesktopBuild)'!='false'">1.0.0</MsiNumber>

<LocalizedStringFile>$(ToolPath)\lib\WixUI_en-us.wxl</LocalizedStringFile>

<!--Insert the actaul GUID from setup.csproj you created in the solution below-->

<ProjectGuid>{7EDA69A0-2D3A-42F7-8D77-3CE92CAB4D1D}</ProjectGuid>


</PropertyGroup>

<ItemGroup>

<Compile Include="*.wxs" />

<Compile Include="..\..\..\..\..\Common Setup\Common.Web.wxs">

<Link>Common.Web.wxs</Link>

</Compile>

</ItemGroup>


<Import Project="$(ToolPath)\exchange.wix.targets" />

</Project>

And basically everything works fine, I build the solution in the IDE and I get my msi that works as expected. The only problem is that when I try to add my solution to source control through the solution explorer, I get an error because the solution item 'Common.Web.wxs' is already in source control in the location defined - I was hoping that as this is only linked to the solution and not actually part of its structure that it would not try and check it in to source control. Any ideas how I can stop this happening? And while your at it, if your reading this thread thinking NOOOOOO! you really dont want to do that, please let me know ;-)

For info the imported targets file is below:

<Project InitialTargets="CheckRequiredProperties" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Some properties must be set in the main project file, before using this .TARGETS file -->
<Target
Name="CheckRequiredProperties">

<Error Condition="'$(OutputName)'==''"
Text="The &quot;OutputName&quot; property is not set in project &quot;$(MSBuildProjectFile)&quot;. The OutputName defines the name of the output without a file extension. Please set this in the project file before the &lt;Import&gt; of the .Targets file."/>
<Error Condition="'$(OutputType)'==''"
Text="The &quot;OutputType&quot; property is not set in project &quot;$(MSBuildProjectFile)&quot;. The OutputType defines whether an msi, merge module, or wix library is being built. Please set this in the project file before the &lt;Import&gt; of the .Targets file. Possible values are 'package', 'module', 'library', and 'object'."/>
</Target>

<ItemGroup>
<WiXLibrary Include="$(ToolPath)\ca\sca.wixlib;$(ToolPath)\lib\wixui_minimal.wixlib" />
</ItemGroup>

<UsingTask TaskName="Candle" AssemblyFile="wixtasks.dll" />
<UsingTask TaskName="Lit" AssemblyFile="wixtasks.dll" />
<UsingTask TaskName="Light" AssemblyFile="wixtasks.dll" />

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildBinPath)\Wix.targets</MSBuildAllProjects>
</PropertyGroup>

<!-- Define the default file extensions -->
<PropertyGroup>
<TargetExt Condition="'$(OutputType)'=='package'">.msi</TargetExt>
<TargetExt Condition="'$(OutputType)'=='module'">.msm</TargetExt>
<TargetExt Condition="'$(OutputType)'=='library'">.wixlib</TargetExt>
<IntermediateExt Condition="'$(IntermediateExt)'==''">.wixobj</IntermediateExt>
</PropertyGroup>

<!-- Default output type and path properties -->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<OutputPath Condition=" '$(OutputPath)' == '' ">bin\$(Configuration)\</OutputPath>
<OutDir>$(OutputPath)</OutDir> <!-- Example, bin\Debug\ -->
<TargetName Condition=" '$(TargetName)' == '' ">$(OutputName)</TargetName> <!-- Example, MySetup -->
<TargetFileName Condition=" '$(TargetFileName)' == '' ">$(TargetName)$(TargetExt)</TargetFileName><!-- Example, MySetup.msi -->
<TargetPath Condition=" '$(TargetPath)' == '' ">$(OutDir)$(TargetFileName)</TargetPath> <!-- Example, bin\Debug\MySetup.msi -->

<!-- Properties for the intermediate object output -->
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">obj\</BaseOutputPath> <!-- Example, obj\ -->
<IntermediateOutputPath Condition=" '$(IntermediateOutputPath)' == '' ">$(BaseOutputPath)$(Configuration)\</IntermediateOutputPath><!-- Example, obj\Debug\ -->

<!-- Specify the Candle .wixobj if it isn't defined. If there is not supposed to be object output (ie. Only linking), don't set the object output. -->
<CompileObjOutput Condition=" '$(CompileObjOutput)' == '' And '$(NoObjOutputDefault)' != 'true' ">$(IntermediateOutputPath)$(OutputName)$(IntermediateExt)</CompileObjOutput><!-- Example, obj\Debug\MySetup.wixobj -->
</PropertyGroup>

<!-- Default Lib properties copied from the Compile properties. -->
<PropertyGroup>
<LibNoLogo Condition="'$(LibNoLogo)'==''">$(NoLogo)</LibNoLogo>
<LibExtension Condition="'$(LibExtension)'==''">@(Extension)</LibExtension>
<LibSuppressSchemaValidation Condition="'$(LibSuppressSchemaValidation)'==''">$(SuppressSchemaValidation)</LibSuppressSchemaValidation>
<LibSuppressIntermediateFileVersionMatching Condition="'$(LibSuppressIntermediateFileVersionMatching)'==''">$(SuppressIntermediateFileVersionMatching)</LibSuppressIntermediateFileVersionMatching>
<LibSuppressAllWarnings Condition="'$(LibSuppressAllWarnings)'==''">$(SuppressAllWarnings)</LibSuppressAllWarnings>
<LibUseSmallTableDefinitions Condition="'$(LibUseSmallTableDefinitions)'==''">$(UseSmallTableDefinitions)</LibUseSmallTableDefinitions>
<LibTreatWarningsAsErrors Condition="'$(LibTreatWarningsAsErrors)'==''">$(TreatWarningsAsErrors)</LibTreatWarningsAsErrors>
<LibWarningLevel Condition="'$(LibWarningLevel)'==''">$(WarningLevel)</LibWarningLevel>
<LibVerboseOutput Condition="'$(LibVerboseOutput)'==''">$(VerboseOutput)</LibVerboseOutput>
<LibVerboseOutputLevel Condition="'$(LibVerboseOutputLevel)'==''">$(VerboseOutputLevel)</LibVerboseOutputLevel>
</PropertyGroup>

<!-- Default Linker properties copied from the Compile properties. -->
<PropertyGroup>
<LinkerNoLogo Condition="'$(LinkerNoLogo)'==''">$(NoLogo)</LinkerNoLogo>
<LinkerExtension Condition="'$(LinkerExtension)'==''">@(Extension)</LinkerExtension>
<LinkerSuppressSchemaValidation Condition="'$(LinkerSuppressSchemaValidation)'==''">$(SuppressSchemaValidation)</LinkerSuppressSchemaValidation>
<LinkerSuppressIntermediateFileVersionMatching Condition="'$(LinkerSuppressIntermediateFileVersionMatching)'==''">$(SuppressIntermediateFileVersionMatching)</LinkerSuppressIntermediateFileVersionMatching>
<LinkerSuppressAllWarnings Condition="'$(LinkerSuppressAllWarnings)'==''">$(SuppressAllWarnings)</LinkerSuppressAllWarnings>
<LinkerUseSmallTableDefinitions Condition="'$(LinkerUseSmallTableDefinitions)'==''">$(UseSmallTableDefinitions)</LinkerUseSmallTableDefinitions>
<LinkerTreatWarningsAsErrors Condition="'$(LinkerTreatWarningsAsErrors)'==''">$(TreatWarningsAsErrors)</LinkerTreatWarningsAsErrors>
<LinkerWarningLevel Condition="'$(LinkerWarningLevel)'==''">$(WarningLevel)</LinkerWarningLevel>
<LinkerVerboseOutput Condition="'$(LinkerVerboseOutput)'==''">$(VerboseOutput)</LinkerVerboseOutput>
<LinkerVerboseOutputLevel Condition="'$(LinkerVerboseOutputLevel)'==''">$(VerboseOutputLevel)</LinkerVerboseOutputLevel>
</PropertyGroup>

<!-- Compile the wxs source. -->
<PropertyGroup>
<CompileDependsOn>PrepareForBuild</CompileDependsOn>
</PropertyGroup>
<Target
Name="Compile"
Inputs="@(Compile);$(MSBuildAllProjects)"
Outputs="$(MSBuildAllProjects)"
DependsOnTargets="$(CompileDependsOn)">

<Candle
SourceFiles="@(Compile)"
DefineConstants="$(DefineConstants)"
PreprocessToStdOut="$(PreprocessToStdOut)"
PreprocessToFile="$(PreprocessToFile)"
IncludeSearchPaths="@(IncludeSearchPath)"
NoLogo="$(NoLogo)"
OutputFile="$(IntermediateOutputPath)"
SuppressSchemaValidation="$(SuppressSchemaValidation)"
UseSmallTableDefinitions="$(UseSmallTableDefinitions)"
ShowSourceTrace="$(ShowSourceTrace)"
Extensions="@(CompileExtension)"
SuppressAllWarnings="$(SuppressAllWarnings)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
WarningLevel="$(WarningLevel)"
VerboseOutput="$(VerboseOutput)"
VerboseOutputLevel="$(VerboseOutputLevel)"
ToolPath="$(ToolPath)"
/>
</Target>

<PropertyGroup>
<!-- Don't depend on the Compile task because Lib can be run from a different project than the compile. -->
<LibDependsOn>PrepareForBuild</LibDependsOn>
</PropertyGroup>
<Target
Name="Lib"
Inputs="@(Compile);
@(WixObject);
$(MSBuildAllProjects)"
Outputs="$(OutDir)$(TargetFileName)"
DependsOnTargets="$(LibDependsOn)"
Condition=" '$(OutputType)' == 'library' ">

<Lit
ObjectFiles="@(WixObject);@(WixLibrary);@(Compile -> '$(IntermediateOutputPath)%(Filename).wixobj')"
NoLogo="$(LibNoLogo)"
OutputFile="$(OutDir)$(TargetFileName)"
Extensions="@(LibExtension)"
SuppressSchemaValidation="$(LibSuppressSchemaValidation)"
SuppressIntermediateFileVersionMatching="$(LibSuppressIntermediateFileVersionMatching)"
SuppressAllWarnings="$(LibSuppressAllWarnings)"
UseSmallTableDefinitions="$(LibUseSmallTableDefinitions)"
TreatWarningsAsErrors="$(LibTreatWarningsAsErrors)"
WarningLevel="$(LibWarningLevel)"
VerboseOutput="$(LibVerboseOutput)"
VerboseOutputLevel="$(LibVerboseOutputLevel)"
ToolPath="$(ToolPath)"
/>
</Target>

<PropertyGroup>
<!-- Don't depend on the Compile task because Link can be run from a different project than the compile. -->
<LinkDependsOn>PrepareForBuild</LinkDependsOn>
</PropertyGroup>
<Target
Name="Link"
Inputs="@(Compile);
@(WixObject);
@(WixLibrary);
$(MSBuildAllProjects)"
Outputs="$(OutDir)$(TargetFileName)"
DependsOnTargets="$(LinkDependsOn)"
Condition=" '$(OutputType)'=='package' Or '$(OutputType)'=='module' ">

<Light
ObjectFiles="@(WixObject);@(WixLibrary);@(Compile -> '$(IntermediateOutputPath)%(Filename).wixobj')"
BaseInputPath="$(BaseInputPath)"
CabinetCache="$(CabinetCache)"
Extensions="@(LinkExtension)"
BaseUncompressedImagesOutputPath="$(BaseUncompressedImagesOutputPath)"
LocalizedStringFile="$(LocalizedStringFile)"
NoLogo="$(LinkerNoLogo)"
LeaveTemporaryFiles="$(LeaveTemporaryFiles)"
ReuseCabinetCache="$(ReuseCabinetCache)"
OutputFile="$(OutputPath)$(TargetFileName)"
OutputAsXml="$(OutputAsXml)"
SuppressDefaultAdminSequenceActions="$(SuppressDefaultAdminSequenceActions)"
SuppressDefaultAdvSequenceActions="$(SuppressDefaultAdvSequenceActions)"
SuppressAssemblies="$(SuppressAssemblies)"
SuppressFiles="$(SuppressFiles)"
SuppressLayout="$(SuppressLayout)"
SuppressSchemaValidation="$(LinkerSuppressSchemaValidation)"
SuppressDefaultUISequenceActions="$(SuppressDefaultUISequenceActions)"
SuppressIntermediateFileVersionMatching="$(LinkerSuppressIntermediateFileVersionMatching)"
SuppressAllWarnings="$(LinkerSuppressAllWarnings)"
UseSmallTableDefinitions="$(LinkerUseSmallTableDefinitions)"
TreatWarningsAsErrors="$(LinkerTreatWarningsAsErrors)"
WarningLevel="$(LinkerWarningLevel)"
VerboseOutput="$(LinkerVerboseOutput)"
VerboseOutputLevel="$(LinkerVerboseOutputLevel)"
ToolPath="$(ToolPath)"
/>

</Target>

<!-- Make the build directories. -->
<UsingTask TaskName="ExchangeTasks.GenerateGUID" AssemblyFile="$(CommonScriptsLocation)\ExchangeTasks.dll" />
<UsingTask TaskName="ExchangeTasks.GetBuildNumber" AssemblyFile="$(CommonScriptsLocation)\ExchangeTasks.dll" />
<UsingTask TaskName="ExchangeTasks.SaveMSIDetails" AssemblyFile="$(CommonScriptsLocation)\ExchangeTasks.dll" />

<Target
Name="PrepareForBuild">
<MakeDir Directories="$(IntermediateOutputPath);$(OutputPath)"/>
<GetBuildNumber Condition="'$(IsDesktopBuild)'!='false'" File="$(wixroot)\Installer.txt">
<Output TaskParameter="MsiNumber" PropertyName="MsiNumber" />
</GetBuildNumber>
<GenerateGUID>
<Output TaskParameter="GUID" PropertyName="ProductGuid" />
</GenerateGUID>
<SaveMSIDetails
File = "$(OutputPath)$(OutputName)_msi.txt"
ProductGUID = "$(ProductGuid)"
ProductVersion = "$(MsiNumber)">
</SaveMSIDetails>
<CreateProperty Value="Config=$(Configuration);BuildType=$(BuildType);ProductName=$(OutputName);ProductVersion=$(MsiNumber);ProductGuid=$(ProductGuid)">
<Output TaskParameter="Value" PropertyName="DefineConstants" />
</CreateProperty>

</Target>

<PropertyGroup>
<BuildDependsOn>PrepareForBuild;Compile;Link</BuildDependsOn>
</PropertyGroup>
<Target
Name="Build"
DependsOnTargets="$(BuildDependsOn)">
</Target>

<PropertyGroup>
<RebuildDependsOn>Clean;Build</RebuildDependsOn>
</PropertyGroup>
<Target
Name="Rebuild"
DependsOnTargets="$(RebuildDependsOn)">
</Target>

<!-- Clean task -->
<PropertyGroup>
<CleanDependsOn></CleanDependsOn>
</PropertyGroup>
<Target
Name="Clean"
DependsOnTargets="$(CleanDependsOn)">

<Delete Files=
"$(OutDir)$(TargetFileName);
$(CompileObjOutput)"/>
</Target>
</Project>

[18065 byte] By [simonburgess] at [2007-12-20]
# 1

As you have discovered the Add Solution to Source Control feature performs a "collision check" where it attempts to determine if any files in the solution already exist in source control. If they do, then the IDE gives you two choices: cancel or pick a different location in the repository.

Obviously there are cases such as yours where the collision is benign, and one would like the operation to continue adding all files that did not collide. Interestingly enough, one of our test engineers hit that last week, and I intend to put in a fix (adding an Ignore or Continue button to the dialog) in the next day or two. Unfortunately, since that fix will not go out for some time that does not provide you with an immediate help.

Some possible workarounds include:

1) Use Source Control Explorer to make sure all the local folders have workspace mappings. Then use Source Control Explorer to add and check in all the files in the solution. After that you can use File->Source Control->Change Source Control to create source control bindings for the solution and project.

-or-

2) Perform an "Exclude from project" on the file that is colliding. Then perform the Add Solution to Source Control and check in. After that you can do an "Add Existing Item" to bring the colliding item back in, and it should be recognized as controlled.

--Ben Ryan

BenRyan at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Version Control...

Visual Studio Team System

Site Classified