My app.config did not transform the value - visual-studio

In my windows service application, I want to debug it by my configuration. Originally I used slowcheetah, however it just did not work. So I wanted to manually to transform it.
There is a method to do it.
In the project file, I have
<ItemGroup>
<Content Include="App.config" />
<Content Include="App.Debug.config">
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.TestDebug.config">
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.Release.config">
<DependentUpon>App.config</DependentUpon>
</Content>
<None Include="packages.config">
</None>
</ItemGroup>
Also I have
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
<!-- Generate transformed app config in the intermediate directory -->
<TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
<!-- Force build process to use the transformed configuration file from now on. -->
<ItemGroup>
<AppConfigWithTargetPath Remove="app.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
In App.TestDebug.config, the value is:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="veserver" value="xx.xx.xx.221" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
In App.Debug.config, the value is:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="veserver" value="xx.xx.xx.221" />
In App.config, the value is:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="veserver" value="xx.xx.xx.222" />
Now I debug it with
App.TestDebug.config
In the C# code ConfigurationManager.AppSettings["veserver"] is still
xx.xx.xx.222
Which means that it didn't transform the value. It is supposed to be
xx.xx.xx.221
Why?

Find a solution by myself.
<ItemGroup>
<Content Include="App.config" />
<None Include="App.Debug.config">
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.TestDebug.config">
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.Release.config">
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="packages.config">
</None>
Change
Content
to
None
.

Related

Your project does not reference "MonoAndroid,Version=v9.0"

As google is requiring all new as well as updates to target api level 28.
I have a xamarin android project using visual studio on the PC
Doing so I can not get past the error:
Your project does not reference "MonoAndroid,Version=v9.0" framework. Add a reference to "MonoAndroid,Version=v9.0" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.
My project doesnt currently have any nuget packages, so i am completley unaware what they are asking for here.
I have of course attempted to target v9 in the project properites. This of course updates the project and manifest as expected.
Ive long had the 28 sdk installed, but sure to update my sdks using not only the MS repo but the latest released on the google repo...
Ive also been sure that the correct Mono.Android.dll referance is used and exists:
\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\Mono.Android.dll"
Finally i went and upgraded to Visual Studio 2019 thinking that would fix whatever i have screwed up but it did not.
I then proceeded to try targeting android Q that didnt work either. so im stuck at v8.1 or below.
Ive scoured the internet for answers.
Suggestions ive tried are to be sure the project did not have the Use Latest platform tag, and to run as administrator
Any suggestion apprecated.
Update in response to comments:
Repeating what i said above. But to provide proof,
I have of course attempted to target v9 in the project properites. This of course updates the project and manifest as expected.
Here is the project file stating the version targeted:
Ive long had the 28 sdk installed, but sure to update my sdks using not only the MS repo but the latest released on the google repo...
Here is the manifest indicating what is targeted:
The target version as viewed in properties
And the compile version set
And the current content of the sdk manager
though i also tried using the google repository and android Q
And here is the project file contents:
(I should note contrary to the above ive added a nuget package to see if it helps anything)
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C79A7EE8-2CFC-4158-9BE0-D540A39E2823}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{122416d6-6b49-4ee2-a1e8-b825f31c79fe}</TemplateGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MotoApp</RootNamespace>
<AssemblyName>MotoApp</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a</AndroidSupportedAbis>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
</ItemGroup>
<ItemGroup>
<Compile Include="App\Activities\Interaction\Scaffolding\CharacteristicMenuItem.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\DeviceMenuItem.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\IgnitionGraceItem.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\IgnitionModeItem.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\IgnitionStateItem.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\IgnitionComboItem.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\SecurityPinItem.cs" />
<Compile Include="App\Activities\Interaction\Ui\Ignition\IgnitionGraceActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\Ignition\IgnitionModeActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\Ignition\IgnitionComboActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\Security\SecurityPinActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\Security\SecurityActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\Devices\DeviceNameActivity.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\ArrayAdapters.cs" />
<Compile Include="App\Activities\Interaction\Ui\Devices\DevicesActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\FunctionsActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\Ignition\IgnitionActivity.cs" />
<Compile Include="App\Activities\Interaction\Ui\MainActivity.cs" />
<Compile Include="App\Activities\Interaction\Scaffolding\BaseMenuItem.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="App\Common.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\AboutResources.txt" />
<None Include="Properties\AndroidManifest.xml" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\MainLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
<AndroidResource Include="Resources\values\colors.xml" />
<AndroidResource Include="Resources\values\ic_launcher_background.xml" />
<AndroidResource Include="Resources\values\strings.xml" />
<AndroidResource Include="Resources\mipmap-anydpi-v26\ic_launcher.xml" />
<AndroidResource Include="Resources\mipmap-anydpi-v26\ic_launcher_round.xml" />
<AndroidResource Include="Resources\mipmap-hdpi\ic_launcher.png" />
<AndroidResource Include="Resources\mipmap-hdpi\ic_launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-hdpi\ic_launcher_round.png" />
<AndroidResource Include="Resources\mipmap-mdpi\ic_launcher.png" />
<AndroidResource Include="Resources\mipmap-mdpi\ic_launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-mdpi\ic_launcher_round.png" />
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png" />
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_round.png" />
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher.png" />
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher_round.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher_round.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\ListLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\ComboLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\TextEditLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\TimeLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\IgnitionLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\PinLayout.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MotoBle\MotoBle.csproj">
<Project>{61a6eb26-f9fc-4c26-8842-b25f6aa2cae1}</Project>
<Name>MotoBle</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\moto32x32.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
And here is the project file of the 'MotoBle' library referanced by the main app project:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{61A6EB26-F9FC-4C26-8842-B25F6AA2CAE1}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{9ef11e43-1701-4396-8835-8392d57abb70}</TemplateGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MotoBle</RootNamespace>
<AssemblyName>MotoBle</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android">
<HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\Mono.Android.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdvertisementService.cs" />
<Compile Include="BleDevice.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Platform.cs" />
<Compile Include="Spec\Descriptors\CharacteristicPresentationFormat.cs" />
<Compile Include="Spec\Descriptors\CharacteristicUserDescription.cs" />
<Compile Include="Spec\Descriptors\ClientCharacteristicConfiguration.cs" />
<Compile Include="Spec\Descriptors\DescriptorBase.cs" />
<Compile Include="Spec\Utilities.cs" />
<Compile Include="CommandService.cs" />
<Compile Include="GattCallback.cs" />
<Compile Include="GattCommand.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\strings.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\drawable\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
i humbly request any info that might help.

Minimal Visual Studio project with custom target only: Disable IntelliSense and allow single file processing?

For our Visual Studio Solution, I want to create one project that just generates some files with custom scripts. I have a somewhat-working solution, further reduced to provide as an example here:
This is my minimal.vcxproj:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Universal|Win32">
<Configuration>Universal</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="common.fooconf" />
</ItemGroup>
<ItemGroup>
<Foo Include="file1.foo" />
<Foo Include="file2.foo" />
</ItemGroup>
<Target Name="Build" Inputs="common.fooconf;#(Foo)" Outputs="Output\%(Foo.Filename).bar">
<MakeDir Directories="Output" />
<Exec Command='TYPE "common.fooconf" "%(Foo.FullPath)" > "Output\%(Foo.Filename).bar"' />
</Target>
<Target Name="Clean">
<RemoveDir Directories="Output" />
</Target>
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
</Project>
And I need this minimal.vcxproj.filters to make the three contained files show up in VS's solution explorer:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="common.fooconf"/>
</ItemGroup>
<ItemGroup>
<Foo Include="file1.foo"/>
<Foo Include="file2.foo"/>
</ItemGroup>
</Project>
Now there are still two problems:
When loading the project, I get error : Designtime build failed for project '[...]\minimal.vcxproj' configuration 'Universal|Win32'. IntelliSense might be unavailable. Check *.designtime.log files in your %TEMP% directory. If I look up in the log, the error is error MSB4057: The target "GetClCommandLines" does not exist in the project. Of course IntelliSense doesn't make sense here (TYPE is just a placeholder for a custom script), but there must be a way of getting rid of this warning.
Build (e.g. via F7) works like a charm (even incremental), but it would be really important for us to trigger processing single files (e.g. CtrlF7). But I can't find out how to make this work.
Using Visual Studio 2019, I needed to add the following targets to have the project load without warnings. This was done by checking the designtime logs and incrementally adding targets, until there were no more warnings.
<Target Name="GetProjectDirectories" />
<Target Name="GetClCommandLines" />
<Target Name="GetGeneratedFiles" />
<Target Name="GetAssemblyReferences" />
<Target Name="GetWinMDReferences" />
<Target Name="GetComReferences" />
<Target Name="GetSDKReferences" />
<Target Name="GetProjectReferences" />
<Target Name="GetForeignReferences" />
<Target Name="GetResolvedReferences" />
<Target Name="GetResolvedSDKReferences" />
<Target Name="GetProjectReferencesInfo" />
<Target Name="GetResolvedLinkLibs" />

Exclude `.js` files but not '.min.js' files from MSBuild publish

Using Visual Studio and MSBuild I would like to be able to exclude all .js files and include all .min.js files in my deployments.
I know this can be achieved using the file properties in visual studio, but this is not an option as there are far too many files.
I have the following PublishProfile in my Visual Studio project. Everything works just fine apart from the <ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Delpoy-Static</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>\\***\wwwroot\***.com\static</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
<!--This does not work, but gives the idea of what I want to achieve-->
<ItemGroup>
<Deploy Exclude="**\*.js" Include="**\*.min.js" />
</ItemGroup>
</Project>
Can this be achieved using the PublishProfile? If so, how?
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<!-- ... -->
</PropertyGroup>
<Target Name="BeforeBuild">
<ItemGroup>
<Minified Include="**\*.min.js" />
<Maxified Include="**\*.js" Exclude="#(Minified)" />
<Content Remove="#(Maxified)" />
</ItemGroup>
</Target>
</Project>
Edit:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<!-- ... -->
</PropertyGroup>
<ItemGroup>
<Minified Include="**\*.min.js" />
<Maxified Include="**\*.js" Exclude="#(Minified)" />
</ItemGroup>
<PropertyGroup>
<ExcludeFoldersFromDeployment>bin</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>#(Maxified);Web.config</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
If you want to exclude files you can place the files to be excluded in the the ExcludeFromPackageFiles item group. In your case you want to take all .js files and exclude all but those that are *.min.js. To do that in your .pubxml file add the following in your .pubxml file .
<ItemGroup>
<ExcludeFromPackageFiles Include="js\**\*.js" Exclude="js\**\*min*.js">
<FromTarget>Project</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
Note: this snippet assumes that your .js files are in a folder named js.
work to me:
Edit .csproj file
Find section MinifyJavaScriptAndCSS
Edit property Exclude in JS tag
Add directory or files to ignore during publish
<Target Name="MinifyJavaScriptAndCSS" AfterTargets="CopyAllFilesToSingleFolderForPackage" Condition="'$(Configuration)'=='Release'">
<ItemGroup>
<!-- Every .js file (exclude *.min.js and *.vsdoc.js files) -->
<JS Include="$(_PackageTempDir)\**\*.js" Exclude="$(_PackageTempDir)\**\*.min.js;$(_PackageTempDir)\**\*vsdoc.js;" />
<CSS Include="$(_PackageTempDir)\**\*.css" Exclude="$(_PackageTempDir)\**\*.min.css" />
</ItemGroup>
<AjaxMin JsKnownGlobalNames="jQuery,$" JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
<Message Text="[pcv] $(MSBuildProjectName) -> Minified: #(JS)" Importance="high" />
<Message Text="[pcv] $(MSBuildProjectName) -> Minified: #(CSS)" Importance="high" />

Setting Visual Studio to automatically minifying using Ajax Minifier

I use VS 2010 I would like at the pressing of Build Button have all CSS and .JS files minified.
Following this article all is working great for JS... adding some extra code for the CSS (pasted below) I'm not able to Minifying the CSS. What I'm doing wrong here?
Thanks for your time.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
<JS Include="**\*.css" Exclude="**\*.min.css;Scripts\*.css" />
</ItemGroup>
<AjaxMin SourceFiles="#(JS)" SourceExtensionPattern="\.js$" TargetExtension=".min.js" />
<AjaxMin SourceFiles="#(CSS)" SourceExtensionPattern="\.css$" TargetExtension=".min.css" />
</Target>
I found out the solution to my problem, more resource here
Unable to run Ajax Minifier as post-build in Visual Studio
http://ajaxmin.codeplex.com/wikipage?title=AjaxMinTask
Also very interesting:
http://www.codeproject.com/Articles/81317/Automatically-compress-embedded-JavaScript-resourc.aspx?msg=3802401&display=Mobile
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
</ItemGroup>
<ItemGroup>
<CSS Include="**\*.css" Exclude="**\*.min.css" />
</ItemGroup>
<AjaxMin
JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js"
CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
</Target>
On my project file I used "UsingTask" instead of "Import" and it's working:
<UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectDirectory)\..\..\packages\AjaxMin.5.14.5506.26202\tools\net40\AjaxMinTask.dll" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
</ItemGroup>
<ItemGroup>
<CSS Include="**\*.css" Exclude="**\*.min.css" />
</ItemGroup>
<AjaxMin
JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js"
CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
</Target>

Why doesn't my MSBuild project build incrementally?

I have a project which generates a class from its XSD definition, then builds it. My problem is that, even though I specify the inputs and outputs of my Xsd target, it still gets executed every time I build the Visual Studio solution. What could be the problem here?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" InitialTargets="Xsd" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- snip -->
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="request.cs">
<DependentUpon>request.xsd</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="key.snk" />
</ItemGroup>
<ItemGroup>
<Xsd Include="request.xsd" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="Xsd" Inputs="#(Xsd)" Outputs="request.cs">
<Exec Command='"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\xsd.exe" "#(Xsd)" /c /o:..\.. /n:Order.Messaging' />
</Target>
</Project>
Remove Xsd target from InitialTargets
Initial targets are typically used for error checking.
and add dependency to BeforeBuild Target:
<Target Name="BeforeBuild" DependsOnTargets="Xsd" />

Resources