Skip to content

Don't set a default ProjectAssetsFile path in the SDK #2010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,7 @@
{1} - Restored version of platform package
{2} - Current version of platform package</comment>
</data>
<data name="AssetsFileNotSet" xml:space="preserve">
<value>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</value>
</data>
</root>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@
{1} - Restored version of platform package
{2} - Current version of platform package</note>
</trans-unit>
<trans-unit id="AssetsFileNotSet">
<source>The path to the project assets file was not set. Run a NuGet package restore to generate this file.</source>
<target state="new">The path to the project assets file was not set. Run a NuGet package restore to generate this file.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Microsoft.NET.Build.Tasks
{
public class CheckForTargetInAssetsFile : TaskBase
{
[Required]
public string AssetsFilePath { get; set; }

[Required]
Expand Down
1 change: 0 additions & 1 deletion src/Tasks/Microsoft.NET.Build.Tasks/FilterResolvedFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class FilterResolvedFiles : TaskBase
private readonly List<ITaskItem> _assembliesToPublish = new List<ITaskItem>();
private readonly List<ITaskItem> _packagesResolved = new List<ITaskItem>();

[Required]
public string AssetsFilePath { get; set; }

[Required]
Expand Down
1 change: 0 additions & 1 deletion src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class GenerateDepsFile : TaskBase
[Required]
public string ProjectPath { get; set; }

[Required]
public string AssetsFilePath { get; set; }

[Required]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace Microsoft.NET.Build.Tasks
/// </summary>
public class GenerateRuntimeConfigurationFiles : TaskBase
{
[Required]
public string AssetsFilePath { get; set; }

[Required]
Expand Down
22 changes: 22 additions & 0 deletions src/Tasks/Microsoft.NET.Build.Tasks/LoadAssetsFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.NET.Build.Tasks
{
public sealed class LoadAssetsFile : TaskBase
{
/// <summary>
/// The assets file to process
/// </summary>
public string ProjectAssetsFile
{
get; set;
}

protected override void ExecuteCore()
{
var lockFile = new LockFileCache(this).GetLockFile(ProjectAssetsFile);
}
}
}
4 changes: 4 additions & 0 deletions src/Tasks/Microsoft.NET.Build.Tasks/LockFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public LockFileCache(Task task)

public LockFile GetLockFile(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new BuildErrorException(Strings.AssetsFileNotSet);
}
if (!Path.IsPathRooted(path))
{
throw new BuildErrorException(Strings.AssetsFilePathNotRooted, path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public sealed class ReportAssetsLogMessages : TaskBase
/// <summary>
/// The assets file to process
/// </summary>
[Required]
public string ProjectAssetsFile
{
get; set;
Expand Down
8 changes: 6 additions & 2 deletions src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public sealed class ResolvePackageAssets : TaskBase
/// <summary>
/// Path to assets.json.
/// </summary>
[Required]
public string ProjectAssetsFile { get; set; }

/// <summary>
Expand Down Expand Up @@ -225,6 +224,11 @@ public sealed class ResolvePackageAssets : TaskBase

protected override void ExecuteCore()
{
if (string.IsNullOrEmpty(ProjectAssetsFile))
{
throw new BuildErrorException(Strings.AssetsFileNotSet);
}

ReadItemGroups();
SetImplicitMetadataForCompileTimeAssemblies();
SetImplicitMetadataForFrameworkAssemblies();
Expand Down Expand Up @@ -317,7 +321,7 @@ internal byte[] HashSettings()
writer.Write(MarkPackageReferencesAsExternallyResolved);
writer.Write(ImplicitPlatformPackageIdentifier ?? "");
writer.Write(ProjectAssetsCacheFile);
writer.Write(ProjectAssetsFile);
writer.Write(ProjectAssetsFile ?? "");
writer.Write(ProjectLanguage ?? "");
writer.Write(ProjectPath);
writer.Write(RuntimeIdentifier ?? "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public string ProjectPath
/// <summary>
/// The assets file to process
/// </summary>
[Required]
public string ProjectAssetsFile
{
get; set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class ResolvePublishAssemblies : TaskBase
[Required]
public string ProjectPath { get; set; }

[Required]
public string AssetsFilePath { get; set; }

[Required]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

<!-- Project Assets File -->
<PropertyGroup>
<ProjectAssetsFile Condition="'$(ProjectAssetsFile)' == ''">$(BaseIntermediateOutputPath)/project.assets.json</ProjectAssetsFile>
<ProjectAssetsFile>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(ProjectAssetsFile)))</ProjectAssetsFile>

<!-- Note that the assets.cache file has contents that are unique to the current TFM and configuration and therefore cannot
be stored in a shared directory next to the assets.json file -->
<ProjectAssetsCacheFile Condition="'$(ProjectAssetsCacheFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).assets.cache</ProjectAssetsCacheFile>
<ProjectAssetsCacheFile>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(ProjectAssetsCacheFile)))</ProjectAssetsCacheFile>
</PropertyGroup>

<PropertyGroup>
<ResolvePackageDependenciesForBuild Condition="'$(ResolvePackageDependenciesForBuild)' == ''">true</ResolvePackageDependenciesForBuild>

<CopyLocalLockFileAssemblies Condition="'$(CopyLocalLockFileAssemblies)' == ''">true</CopyLocalLockFileAssemblies>

<ContentPreprocessorOutputDirectory Condition="'$(ContentPreprocessorOutputDirectory)' == ''">$(IntermediateOutputPath)NuGet\</ContentPreprocessorOutputDirectory>
Expand Down Expand Up @@ -130,7 +123,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</ResolvePackageDependenciesForBuildDependsOn>
</PropertyGroup>
<Target Name="ResolvePackageDependenciesForBuild"
Condition="'$(ResolvePackageDependenciesForBuild)' == 'true' and Exists('$(ProjectAssetsFile)')"
Condition=" '$(DesignTimeBuild)' != 'true' Or Exists('$(ProjectAssetsFile)')"
BeforeTargets="AssignProjectConfiguration"
DependsOnTargets="$(ResolvePackageDependenciesForBuildDependsOn)" />

Expand Down Expand Up @@ -370,6 +363,8 @@ Copyright (c) .NET Foundation. All rights reserved.

<UsingTask TaskName="Microsoft.NET.Build.Tasks.ReportAssetsLogMessages"
AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="Microsoft.NET.Build.Tasks.LoadAssetsFile"
AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />

<!-- The condition on this target causes it to be skipped during design-time builds if
the restore operation hasn't run yet. This is to avoid displaying an error in
Expand All @@ -378,6 +373,10 @@ Copyright (c) .NET Foundation. All rights reserved.
<Target Name="ReportAssetsLogMessages"
Condition="'$(EmitAssetsLogMessages)' == 'true' And ('$(DesignTimeBuild)' != 'true' Or Exists('$(ProjectAssetsFile)'))">

<!-- Load the assets file in a separate task, so that if the file itself can't be loaded (or isn't set), we
can generate an error without continuing (since ReportAssetsLogMessages uses ContinueOnError="ErrorAndContinue" -->
<LoadAssetsFile ProjectAssetsFile="$(ProjectAssetsFile)" />

<ReportAssetsLogMessages
ProjectAssetsFile="$(ProjectAssetsFile)"
ContinueOnError="ErrorAndContinue">
Expand Down
Loading