Target folder cannot be created building a PIP project - ocean

I am trying to build a PIP project in VS 2010. I'm using Ocean SDK 2012. When I create the PIP project I've used the wizard but I've noticed the pre-build event has the DeployList.xml first when it should be second in the parameter list. Now when trying to do a build it comes up with an error saying that
"Target folder cannot be created."
I'm not sure what or where this target folder is supposed to be. Has anybody done a PIP project before and can give any tips...

FYI: we got a couple of similar issues via Ocean Developers Portal (http://www.ocean.slb.com), probably one was from you :), in this case you can ignore the following answer:
We found some problem with csproj file, you can check if you have the same: open the file in notepad/textpad and check these two tags for PropertyGroup Condition:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
The problem here is that DeployCopier parser skips these nodes because it does not match with the one with the attribute:
" '$(Configuration)|$(Platform)' == 'Release|x64' "
Please note the lead and trail space!
DeployCopier uses this to compare:
string.Format(" '$(Configuration)|$(Platform)' == '{0}|{1}' ", data.Config, data.Platform);
(with the leading and trailing spaces)
In a future, it will be fixed in DeployCopier to ignore the spaces.
If the statements do not have single space after starting double quote and before ending double quote in your file, try to add a space before and after the PropertyGroup attribute value like:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">

There is no problem to use PIP builder from SDK 2012 with VS2010. Please be sure that your PIP project is under the same solution with your Plug-in and you have only one plug-in that will be packed in PIP. The proper PIP project's events look as:
Pre-build:
rmdir "$(ProjectDir)\obj\copytemp" /s /q
"$(ProjectDir)DeployCopier.exe" "$(ProjectDir)DeployList.xml" "$(ProjectDir)\obj\copytemp" /config:$(ConfigurationName) /platform:"$(PlatformName)"
Post-build:
"%Ocean2012Home%\PluginPackager.exe" /p "$(ProjectDir)\obj\copytemp\DeployPlugin1testBuild.dll" "$(TargetDir)$(TargetName).pip"
Probably you need to delete your previous PIP project from solution and recreate it.

Related

What configuration and platform does msbuild use by default when building a solution file or project files

If I execute msbuild from the command line with my solution file or project file as input without setting configuration and platform how does msbuild determine which configuration and platform to use for each project in the solution or the single project file?
In case of solution files - both msbuild and xbuild try to find Debug config and Mixed platforms platform, but if that doesn't exist then it falls back to the first one that it can find under SolutionConfigurationPlatforms in the .sln file. Keep in mind that this is just solution level config/platform, and it uses the mapping in ProjectConfigurationPlatforms in the .sln file to determine the config/platform to use for the project.
In case of project files, the *proj files usually have the default Configuration and Platform specified. But if even that is missing then the Microsoft.Common.*targets file chooses Debug|AnyCPU as the default.
Update: default specification in the csproj might look like this:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
...
It's essentially saying "if $(Configuration) is unspecified, then set it to Debug", and similar for Platform.

"IIS Web Application Name' has already been defined" when using msdeploy from TFS Build

So here's the deal: I have a Visual Studio solution that is made up of numerous projects. Two of these projects are web application projects. Of these two, I want to have TFS build deploy one of them to our dev server after a successful build/test run.
To get the web app to deploy, I updated the deploy target of my .csproj so it looks like the following:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DeployOnBuild>true</DeployOnBuild>
<DeployTarget>MsDeployPublish</DeployTarget>
<CreatePackageOnPublish>true</CreatePackageOnPublish>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<MSDeployServiceUrl>https://192.168.21.79</MSDeployServiceUrl>
<DeployIisAppPath>DeploymentTest</DeployIisAppPath>
<UserName>deploy</UserName>
<Password>sosecure</Password>
<AllowUntrustedCertificate>true</AllowUntrustedCertificate>
<SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
</PropertyGroup>
With this configuration, my web app was getting deployed to the server successfully. Unfortunately there was one minor problem. For reasons that are too frustrating to go into here (and at the end of the day, can't likely be changed), when the deploy runs and pushes the app to our server, there's one CSS file in the project that I need skipped. That is to say, I want the server copy of the file to be left alone, even if it's different from what's in the project.
To support this requirement, I added the following to my .csproj:
<PropertyGroup>
<OnBeforePackageUsingManifest>AddSkipRules</OnBeforePackageUsingManifest>
</PropertyGroup>
<Target Name="AddSkipRules">
<ItemGroup>
<MsDeploySkipRules Include="SkipCss">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>site\.css$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipCss2">
<SkipAction>Update</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>site\.css$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
With this added, my expectation was that the build would skip processing of my site.css file. Alas, after trying a number of different things, the file always got updated on the server. After a bit more digging, I found something (here on SO or on a blog, don't recall at this point) that mentioned the .csproj needs a directive to ensure msdeploy.exe is used to handle the deployment. With that in mind, I added the following:
<PropertyGroup>
<UseMsDeployExe>true</UseMsDeployExe>
</PropertyGroup>
Now when I run the build, it fails with the following error:
MSDEPLOY: The parameter 'IIS Web Application Name' has already been defined.
So, I tried removing the <DeployIssAppPath> element from the .csproj but that just led to the following error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets (4220): The "ConcatFullServiceUrlWithSiteName" task was not given a value for the required parameter "SiteAppName".
At this point I'm pretty much out of ideas and really need to get this thing working. Any suggestions or insight as to what I'm missing to get around the error about 'IIS Web Application Name' already being defined or the last error about 'SiteAppName' not having a value would be appreciated.
Have you tried stopping the app pool for the target before deploying? I use something like this in PowerShell, which is called from MSBuild in my deployment processes:
echo ""
echo "Stopping $($args[0]) App Pool..."
echo ""
#Stop App Pool
MsDeployAppPoolSwitch $args[0] $args[1] $args[2] $args[3] "StopAppPool"
echo ""
echo "Deploying to $($args[0])..."
echo ""
#Deploy Site
WebsiteDeploy $args[0] $args[1] $args[2] $args[3] $DropFolder
echo ""
echo "Starting $($args[0]) App Pool..."
echo ""
#Start App Pool
MsDeployAppPoolSwitch $args[0] $args[1] $args[2] $args[3] "StartAppPool"

What is default msbuild platform

How does msbuild chose a platform if it is not specified? It seems to me that for some solutions it selects "Mixed Platforms" for others "x86".
I switch on the diagnostics level of logging and the only thing I can see is that "Initial Properties" at the beginning contain e.g. "Platform = Mixed Platforms" without any explanation why.
To preempt some answers, I know that I can override the platform manually. That is not an issue. I need to know what msbuild does when it is NOT specified.
This may help: I was researching this and finally tracked down the default platform for my install, by looking in Microsoft.Cpp.Default.props (line 21 in this version of Visual Studio), which lives in Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120:
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
This means that under VS12 (Visual Studio 2013) MSBuild will pick Win32 as the platform if no other platform is explicitly specified. As noted in some other questions, setting an environment variable named Platform will change the default to the value you set.
Important note: If you invoke MSBuild on a Visual Studio solution file (*.sln) rather than a project file, and you don't specify a platform in the MSBuild arguments, then it appears that MSBuild will choose the platform automatically based on the first entry under the SolutionConfigurationPlatforms global section in the solution file. I haven't found this documented anywhere but from experimentation it appears to be the case. This means that editing your project file and providing a different default Platform property (as described above), MSBuild will ignore this default, because it will have chosen the platform already before it even starts looking at the project. Invoking MSBuild directly on the project file seems to bypass this behavior.
MSBuild does not choose but whatever MSBuild project it is building may default certain properties. I am assuming that your question relates to how MSBuild builds a solution file.
msbuild.exe "somesolution.sln" /t:Build
You need to look at the projects that make up the solution, in there you will see the properties that are set. For example you will probably see the following at the top of the project file:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
...
</PropertyGroup>
This shows a PropertyGroup containing amongst others two properties, Configuration and Platform. Their values are set based on a Condition. The condition says says that if no value has been set for the property Configuration it should default to 'Debug'. Likewise if nothing is set for Platform it should default to AnyCPU.
You may also see a Conditional PropertyGroup:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
</PropertyGroup>
What this condition says is that if the property Configuration and Platform match Debug and AnyCPU then it should apply all of the properties contained within.
A point to note is that the property names are just an arbitrary name and the values are just strings. However when building .Net projects there is a convention to which these properties and their values are a part. To see what the default values are you do not need to open each project in a text editor. You can go into Visual Studio and look at the solution configuration.

Visual Studio macro/anything else to iterate through all projects and set project properties

I'm trying to write a macro/anything else to iterate though all projects and remove all other build configuration other that Active Solution Configuration - Debug and Active Solution Platform - x86. Also after editing the configuration for all projects, I want to set pre-build and post-build events to all projects. I have no clue where to start. Please help. I have like 44 projects in solution and its really hard and time consuming to set all these manually.
Pre Build event:
rd /s /q "$(ProjectDir)bin"
Post Build event:
copy "$(TargetPath)" "$(SolutionDir)TOTALOUTPUT\" /y
I could not understand your point clearly but let me try to help...
You can create a new configuration by clickint Build->Configuration Manager->New (top left, there is active solution configuration, click on it you will see New option)
Name it and check the projects you wanna compile
Then simply go your solution, select the projects with Ctrl and then leftclick->properties
VS allows you to change the properties of multiple projects, so you can easily writes post builds and pre builds events like that, it will work for all projects you selected...
You can choose to put this in a macro, or not, however I would actually recommend directly going to the .csproj and .sln files. In the .csproj files they have a series of property groups that specify the build configuration like so:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
If you create a simple script/program/etc that traverses all the .csproj files in question, and read the .csproj xml file. While going through it, you can simply ensure that only the 2 PropertyGroups defining configurations show up. These two configurations will be your debug/release configs. Further, in that same script you can add your pre/post build events, they are simply a different type of property group, such as so:
<PropertyGroup>
<PostBuildEvent>xcopy $(TargetName).* "%25SEARCH1%25"\bin\ /i /y</PostBuildEvent>
</PropertyGroup>
Note: It is likely better to do this as a script when Visual Studio is closed rather than as a macro, but I see no reason why simply wrapping this into a macro wouldn't work either.

How or why is MSBuild choosing the x64 platform when I don't specify it instead of AnyCPU?

I'm running msbuild.exe via Rake from a regular PowerShell console. This is the command as printed from a diagnostic level run
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "D:/Projects/machine.specifications/Source/Machine.Specifications/Machine.Specifications.csproj31881140" /maxcpucount /target:Build /verbosity:diagnostic /property:Configuration=Debug /property:TrackFileAccess=false /property:BuildInParallel=false /property:BuildRunner=Rake
And the build is failing because msbuild is picking x64 as the Platform.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9): error : The OutputPath property is not set for project 'Machine.Specifications.csproj37103470'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='X64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.
I'm not passing it in on the command line (or from the script). The csproj has a default configuration
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
and two specific configurations
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
So, I expected the AnyCPU platform to be selected. But, for some reason, something is picking or sending in x64. I don't think the Rake system is a problem here, I've seen this behavior before on raw cmd line calls to msbuild (but I haven't documented them).
I'm on 64-bit Windows 7, calling msbuild 4.0. I don't know if that's relevant.
I am loading the 64-bit Visual Studio tools (C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64) using Invoke-BatchFile in my PowerShell profile. Could that be the culprit?
Why would msbuild deliberately choose x64 anyway? The 32-bit version doesn't choose x86 for you.
*1: The PowerShell console is at %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
*2: I'm running the MSpec build (here's the rakefile and the msbuild call)
When you launch Visual Studio x64 command window, it sets an environment variable :
Platform=X64
This is a difference from the 32 bit command window, where this environment variable is not defined, and MSBuild then uses the conditional logic to use default platform.
You can either remove the Platform environment variable in your batch file, or pass in explicit Platform property as a parameter to MSBuild.