I want to exclude ALL files & folders in wwwroot\data from being published to my website folder. The files in my website folder are the latest copy and should never be overwritten when I publish the project.
Reference Microsoft documentation
The documentation indicates using this xml in .csproj file but I can't get it to work. I've tried putting this in both my .csproj file and .pubxml with no success.
What am I doing wrong? Can someone tell me if this actually works?
<ItemGroup>
<MsDeploySkipRules Include="CustomSkipFolder">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>wwwroot\\data</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
Here is my .pubxml file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>C:\www\VisualStudio2019-Core3</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>881d6bfb-ed04-41d7-b600-0e26765ff90e</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
Tried putting code here -->>
</Project>
Here is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>VisualStudio2019_Core3</RootNamespace>
<UserSecretsId>93d2ec1f-4bcc-4aa5-ad65-4bdbdce5690a</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
</ItemGroup>
Tried putting code here -->>
</Project>
Additional information:
Visual Studio 2019
Web Application Core 3.1
Publishing via Studio menus...not command line.
I used this (referring to my webapp) after end tag PropertyGroup
<ItemGroup>
<Content Remove="appsettings.Development.*" />
<Content Remove="bundleconfig.json" />
<Content Remove="wwwroot\js\Site.js" />
<Content Remove="wwwroot\js\webcam-easy.js" />
<Content Remove="wwwroot\js\webcam-app.js" />
<Content Remove="wwwroot\css\Site.css" />
<Content Update="wwwroot\js\Site.js" CopyToPublishDirectory="Never" />
<Content Update="wwwroot\js\webcam-easy.js" CopyToPublishDirectory="Never" />
<Content Update="wwwroot\js\webcam-app.js" CopyToPublishDirectory="Never" />
<Content Update="wwwroot\css\Site.css" CopyToPublishDirectory="Never" />
<ResolvedFileToPublish Include="wwwroot\css\xxxxx.min.css">
<RelativePath>wwwroot\css\xxxxx.min.css</RelativePath>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="wwwroot\js\xxxxx.min.js">
<RelativePath>wwwroot\js\xxxxx.min.js</RelativePath>
</ResolvedFileToPublish>
<MsDeploySkipRules Include="connectionconfig">
<ObjectName>filePath</ObjectName>
<AbsolutePath>connection.json</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
Related
I get this error building my specflow test project
I cannot figure out why I get these compile bugs..
I am quite sure it has to do with use .NET 5,
don't have a lib folder, where the libraries/nugets are stored...
my project looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<Folder Include="Drivers\" />
<Folder Include="Hooks\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MagVenture.Utilities.UI\MagVenture.Utilities.UI.csproj" />
</ItemGroup>
I cannot figure it out... - there is a twirl somewhere that I didn't see..
Disable the NU5100 warning, when treating warnings as errors.
it is due to the .NET framework versions policies about location in lib folder.
I want to build my NuGet package in one of my TFS build steps.
Because .NET Standard 2.0 is currently not supported by the TFS NuGet step, I am using /t:pack as the build argument in my MSBuild invocation.
When I only use one TargetFramework it is working fine. My assemblies get a version and my NuGet package too.
Even if I am using an AssemblyInfo.cs in .NET Standard 2.0 - explained in this answer.
So far no problem, but if I want to build now on two different TargetFrameworks like <TargetFramework>netstandard2.0;net45</TargetFramework> my NuGet package won't get a Version.
So in the end this is working and is generating a versioned NuGet file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);ReadPackageVersionFromOutputAssembly</GenerateNuspecDependsOn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<Target Name="ReadPackageVersionFromOutputAssembly" DependsOnTargets="Build">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="PackAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<ItemGroup>
<Compile Remove="AccessControl\**" />
<EmbeddedResource Remove="AccessControl\**" />
<None Remove="AccessControl\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\common\Version.cs" Link="Properties\Version.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.8.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="MyEngine">
<HintPath>..\libs\NetStandard\MyEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
So here is my current .csproj file. This builds too and also generates a NuGet file. But in this case my NuGet file is unversioned. Why is it this way and how can I fix it?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);ReadPackageVersionFromOutputAssembly</GenerateNuspecDependsOn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<Target Name="ReadPackageVersionFromOutputAssembly" DependsOnTargets="Build">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="PackAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<ItemGroup>
<Compile Remove="AccessControl\**" />
<EmbeddedResource Remove="AccessControl\**" />
<None Remove="AccessControl\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\common\Version.cs" Link="Properties\Version.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.8.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="MyEngine">
<HintPath>..\libs\NetStandard\MyEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="MyEngine">
<HintPath>..\libs\NET45\MyEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
The targets can be adapted to support multi-targeting like this:
<Target Name="ReadPackageVersionFromOutputAssemblySingleTfm" Returns="#(PackAssembly)" Condition="'$(IsCrossTargetingBuild)' != 'true'">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="PackAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<Target Name="ReadPackageVersionFromOutputAssemblyMultipleTfms" Condition="'$(IsCrossTargetingBuild)' == 'true'">
<PropertyGroup>
<FirstTargetFramework>$([System.String]::Copy($(TargetFrameworks)).Split(';').GetValue(0))</FirstTargetFramework>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="ReadPackageVersionFromOutputAssemblySingleTfm" Properties="TargetFramework=$(FirstTargetFramework)">
<Output TaskParameter="TargetOutputs" ItemName="PackAssembly" />
</MSBuild>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<Target Name="ReadPackageVersionFromOutputAssembly" DependsOnTargets="Build;ReadPackageVersionFromOutputAssemblySingleTfm;ReadPackageVersionFromOutputAssemblyMultipleTfms" />
I've got the following set up (uninteresting XML removed for brevity):
MyProject.fsproj
<Project ...>
<Import Project="MyTask.props" />
...
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>
MyTask.props
<Project ...>
<UsingTask XXX.UpdateAssemblyInfo />
<Target Name="UpdateAssemblyInfo"
BeforeTargets="CoreCompile">
<UpdateAssemblyInfo ...>
<Output
TaskParameter="AssemblyInfoTempFilePath"
PropertyName="AssemblyInfoTempFilePath" />
</UpdateAssemblyInfo>
<ItemGroup>
<Compile Include="$(AssemblyInfoTempFilePath)" />
</ItemGroup>
</Target>
</Project>
The problem is that the ItemGroup added by MyTask.props is added last, despite being imported right at the very start of the project. I assume that this is because the ItemGroup is not actually imported then - it's added by when the task is run.
This isn't a good thing in F#, as file order is important - including the file at the end of the build list means it's impossible to build an EXE, for example (as the entrypoint must be in the last file).
Hence my question - is there a way for me to output an ItemGroup as part of a Target and have that generated ItemGroup be first?
A bit late, but this may help someone in the future, I'm not using the import tag on this sample, but it will work the same way, the important part is the "UpdateAssemblyInfo" target, the main idea is to clear and regenerate the Compile ItemGroup using the appropriate sort order.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Target Name="Build" DependsOnTargets="UpdateAssemblyInfo">
</Target>
<Target Name="UpdateAssemblyInfo">
<!-- Generate your property -->
<PropertyGroup>
<AssemblyInfoTempFilePath>ABC.xyz</AssemblyInfoTempFilePath>
</PropertyGroup>
<!-- Copy current Compile ItemGroup to TempCompile -->
<ItemGroup>
<TempCompile Include="#(Compile)"></TempCompile>
</ItemGroup>
<!-- Clear the Compile ItemGroup-->
<ItemGroup>
<Compile Remove="#(Compile)"/>
</ItemGroup>
<!-- Create the new Compile ItemGroup using the required order -->
<ItemGroup>
<Compile Include="$(AssemblyInfoTempFilePath)"/>
<Compile Include="#(TempCompile)"/>
</ItemGroup>
<!-- Display the Compile ItemGroup ordered -->
<Message Text="Compile %(Compile.Identity)"/>
</Target>
</Project>
I have an asp.net mvc 3 project and a separate BusinessLayer project included in the solution. When I'm trying to deploy my site to Azure via local git repository, I'm getting the following error: '<remote_path>\BusinessLayer\BusinessLayer.csproj' is not a deployable project.. No other information is provided in logs. Site perfectly deploys on my local server. So I want to know at least some possible reasons why this error occurs. Thanks in advance.
Here's my .csproj file, if necessary:
<?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>{31F2F6FE-10D8-4510-AC61-CBE1962D3940}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BusinessLayer</RootNamespace>
<AssemblyName>BusinessLayer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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="MongoDB.Bson">
<HintPath>..\..\Libs\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver">
<HintPath>..\..\Libs\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Battle.cs" />
<Compile Include="BattleManager.cs" />
<Compile Include="BattlePlace.cs" />
<Compile Include="Helpers\ConvertHelper.cs" />
<Compile Include="Helpers\ImageHelper.cs" />
<Compile Include="Message.cs" />
<Compile Include="Picture.cs" />
<Compile Include="Place.cs" />
<Compile Include="PlaceManager.cs" />
<Compile Include="Subject.cs" />
<Compile Include="User.cs" />
<Compile Include="Helpers\DBHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.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>
You may need to tell Azure exactly which project it should deploy, which you can do using a .deployment file at the root of your project. e.g.
[config]
project = WebProject/WebProject.csproj
Please see this page for more information about this.
Sounds like you're trying to deploy the BusinessLayer project and not the Website project. As long as your MVC site project has a reference to BusinessLayer, just deploy the website. BusinessLayer will be included as a reference.
You can't deploy BusinessLayer by itself, as it is a library and not an application.
I want to unbind my sln file from TFS server and publish it on SVN is there any "easy" option to do this. It's easy to open sln and chose unbind option in Visual Studio, but does any one ever tried to automate this process? There is a solution to edit sln file using xmlpoke and deleting binding information, but is it safe?
I have some samples published on the MSDN Code Gallery for the TFS 2010 SDK that illustrate how to do this with MSBuild and the MSBuild Community Tasks. Here's a snippet of MSBuild script from the WorkItemObjectModel sample's WorkItemType.csproj file:
<Import Project="$(MSBuildExtensionsPath32)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<ItemGroup>
<SourceFiles
Include="$(SolutionDir)**/*.*"
Exclude="$(SolutionDir)Package/**/*.*;$(SolutionDir)**/bin/**/*.*;$(SolutionDir)**/obj/**/*.*;$(SolutionDir)**/internal.proj;$(SolutionDir)**/*.*scc;$(SolutionDir)$(SolutionName).zip">
<Visible>False</Visible>
</SourceFiles>
</ItemGroup>
<Target Name="AfterBuild" Condition="'$(Configuration)'=='Release'"
Inputs="#(SourceFiles)" Outputs="$(SolutionDir)$(SolutionName).zip">
<Delete
Files="$(SolutionDir)$(SolutionName).zip"
Condition="Exists('$(SolutionDir)$(SolutionName).zip')" />
<PropertyGroup>
<PackageDir>$(SolutionDir)Package\</PackageDir>
</PropertyGroup>
<MakeDir
Directories="$(PackageDir)" />
<Copy
SourceFiles="#(SourceFiles)"
DestinationFiles="$(PackageDir)%(RecursiveDir)%(Filename)%(Extension)" />
<Delete
Files="$(PackageDir)**/bin/**/*.*;$(PackageDir)**/obj/**/*.*" />
<RemoveDir
Directories="$(PackageDir)**/bin;$(PackageDir)**/obj" />
<Attrib
Files="#(PackageFiles)"
ReadOnly="false" />
<FileUpdate
Files="$(PackageDir)$(SolutionFileName)"
IgnoreCase="true"
Regex="^\s+GlobalSection\(TeamFoundationVersionControl\).+\n(\s*Scc.*\n)+\s+EndGlobalSection"
ReplacementText=" "
Multiline="true"
Singleline="false" />
<ItemGroup>
<ProjectFiles Include="$(PackageDir)**/*.*proj" />
</ItemGroup>
<FileUpdate
Files="#(ProjectFiles)"
Regex="<Scc[A-z]+>.+</Scc[A-z]+>"
ReplacementText=" " />
<ItemGroup>
<PackageFiles Include="$(PackageDir)**\*.*" />
</ItemGroup>
<Zip
Files="#(PackageFiles)"
WorkingDirectory="$(PackageDir)"
ZipFileName="$(SolutionDir)$(SolutionName).zip" />
<Delete
Files="#(PackageFiles)" />
<RemoveDir
Directories="$(PackageDir)" />
</Target>
In a nutshell, this script copies the source files to a temporary directory, removes the source control bindings from the solution and project files, then zips up the sources and finally deletes the temporary directory.