Attach VS2010 Debugger to GTest running from MSBuild - visual-studio-2010

I Compile my GTests using my own configuration:
<ProjectConfiguration Include="Test|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
I Run my GTests using a custom made Target
<Target Name="RunTests">
<Message Text="Configuration: $(Configuration)" Importance="High" />
<Exec Command="..\$(Configuration)\#(BuildProjectFile->'%(Filename)').exe" />
</Target>
I would like to run my GTest using VS2010 instead of running it as its own executeable. I want the advantage of using the VS2010 debugger to debug my tests.
Is there a correct task to start my compilation so the debugger picks it up or do i rather have to return something to VS2010 so it starts executing on its own?

By using Returns="#(ManagedTargetPath)" VS is getting the executeable is is supposed to start.
Instead of starting the Test via the Exec Task the Target should just be Build with Debugging enables and the TargetPath should be returned to VS for execution.
The following example redirects an incoming build call to execute the unittests instead and launch them using the build in mechanism of VS2010.
(I currently do not understand why breakpoints in the *.cc files are ignored and the ones in the *.c files are not ignored - could be a coincidence)
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c" />
<ClCompile Include="Source\A.c" />
<ClCompile Include="Source\A_unittest.cc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7506F0B9-7FA3-4E1E-8EB5-A1819E232C59}</ProjectGuid>
<RootNamespace>STACKOVERFLOW</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target
Name="NormalBuild"
Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
DependsOnTargets="_DetermineManagedStateFromCL;CustomBeforeBuild;$(BuildDependsOn)"
Returns="#(ManagedTargetPath)">
<ItemGroup>
<ManagedTargetPath Include="$(TargetPath)" Condition="'$(ManagedAssembly)' == 'true'" />
</ItemGroup>
</Target>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Test|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<Target Name="Build"
Returns="#(ManagedTargetPath)">
<MSBuild Projects="STACKOVERFLOW.vcxproj" Targets="NormalBuild" Properties="Configuration=Test" />
</Target>
<Target Name="CustomBeforeBuild">
<ItemGroup Condition="'$(Configuration)' == 'Test'">
<ClCompile Remove="*main.c*" />
<ClCompile Include="c:/gtest/*.c*" />
</ItemGroup>
</Target>
</Project>

Related

Xamarin error System.DllNotFoundException: /system/lib/libsqlite.so on Android 7.0

I get this exception whenever I try to create a SQLite.Net.SQLiteConnection in android 7.0
any idea how to fix it?
I'm using these nuget pacakges:
<packages>
<package id="ExifLib.PCL" version="1.0.1" targetFramework="monoandroid6" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid43" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid43" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="monoandroid6" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="monoandroid6" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="monoandroid6" />
<package id="SQLiteNetExtensions" version="1.3.0" targetFramework="xamarinios1" />
<package id="sqlite-net-pcl" version="1.2.1" targetFramework="monoandroid70" />
<package id="SQLitePCL.bundle_green" version="0.9.3" targetFramework="monoandroid60" />
<package id="SQLitePCL.plugin.sqlite3.android" version="0.9.3" targetFramework="monoandroid60" />
<package id="SQLitePCL.raw" version="0.9.3" targetFramework="monoandroid60" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.core" version="1.1.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.lib.e_sqlite3.android" version="1.1.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.provider.e_sqlite3.android" version="1.1.1" targetFramework="monoandroid70" />
<package id="Xam.Plugins.Settings" version="2.5.1.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.CustomTabs" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.FFImageLoading" version="2.2.5" targetFramework="monoandroid70" />
<package id="Xamarin.FFImageLoading.Forms" version="2.2.5" targetFramework="monoandroid70" />
<package id="Xamarin.Forms" version="2.3.3.168" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Ads" version="29.0.0.1" targetFramework="monoandroid60" />
<package id="Xamarin.GooglePlayServices.Analytics" version="29.0.0.1" targetFramework="monoandroid60" />
<package id="Xamarin.GooglePlayServices.AppIndexing" version="29.0.0.1" targetFramework="monoandroid60" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0.1" targetFramework="monoandroid60" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0.1" targetFramework="monoandroid60" />
<package id="Xamarin.Insights" version="1.12.3" targetFramework="monoandroid60" />
</packages>
I think you are using oystein.krog package
You should try with praeclarum package
The solution for me was to update the SQLiteNetExtensions nuget package to the latest Alpha version (prerelease), it's important to first remove all references to sqlite related libs though.
i have same issue in my xamarin android. i install this package for sqlite and set targeted version to android 8(oreo) my application works again

VSTS NuGet step restore error: You cannot call a method on a null-valued expression at CallSite.Target(Closure , CallSite , Object , Object )

I get an error during execute NuGet restore step in Visual Studio Team Services (was Visual Studio Online). I didn’t set nothing special but the error appears. The error is:
2016-04-10T16:53:36.3476846Z ##[debug]Adding credentials section to NuGet.config
2016-04-10T16:53:36.5691737Z ##[error]System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
2016-04-10T16:53:36.5701787Z ##[error] at CallSite.Target(Closure , CallSite , Object , Object )
2016-04-10T16:53:36.5711737Z ##[error] at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
2016-04-10T16:53:36.5721738Z ##[error] at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
2016-04-10T16:53:36.5721738Z ##[error] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Here all the details. At the beginning of few screen shots:
Configuration Bild Step in VSO
Logs from output console in VSO
My main nuget configuration file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\Aleksandra.Tests\packages.config" />
<repository path="..\Aleksandra\packages.config" />
</repositories>
Next subconfigs look like these:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="bootstrap" version="3.0.0" targetFramework="net45" />
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="jQuery" version="1.10.2" targetFramework="net45" />
<package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Twitter" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.6.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="Respond" version="1.2.0" targetFramework="net45" />
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
</packages>
… and ..
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
</packages>
Have a look at this article about the package restore. To quote the important points, repositores.config file will be automatically regenerated when needed. Same applies in general to the packages folder. You can safely remove them from source control.
Also, you can leave the Path to NuGet.config textbox blank. Unless you have special needs (e.g. private feeds for which you'd need authentication), you don't need that file, all packages.config files will be picked up in the solution.

MSBuild /p:OutputType=Library builds as executable

My problem is as stated in the title: I'm trying to build my project from msbuild, and I specify /p:OutputType=Library, and the result is an executable application. I've been toying with this all day, and was able to successfully get it to build as a library twice, but unfortunately I haven't been able to reproduce it since then.
I've been using this command:
msbuild project.sln /p:OutputType=Library;Configuration=Release;Platform=x64
Here's my vcxproj:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="driver.cpp" />
<ClCompile Include="XMessageBox.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="accounts.h" />
<ClInclude Include="udp.h" />
<ClInclude Include="VersionHelpers.h" />
<ClInclude Include="XMessageBox.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="project.rc" />
</ItemGroup>
<ItemGroup>
<None Include="UAC_shield.ico" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4D362A3E-CA53-444C-B1C8-C49641823875}</ProjectGuid>
<RootNamespace>project</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<PlatformToolset>v100</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>project64</TargetName>
<OutDir>..\x64\Release</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(PLATFORM_SDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(PLATFORM_SDK_DIR);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem>
</Link>
<Bscmake>
<PreserveSbr>true</PreserveSbr>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(PLATFORM_SDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(PLATFORM_SDK_DIR);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>$(PLATFORM_SDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat />
<BufferSecurityCheck>false</BufferSecurityCheck>
<BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(PLATFORM_SDK_DIR)\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
</Link>
<Bscmake>
<PreserveSBR>true</PreserveSBR>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>$(PLATFORM_SDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<BufferSecurityCheck>false</BufferSecurityCheck>
<BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(PLATFORM_SDK_DIR)\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<SubSystem>Windows</SubSystem>
</Link>
<Bscmake>
<PreserveSBR>true</PreserveSBR>
</Bscmake>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Any ideas?
Thanks in advance,
~P
Create multiple configurations that have the ConfigurationType property set to
the type of module you want to build, either Application or DynamicLibrary.
For instance you could have one configuration named ReleaseDLL that has
ConfigurationType=DynamicLibrary and one configuration named ReleaseExe
that has ConfigurationType=Application. Then run
"msbuild project.sln /p:OutputType=Library;Configuration=ReleaseExe;Platform=x64"
or
"msbuild project.sln /p:OutputType=Library;Configuration=ReleaseDLL;Platform=x64"
depending on which one you want.

Why am I getting "HTTP Status 404 - Servlet <servlet name> is not available"

I am going through this Spring web MVC tutorial but am stuck at section 1.12 where I should be seeing a "Hello" page handled by my Controller, but instead get "HTTP Status 404 - Servlet is not available". I have looked at the other stackoverflow questions that have the same error, but none have helped.
Here are the relevant files:
/web/WEB-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<!--
The "Front Controller" (http://en.wikipedia.org/wiki/Front_Controller_pattern).
that dispatches requests to registered handlers (Controller implementations).
-->
<servlet>
<servlet-name>filth</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>filth</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
/web/WEB-INF/filth-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- the application context definition for the filth DispatcherServlet -->
<context:component-scan base-package="com.filth.controller"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/web/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
/web/view/hello.jsp:
<html>
<head><title>Hello :: Spring Application</title></head>
<body>
<h1>Hello - Spring Application</h1>
<p>Greetings.</p>
</body>
</html>
/src/main/java/com/filth/controller/HelloController.java:
package com.filth.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
/**
* Controller for the "Hello" page
*/
#Controller
public class HelloController {
private static final Log LOGGER = LogFactory.getLog(HelloController.class);
#RequestMapping(value="/hello.html", method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
LOGGER.info("Returning hello view");
return new ModelAndView("hello");
}
}
/build.properties:
# Ant properties for building FiLTH
appserver.home=${env.WORKSPACE}/tomcat6
appserver.lib=${appserver.home}/lib
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret
/build.xml:
<?xml version="1.0"?>
<project name="filth" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." default="usage">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement path="${build.lib.dir}/ant-contrib.jar"/>
</classpath>
</taskdef>
<taskdef name="ivy-configure" classname="org.apache.ivy.ant.IvyConfigure"/>
<taskdef name="ivy-resolve" classname="org.apache.ivy.ant.IvyResolve"/>
<taskdef name="ivy-retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/>
<taskdef name="ivy-deliver" classname="org.apache.ivy.ant.IvyDeliver"/>
<taskdef name="ivy-publish" classname="org.apache.ivy.ant.IvyPublish"/>
<target name="ivy-resolve">
<ivy:configure />
<ivy:resolve file="${ivy.dep.file}" conf="${ivy.configurations}" />
<ivy:retrieve pattern="${ivy.retrieve.pattern}" conf="${ivy.configurations}" />
<echo message="ivy.dep.file: ${ivy.dep.file}"/>
<echo message="ivy.configurations: ${ivy.configurations}"/>
<echo message="ivy.retrieve.pattern: ${ivy.retrieve.pattern}"/>
</target>
<property environment="env"/>
<property file="build.properties"/>
<property file="build.passwords.properties" />
<property name="src.dir" value="src/main/java"/>
<property name="test.dir" value="src/test"/>
<property name="web.dir" value="web/"/>
<property name="build.dir" value="target"/>
<property name="name" value="filth"/>
<property name="resources.dir" value="src/main/resources"/>
<path id="master-classpath">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${resources.dir}"/>
<pathelement path="${build.dir}"/>
</path>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message="install --> Install application in Tomcat"/>
<echo message="reload --> Reload application in Tomcat"/>
<echo message="start --> Start Tomcat application"/>
<echo message="stop --> Stop Tomcat application"/>
<echo message="list --> List Tomcat applications"/>
<echo message=""/>
</target>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="buildtests" description="Compile test tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${test.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="tests" depends="build, buildtests" description="Run tests">
<junit printsummary="on"
fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Test.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
***********************************************************
</fail>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<!-- End Tomcat tasks -->
</project>
/ivy.xml:
<ivy-module version="2.0">
<info organisation="org.apache" module="hello-ivy"/>
<dependencies>
<dependency org="org.springframework" name="spring-context" rev="4.1.6.RELEASE"/>
<dependency org="org.springframework" name="spring-webmvc" rev="4.1.6.RELEASE"/>
<dependency org="commons-logging" name="commons-logging" rev="1.2"/>
<dependency org="javax.servlet" name="servlet-api" rev="2.5"/>
<dependency org="junit" name="junit" rev="4.12"/>
</dependencies>
</ivy-module>
I am getting the error when navigating to http://localhost:8080/filth/hello.html.
catalina.out does not give any errors, and I do see the log entry from HelloController.java, but very inconsistently--not sure why that is either.
Note that http://localhost:8080/filth/index.jsp, and http://localhost:8080/filth/view/hello.jsp work--just going through the Controller is not working as expected.
Anyone have any ideas?
Let me know if you need more context/info.
Thanks!
Figured it out. I didn't have the necessary jar dependencies included in the deployment--added a lib/ directory in WEB-INF and had ivy place necessary runtime dependecies there (the "deploy" ant target took it from there). I didn't see this error earlier because I wasn't looking in the right log file--finally saw that logging output was going to [tomcat]/logs/localhost...log.

ant target for junit fails to load spring context xml files

When i run ant target for junit, following error occurs:
Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml] Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml] Offending resource: class path resource [esw-web-ctx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]; nested exception is java.net.UnknownHostException: www.springframework.org
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml]
Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]
Offending resource: class path resource [esw-web-ctx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]; nested exception is java.net.UnknownHostException: www.springframework.org
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76).......
......
Ant target:
<target name="junit" depends="buildlocal">
<delete dir="${JUNIT_REPORT}" failonerror="false"/>
<mkdir dir="${BUILD_TEST_DIR}" />
<mkdir dir="${JUNIT_REPORT}" />
<echo message="Launching JUnit tests" />
<copy todir="${BUILD_TEST_DIR}/" overwrite="true">
<fileset dir="${COMP_TESTCONFIG_DIR}">
<exclude name="*.properties.template" />
<exclude name="*.xml.template" />
<exclude name="*.ccf.template" />
<exclude name="**/*.bak" />
<exclude name="**/*.keep" />
<exclude name="**/*.keep.*" />
<exclude name="**/*.contrib" />
<exclude name="**/*.java" />
<exclude name="**/*.class" />
<exclude name="**/*.contrib.*" />
</fileset>
</copy>
<junit printsummary="on" fork="off" haltonfailure="false" failureproperty="junit.failure" showoutput="false">
<classpath>
<path refid="CLASSPATH_JUNIT"/>
</classpath>
<batchtest fork="off" todir="${BUILD_TEST_DIR}">
<fileset dir="${TEST_CLASSES_DIR}">
<include name="**/*Test.class" />
<include name="**/Test*.class" />
<!-- <exclude name="**/EswCacheInitializerTest.class" /> -->
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<echo message="Launching junitreport" />
<junitreport todir="${JUNIT_REPORT}">
<fileset dir="${BUILD_TEST_DIR}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${JUNIT_REPORT}"/>
</junitreport>
<delete dir="${BUILD_TEST_DIR}" failonerror="false"/>
<echo message="**** Junit report generated at the location: ${JUNIT_REPORT} ***"/>
<echo message="==============================================="/>
<echo message="****** JUNIT BUILD ENDS - CORE ****** "/>
<echo message="==============================================="/>
<fail if="junit.failure" message="Unit test(s) failed. See reports at: ${JUNIT_REPORT}"/>
</target>
<path id="CLASSPATH_JUNIT">
<path refid="LIB_JAVAC"/>
<pathelement location="${TEST_CLASSES_DIR}" />
<pathelement location="${BUILD_TEST_DIR}" />
<pathelement location="${APP_DIR}\bgc-esw-core\target\classes" />
<pathelement location="${APP_DIR}\bgc-esw-web\target\classes" />
<pathelement location="${APP_DIR}\bgc-esw-wicket-components\target\classes" />
<fileset dir="${BUILD_LIBS_HOME}">
<include name="*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-web\build" erroronmissingdir="false">
<include name="bgc-esw-*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-services\build" erroronmissingdir="false">
<include name="bgc-esw-service*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-core\build" erroronmissingdir="false">
<include name="bgc-esw-core*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-wicket-components\build" erroronmissingdir="false">
<include name="bgc-esw-wicket-components*.jar" />
</fileset>
</path>
Check the XML namespaces definitions in that application context definition. It typically contains something like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
I bet that some of the spring XSD files are not in the jars on your classpath; all these should be locally on your system and not downloaded from web.

Resources